mmhttp.protocol
Class ResponseParser

java.lang.Object
  extended by mmhttp.protocol.ResponseParser

public class ResponseParser
extends java.lang.Object

Used to parse HTTP 1.1 responses.


Constructor Summary
ResponseParser(java.io.InputStream input)
          The Response will be read out of the provided InputStream.
 
Method Summary
 java.lang.String getBody()
           
 java.lang.String getHeader(java.lang.String key)
           
 int getStatus()
           
 boolean hasHeader(java.lang.String key)
           
static ResponseParser performHttpRequest(java.lang.String hostname, int hostPort, RequestBuilder builder)
          A convenience method that will perform a complete HTTP request, returning a parsed response.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ResponseParser

public ResponseParser(java.io.InputStream input)
               throws java.lang.Exception
The Response will be read out of the provided InputStream.

Parameters:
input -
Throws:
java.lang.Exception
Method Detail

getStatus

public int getStatus()
Returns:
the status of the response

getBody

public java.lang.String getBody()
Returns:
the body of the response

getHeader

public java.lang.String getHeader(java.lang.String key)
Parameters:
key -
Returns:
the value of the specified header, null if it doesn't exist

hasHeader

public boolean hasHeader(java.lang.String key)
Parameters:
key -
Returns:
true if the parsed response contains the specified header

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
a human readable representation of the response.

performHttpRequest

public static ResponseParser performHttpRequest(java.lang.String hostname,
                                                int hostPort,
                                                RequestBuilder builder)
                                         throws java.lang.Exception
A convenience method that will perform a complete HTTP request, returning a parsed response.

Parameters:
hostname -
hostPort -
builder -
Returns:
parsed response.
Throws:
java.lang.Exception


Copyright © 2009 Micah Martin. All Rights Reserved.