Package com.ibm.di.parser
Class HTTPParser
- java.lang.Object
-
- com.ibm.di.parser.ParserImpl
-
- com.ibm.di.parser.HTTPParser
-
- All Implemented Interfaces:
ParserInterface,VersionInfoInterface
public class HTTPParser extends ParserImpl
The HTTP Parser interprets a byte stream according to the HTTP specification. This Parser is used by the HTTP Client Connector and by the HTTP Server Connector.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringENCODING_LATIN_1(ISO Latin 1) Character Encoding.static java.lang.StringHTTP_FILE_NOT_FOUNDString containing the status code and reason phrase for unsuccessful action when the server has not found anything matching the Request-URI.static java.lang.StringHTTP_FORBIDDENString containing the status code and reason phrase for unsuccessful action because the request requires user authentication.static java.lang.StringHTTP_OKString containing the status code and reason phrase for successfully received, understood and accepted action.static java.lang.StringHTTP_REDIRString containing the status code and reason phrase for redirection when the requested resource resides temporarily under a different URI.-
Fields inherited from class com.ibm.di.parser.ParserImpl
_debug, myConfiguration
-
-
Constructor Summary
Constructors Constructor Description HTTPParser()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.String[]getNames(Entry e)Returns property/attribute names in specified entry.java.lang.ObjectgetProp(Entry e, java.lang.String prop)Return a property/attribute value of specified entry.java.lang.StringgetVersion()Version information.voidhttpAuthenticationRequest(java.lang.String realm)Send a Forbidden response requesting authentication.voidhttpForbidden()Send a HTTP response message with error code 401 (Forbidden) into the current output writer.voidinitParser()Perform initialization of parser.voidparseAuthentication(Entry entry)Decode the username and password specified in the Authorization header of the request HTTP message.intreadByte()Reads one byte of the current input reader.EntryreadEntry()Reads entry from the current input reader.java.lang.StringreadLine()Reads line from the current input reader.voidsendAuthorization(Entry entry, java.io.BufferedWriter out)Send client authorization.voidsendProxyAuthorization(java.lang.String user, java.lang.String pass, java.io.BufferedWriter out)voidsetClientMode(boolean clientMode)Sets the client mode.voidsetProp(Entry e, java.lang.String prop, java.lang.Object value)Sets a property/attribute's value of specified entry.voidsetUseProperties(boolean useProps)Sets the user properties.voidwriteEntry(Entry entry)Writes an entry to the current output writer.-
Methods inherited from class com.ibm.di.parser.ParserImpl
closeParser, debug, debugMode, flush, getClassInstance, getContext, getDebug, getInputStream, getOutputStream, getParam, getParser, getReader, getWriter, isDeltaSupported, logmsg, querySchema, registerScriptBeans, setConfiguration, setContext, setDebug, setInputStream, setInputStream, setInputStream, setOutputStream, setOutputStream, setParam, setParser
-
-
-
-
Field Detail
-
HTTP_OK
public static final java.lang.String HTTP_OK
String containing the status code and reason phrase for successfully received, understood and accepted action.- See Also:
- Constant Field Values
-
HTTP_FILE_NOT_FOUND
public static final java.lang.String HTTP_FILE_NOT_FOUND
String containing the status code and reason phrase for unsuccessful action when the server has not found anything matching the Request-URI.- See Also:
- Constant Field Values
-
HTTP_FORBIDDEN
public static final java.lang.String HTTP_FORBIDDEN
String containing the status code and reason phrase for unsuccessful action because the request requires user authentication.- See Also:
- Constant Field Values
-
HTTP_REDIR
public static final java.lang.String HTTP_REDIR
String containing the status code and reason phrase for redirection when the requested resource resides temporarily under a different URI.- See Also:
- Constant Field Values
-
ENCODING_LATIN_1
public static final java.lang.String ENCODING_LATIN_1
(ISO Latin 1) Character Encoding.- See Also:
- Constant Field Values
-
-
Method Detail
-
initParser
public void initParser() throws java.lang.ExceptionPerform initialization of parser.- Specified by:
initParserin interfaceParserInterface- Overrides:
initParserin classParserImpl- Throws:
java.lang.Exception- if an error occurs.
-
setUseProperties
public void setUseProperties(boolean useProps)
Sets the user properties.- Parameters:
useProps- the new properties.
-
setClientMode
public void setClientMode(boolean clientMode)
Sets the client mode.- Parameters:
clientMode- the new client mode.
-
readByte
public int readByte() throws java.lang.ExceptionReads one byte of the current input reader.- Returns:
- the read byte
- Throws:
java.lang.Exception- If an I/O error occurs
-
readLine
public java.lang.String readLine() throws java.lang.ExceptionReads line from the current input reader.- Returns:
- the read line
- Throws:
java.lang.Exception- If an I/O error occurs
-
readEntry
public Entry readEntry() throws java.lang.Exception
Reads entry from the current input reader. Depending on whether the parameterheadersAsPropertiesis checked, read headers are represented as attributes or properties.- Returns:
- the read entry
- Throws:
java.lang.Exception- If an I/O error occurs
-
writeEntry
public void writeEntry(Entry entry) throws java.lang.Exception
Writes an entry to the current output writer.- Parameters:
entry- the entry to be written.- Throws:
java.lang.Exception-- if
http.urlis missing- if an I/O error occurs
- if base64 encoding fails
- if
-
parseAuthentication
public void parseAuthentication(Entry entry) throws java.lang.Exception
Decode the username and password specified in the Authorization header of the request HTTP message. The character encoding used is 'iso-8859-1'.- Parameters:
entry- entry containing the authorization header.- Throws:
java.lang.Exception- if the charset conversion failed
-
setProp
public void setProp(Entry e, java.lang.String prop, java.lang.Object value)
Sets a property/attribute's value of specified entry. The result depends on whetherheadersAsPropertiesparameter is checked.- Parameters:
e- the entryprop- The name of the property/attribute.value- The value of the property/attribute.
-
getProp
public java.lang.Object getProp(Entry e, java.lang.String prop)
Return a property/attribute value of specified entry. The result depends on whetherheadersAsPropertiesparameter is checked.- Parameters:
e- the entryprop- The name of the property/attribute.- Returns:
- The property/attribute's value or null if such does not exists.
-
getNames
public java.lang.String[] getNames(Entry e)
Returns property/attribute names in specified entry. The result depends on whetherheadersAsPropertiesparameter is checked.- Parameters:
e- the entry- Returns:
- Array of strings with property/attribute names
-
httpForbidden
public void httpForbidden() throws java.io.IOExceptionSend a HTTP response message with error code 401 (Forbidden) into the current output writer.- Throws:
java.io.IOException- If an I/O error occurs.
-
httpAuthenticationRequest
public void httpAuthenticationRequest(java.lang.String realm) throws java.io.IOExceptionSend a Forbidden response requesting authentication.This method sends response message with error code 401 (Forbidden) when a request is made to protected resources. The response message includes a WWW-Authenticate header specifying a scheme and a realm.
- Parameters:
realm- Therealmis string that defines a protection space (a set of protected resources) within the same host.- Throws:
java.io.IOException- If an I/O error occurs.
-
sendAuthorization
public void sendAuthorization(Entry entry, java.io.BufferedWriter out) throws java.lang.Exception
Send client authorization.- Parameters:
entry- entry containing HTTP message attributes.out- the output writer.- Throws:
java.lang.Exception- If an I/O error occurs or if base64 encoding fails.
-
sendProxyAuthorization
public void sendProxyAuthorization(java.lang.String user, java.lang.String pass, java.io.BufferedWriter out) throws java.lang.Exception- Throws:
java.lang.Exception
-
getVersion
public java.lang.String getVersion()
Version information.- Returns:
- version information
-
-