com.atlassian.sal.core.net
Class HttpClientResponse

java.lang.Object
  extended by com.atlassian.sal.core.net.HttpClientResponse
All Implemented Interfaces:
Response

public class HttpClientResponse
extends Object
implements Response


Constructor Summary
HttpClientResponse(org.apache.commons.httpclient.HttpMethod method)
           
 
Method Summary
<T> T
getEntity(Class<T> entityClass)
          Unmarshall the response body as the specified type
 String getHeader(String name)
          Get's the header by the given name
 Map<String,String> getHeaders()
          Get a map of all the headers
 InputStream getResponseBodyAsStream()
           
 String getResponseBodyAsString()
           
 int getStatusCode()
           
 String getStatusText()
           
 boolean isSuccessful()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpClientResponse

public HttpClientResponse(org.apache.commons.httpclient.HttpMethod method)
Method Detail

getResponseBodyAsString

public String getResponseBodyAsString()
                               throws ResponseException
Specified by:
getResponseBodyAsString in interface Response
Returns:
the response body of the request.
Throws:
ResponseException - If the response cannot be retrieved

getResponseBodyAsStream

public InputStream getResponseBodyAsStream()
                                    throws ResponseException
Specified by:
getResponseBodyAsStream in interface Response
Returns:
the response body of the request.
Throws:
ResponseException - If the response cannot be retrieved

getEntity

public <T> T getEntity(Class<T> entityClass)
            throws ResponseException
Description copied from interface: Response
Unmarshall the response body as the specified type

Specified by:
getEntity in interface Response
Parameters:
entityClass - the type of the response
Returns:
the unmarshalled object
Throws:
ResponseException - if there was difficulty reading the response or unmarshalling the object

getStatusCode

public int getStatusCode()
Specified by:
getStatusCode in interface Response
Returns:
status code of the request.

getStatusText

public String getStatusText()
Specified by:
getStatusText in interface Response
Returns:
status test of the response

isSuccessful

public boolean isSuccessful()
Specified by:
isSuccessful in interface Response
Returns:
true if network returned a status code in the 200 range or 300 range

getHeader

public String getHeader(String name)
Description copied from interface: Response
Get's the header by the given name

Specified by:
getHeader in interface Response
Parameters:
name - The name of the header
Returns:
The value of the header. This will include all values, comma separated, if multiple header fields with the given name were specified, as per RFC2616. When the specified header key is not present, null is returned.

getHeaders

public Map<String,String> getHeaders()
Description copied from interface: Response
Get a map of all the headers

Specified by:
getHeaders in interface Response
Returns:
A map of header names to header values. The header values will include all values, comma seperated, if multiple header fields with the given name were specified, as per RFC2616.


Copyright © 2015 Atlassian. All rights reserved.