com.macromedia.net
Class HttpAgentResponse

java.lang.Object
  extended bycom.macromedia.net.HttpAgentResponse

public class HttpAgentResponse
extends java.lang.Object

This object represents the response from an http request. It contains all the of the data from the response (headers and the body) as well as error information if there was an error.


Constructor Summary
HttpAgentResponse()
           
 
Method Summary
 byte[] getBody()
          Get the body of the response.
 java.lang.String getBodyAsString()
          Get the body of this response, but assume that it is text.
 java.lang.Throwable getException()
          Get the exception associated with this request
 long getExecTime()
          Access how long it took to run this request.
 java.lang.String getHeader(java.lang.String key)
          Get a particular header
 java.util.Hashtable getHeaders()
          Get all the headers as a map
 java.lang.String getKey()
          Access the key.
 HttpAgentRequest getRequest()
          Access the request that made this response.
 int getResponseCode()
          Get the response code (200, 404, etc.)
 java.lang.String getResponseMessage()
          Get the response message ("OK" or "Page not found").
 boolean isOk()
          Did we fail? You can call this method to see if you should treat this response as one to get the exception from, or if you should trust the data from it
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpAgentResponse

public HttpAgentResponse()
Method Detail

getBody

public byte[] getBody()
Get the body of the response.


getBodyAsString

public java.lang.String getBodyAsString()
Get the body of this response, but assume that it is text.


getHeader

public java.lang.String getHeader(java.lang.String key)
Get a particular header

Parameters:
key - is the header key (example: Content-Type)
Returns:
the value of that header

getHeaders

public java.util.Hashtable getHeaders()
Get all the headers as a map

Returns:
a read-only map of key/value strings which are the headers

getResponseMessage

public java.lang.String getResponseMessage()
Get the response message ("OK" or "Page not found"). If there was an exception then the response message is the exception message.

Returns:
the response message or exception message. never null

getResponseCode

public int getResponseCode()
Get the response code (200, 404, etc.)

Returns:
the response code or -1 if there was an exception

getException

public java.lang.Throwable getException()
Get the exception associated with this request


isOk

public boolean isOk()
Did we fail? You can call this method to see if you should treat this response as one to get the exception from, or if you should trust the data from it

Returns:
true if this request was successful

getKey

public java.lang.String getKey()
Access the key. This is the way of mapping a request to a response.


getRequest

public HttpAgentRequest getRequest()
Access the request that made this response.


getExecTime

public long getExecTime()
Access how long it took to run this request. This is useful for debugging.

Returns:
the millis it took to run this request