|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--jason.framework.protocol.http.HttpRequestParserImpl
This class is responsible for parsing a HTTP request and obtain the following information
1) Fully qualified resource name 2) Header names 3) Header values 4) Request message body It takes a InputStream to access the client request.
TO DO : Support Transfer-Encoding, multipart/byteranges for the Body content Taking into account Keep-Alive for too long process
HttpParser
Field Summary | |
protected java.io.InputStream |
clientIStream
|
protected java.util.Hashtable |
headerTable
|
protected java.lang.String |
method
|
protected java.util.Hashtable |
parameterTable
|
protected java.lang.String |
protocol
|
protected java.lang.String |
requestURI
|
Constructor Summary | |
HttpRequestParserImpl()
This constructor is to be used while instances of this class is put into the ThreadPool individually or as a part of a different object |
|
HttpRequestParserImpl(java.io.InputStream clientIStream)
|
Method Summary | |
java.lang.String |
getHeader(java.lang.String header)
|
java.util.Enumeration |
getHeaderNames()
|
byte[] |
getMessageBody()
|
java.lang.String |
getMethod()
|
java.lang.String |
getParameter(java.lang.String parameter)
|
java.util.Enumeration |
getParameterNames()
|
java.lang.String |
getProtocol()
|
java.lang.String |
getRequestURI()
|
java.lang.String |
getRequestURIQuery()
|
boolean |
isParsed()
|
void |
parse(java.io.InputStream clientIStream)
Parses an HTTP request from the RFC 2068. |
protected void |
parseGenericLine(java.lang.String line,
java.lang.String separator,
java.util.Hashtable fields,
boolean resolve,
boolean lowerCase)
Parse a line based on Property |
protected void |
parseHeaderLine(java.lang.String line,
java.util.Hashtable fields,
boolean resolve)
Parses a single field=value line |
protected void |
parseHeaders(java.io.BufferedReader bufr,
java.util.Hashtable fields,
boolean resolve)
Parses headers following the requestLine. |
protected void |
parseParameters(java.lang.String requestLine,
java.io.InputStream content)
Parses parameters from the requestLine and from the buffer content. |
protected void |
parseRequest(java.lang.String requestLine)
Parse a request line From the RFC 2068 : request-line = Method SP Request-URI SP HTTP-Version CRLF |
protected void |
parseRequestParameter(java.lang.String parameter)
Parses the request-uri from the request-line ? |
protected void |
parseRequestParameterItem(java.lang.String parameterValue)
Parses a single field=value from the request-line |
void |
setClientIStream(java.io.InputStream clientIStream)
Pass an inputStream for parsing the request. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.lang.String protocol
protected java.lang.String method
protected java.util.Hashtable headerTable
protected java.util.Hashtable parameterTable
protected java.lang.String requestURI
protected java.io.InputStream clientIStream
Constructor Detail |
public HttpRequestParserImpl(java.io.InputStream clientIStream) throws HttpParsingException
public HttpRequestParserImpl() throws HttpParsingException
Method Detail |
public void setClientIStream(java.io.InputStream clientIStream)
parse
method for activation.
clientIStream
- inputStream contains an HTTP requestpublic java.lang.String getProtocol()
getProtocol
in interface HttpRequestParser
public java.lang.String getMethod()
getMethod
in interface HttpRequestParser
public java.lang.String getRequestURI()
getRequestURI
in interface HttpRequestParser
public java.lang.String getRequestURIQuery()
getRequestURIQuery
in interface HttpRequestParser
public java.lang.String getHeader(java.lang.String header)
getHeader
in interface HttpRequestParser
public java.util.Enumeration getHeaderNames()
getHeaderNames
in interface HttpRequestParser
public java.lang.String getParameter(java.lang.String parameter)
getParameter
in interface HttpRequestParser
parameter
- A parameter name
public java.util.Enumeration getParameterNames()
getParameterNames
in interface HttpRequestParser
public boolean isParsed()
true
if the request had been parsedprotected void parseHeaders(java.io.BufferedReader bufr, java.util.Hashtable fields, boolean resolve) throws java.io.IOException
bufr
- Buffer with fieldsfields
- hashtable with the resultresolve
- if true
, replace content %AA entity with real caracter value
java.io.IOException
protected void parseHeaderLine(java.lang.String line, java.util.Hashtable fields, boolean resolve)
line
- field=valuefields
- Stores the key and value from the field=valueresolve
- Chooses to resolve Entity %HH valueprotected void parseGenericLine(java.lang.String line, java.lang.String separator, java.util.Hashtable fields, boolean resolve, boolean lowerCase)
true
, then all entity %HH are replaced by an ASCII value
It stores the result in the fields
hashtable
line
- Line to parseseparator
- Property fields
- Store Property and Value in itresolve
- Resolve entity in the Valuepublic void parse(java.io.InputStream clientIStream) throws HttpParsingException
parse
in interface HttpRequestParser
HttpParsingException
- for an error while parsingprotected void parseRequest(java.lang.String requestLine)
requestLine
- protected void parseParameters(java.lang.String requestLine, java.io.InputStream content) throws java.io.IOException
java.io.IOException
public byte[] getMessageBody()
getMessageBody
in interface HttpRequestParser
protected void parseRequestParameter(java.lang.String parameter)
parameterTable
protected void parseRequestParameterItem(java.lang.String parameterValue)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |