ice.net
Class HttpParser

java.lang.Object
  extended byice.net.HttpParser

public class HttpParser
extends Object


Constructor Summary
HttpParser()
           
 
Method Summary
static void parseHeader(String header, HttpMessage httpMessage)
          Parses the specified HTTP header as defined by the specification.
static HttpResponse parseStatusLine(String statusLine)
          Parses the specified HTTP response statusLine as defined by the specification.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpParser

public HttpParser()
Method Detail

parseHeader

public static void parseHeader(String header,
                               HttpMessage httpMessage)
                        throws IllegalArgumentException,
                               ProtocolException

Parses the specified HTTP header as defined by the specification. The specification defines the header to be as follows: message-header = field-name ":" [ field-value ].

As a result of the parsing, the header is added to the specified httpMessage.

Parameters:
header - the header to be parsed.
httpMessage - the HTTP message to which the header is part of.
Throws:
IllegalArgumentException - if one of the following occurs:
  • the specified header is null;
  • the specified httpMessage is null.
ProtocolException - if some part of the header could not be parsed properly.

parseStatusLine

public static HttpResponse parseStatusLine(String statusLine)
                                    throws IllegalArgumentException,
                                           ProtocolException

Parses the specified HTTP response statusLine as defined by the specification. The specification defines the status line to be as follows: Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase (the specified statusLine should not contain the CRLF at the end.

As a result of the parsing, a HttpResponse object is returned containing the version, status code and reason phrase.

Parameters:
statusLine - the status line to be parsed.
Returns:
the HTTP response containing the parsed version, status code and reason phrase parts of the status line.
Throws:
IllegalArgumentException - if the specified statusLine is null
ProtocolException - if some part of the status line could not be parsed properly.