com.scooterframework.common.http
Class HTTPResponse

java.lang.Object
  extended by com.scooterframework.common.http.HTTPResponse

public class HTTPResponse
extends java.lang.Object

HTTPClient class represents a http response.


Constructor Summary
HTTPResponse(org.apache.http.HttpResponse response)
           
 
Method Summary
 java.lang.String[] getAllHeaders()
          Returns all headers.
 java.util.Map<java.lang.String,java.lang.String> getAllHeadersAsMap()
          Returns a map of all headers.
 java.util.Set<java.lang.String> getAllowedMethods()
          Returns a set of allowed methods.
 byte[] getContentAsBytes()
          Returns content as bytes.
 java.io.InputStream getContentAsInputStream()
          Returns content as input stream.
 java.lang.String getContentAsString()
          Returns content as string by using the platform's default charset.
 java.lang.String getContentAsString(java.lang.String charsetName)
          Returns content as string by using the specified charset.
 java.lang.String getContentEncodingLine()
          Returns the content encoding string, if known.
 java.lang.String getContentEncodingName()
          Returns the content encoding name, if known.
 java.lang.String getContentEncodingValue()
          Returns the content encoding value, if known.
 long getContentLength()
          Returns the length of the content, if known.
 java.lang.String getContentTypeLine()
          Returns the content type string, if known.
 java.lang.String getContentTypeName()
          Returns the content type name, if known.
 java.lang.String getContentTypeValue()
          Returns the content type value, if known.
 java.util.Set<java.lang.String> getHeaderValuesForName(java.lang.String name)
          Returns a set of values in the header associated with the name.
 java.lang.String getProtocolVersion()
          Returns http response protocol version.
 java.lang.String getReasonPhrase()
          Returns http response reason phrase.
 int getStatusCode()
          Returns http response status code.
 java.lang.String getStatusLine()
          Returns http response status.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HTTPResponse

public HTTPResponse(org.apache.http.HttpResponse response)
Method Detail

getStatusCode

public int getStatusCode()
Returns http response status code.

Returns:
status code

getReasonPhrase

public java.lang.String getReasonPhrase()
Returns http response reason phrase.

Returns:
reason phrase

getProtocolVersion

public java.lang.String getProtocolVersion()
Returns http response protocol version.

Returns:
protocol version

getStatusLine

public java.lang.String getStatusLine()
Returns http response status.

Returns:
status string

getContentEncodingLine

public java.lang.String getContentEncodingLine()
Returns the content encoding string, if known.

Returns:
the content encoding string, or null if the content encoding is unknown

getContentEncodingName

public java.lang.String getContentEncodingName()
Returns the content encoding name, if known.

Returns:
the content encoding name, or null if the content encoding is unknown

getContentEncodingValue

public java.lang.String getContentEncodingValue()
Returns the content encoding value, if known.

Returns:
the content encoding value, or null if the content encoding is unknown

getContentTypeLine

public java.lang.String getContentTypeLine()
Returns the content type string, if known.

Returns:
the content type header string, or null if the content type is unknown

getContentTypeName

public java.lang.String getContentTypeName()
Returns the content type name, if known.

Returns:
the content type name, or null if the content type is unknown

getContentTypeValue

public java.lang.String getContentTypeValue()
Returns the content type value, if known.

Returns:
the content type value, or null if the content type is unknown

getContentLength

public long getContentLength()
Returns the length of the content, if known.

Returns:
the number of bytes of the content, or a negative number if unknown. If the content length is known but exceeds Long.MAX_VALUE, a negative number is returned.

getAllHeaders

public java.lang.String[] getAllHeaders()
Returns all headers.

Returns:
headers array

getAllHeadersAsMap

public java.util.Map<java.lang.String,java.lang.String> getAllHeadersAsMap()
Returns a map of all headers. If there is no headers, an empty map instance is returned.

Returns:
headers map

getHeaderValuesForName

public java.util.Set<java.lang.String> getHeaderValuesForName(java.lang.String name)
Returns a set of values in the header associated with the name.

Parameters:
name - name of a head property
Returns:
a set of values

getAllowedMethods

public java.util.Set<java.lang.String> getAllowedMethods()
Returns a set of allowed methods.

Returns:
a set of allowed methods.

getContentAsString

public java.lang.String getContentAsString()
                                    throws java.io.IOException
Returns content as string by using the platform's default charset. Please notice that you can only call one of the getContentAsXXX() once.

Returns:
a string of content
Throws:
java.io.IOException

getContentAsString

public java.lang.String getContentAsString(java.lang.String charsetName)
                                    throws java.io.IOException
Returns content as string by using the specified charset. Please notice that you can only call one of the getContentAsXXX() once.

Parameters:
charsetName - the name of a supported charset
Returns:
a string of content
Throws:
java.io.IOException

getContentAsBytes

public byte[] getContentAsBytes()
                         throws java.io.IOException
Returns content as bytes. Please notice that you can only call one of the getContentAsXXX() once.

Returns:
a byte array of content
Throws:
java.io.IOException

getContentAsInputStream

public java.io.InputStream getContentAsInputStream()
                                            throws java.io.IOException
Returns content as input stream. Please notice that you can only call one of the getContentAsXXX() once.

Returns:
a stream of content
Throws:
java.io.IOException