com.github.restdriver.serverdriver.http.response
Class DefaultResponse

java.lang.Object
  extended by com.github.restdriver.serverdriver.http.response.DefaultResponse
All Implemented Interfaces:
Response

public final class DefaultResponse
extends Object
implements Response

Our class which describes an HTTP response.


Constructor Summary
DefaultResponse(org.apache.http.HttpResponse response, long responseTime)
          Constructor from apache HttpResponse.
 
Method Summary
 org.codehaus.jackson.JsonNode asJson()
          Returns the JSON response content as a JsonNode, or throws RuntimeMappingException
 Element asXml()
          Returns the XML response content as an org.w3c.Element, or throws RuntimeMappingException
 String getContent()
          What was the content of the response?
 List<Header> getHeaders()
          What headers did the server send?
 long getResponseTime()
          How long did the response take?
 int getStatusCode()
          What was the response code?
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DefaultResponse

public DefaultResponse(org.apache.http.HttpResponse response,
                       long responseTime)
Constructor from apache HttpResponse.

Parameters:
response - the HttpResponse
responseTime - time taken for the request in milliseconds
Method Detail

getStatusCode

public int getStatusCode()
Description copied from interface: Response
What was the response code?

Specified by:
getStatusCode in interface Response
Returns:
the HTTP status code of the response

getContent

public String getContent()
Description copied from interface: Response
What was the content of the response?

Specified by:
getContent in interface Response
Returns:
The response body content as a string

getHeaders

public List<Header> getHeaders()
Description copied from interface: Response
What headers did the server send?

Specified by:
getHeaders in interface Response
Returns:
A list of headers

getResponseTime

public long getResponseTime()
Description copied from interface: Response
How long did the response take?

Specified by:
getResponseTime in interface Response
Returns:
Round-trip response time in milliseconds

asJson

public org.codehaus.jackson.JsonNode asJson()
Description copied from interface: Response
Returns the JSON response content as a JsonNode, or throws RuntimeMappingException

Specified by:
asJson in interface Response
Returns:
The JsonNode

asXml

public Element asXml()
Description copied from interface: Response
Returns the XML response content as an org.w3c.Element, or throws RuntimeMappingException

Specified by:
asXml in interface Response
Returns:
The Element

toString

public String toString()
Overrides:
toString in class Object


Copyright © 2011. All Rights Reserved.