groovyx.net.http
Class HttpResponseDecorator

java.lang.Object
  extended by groovyx.net.http.HttpResponseDecorator
All Implemented Interfaces:
HttpMessage, HttpResponse

public class HttpResponseDecorator
extends Object
implements HttpResponse

This class is a wrapper for HttpResponse, which allows for simplified header access, as well as carrying the auto-parsed response data. (see HTTPBuilder.parseResponse(HttpResponse, Object)).

Since:
0.5.0
Author:
Tom Nichols
See Also:
HttpResponseDecorator.HeadersDecorator

Nested Class Summary
 class HttpResponseDecorator.HeadersDecorator
          This class is returned by getHeaders().
 
Constructor Summary
HttpResponseDecorator(HttpResponse base, HttpContextDecorator context, Object parsedResponse)
           
HttpResponseDecorator(HttpResponse base, Object parsedResponse)
           
 
Method Summary
 void addHeader(Header arg0)
           
 void addHeader(String arg0, String arg1)
           
 boolean containsHeader(String arg0)
           
 Header[] getAllHeaders()
           
 String getContentType()
          Get the content-type for this response.
 HttpContextDecorator getContext()
          Get the execution context used during this request
 Object getData()
          Return the parsed data from this response body.
 HttpEntity getEntity()
           
 Header getFirstHeader(String arg0)
           
 HttpResponseDecorator.HeadersDecorator getHeaders()
          Return a HttpResponseDecorator.HeadersDecorator, which provides a more Groovy API for accessing response headers.
 Header[] getHeaders(String arg0)
           
 Header getLastHeader(String arg0)
           
 Locale getLocale()
           
 HttpParams getParams()
           
 ProtocolVersion getProtocolVersion()
           
 int getStatus()
          Get the response status code.
 StatusLine getStatusLine()
           
 HeaderIterator headerIterator()
           
 HeaderIterator headerIterator(String arg0)
           
 boolean isSuccess()
          Quickly determine if the request resulted in an error code.
 void removeHeader(Header arg0)
           
 void removeHeaders(String arg0)
           
 void setEntity(HttpEntity arg0)
           
 void setHeader(Header arg0)
           
 void setHeader(String arg0, String arg1)
           
 void setHeaders(Header[] arg0)
           
 void setLocale(Locale arg0)
           
 void setParams(HttpParams arg0)
           
 void setReasonPhrase(String arg0)
           
 void setStatusCode(int arg0)
           
 void setStatusLine(ProtocolVersion arg0, int arg1)
           
 void setStatusLine(ProtocolVersion arg0, int arg1, String arg2)
           
 void setStatusLine(StatusLine arg0)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HttpResponseDecorator

public HttpResponseDecorator(HttpResponse base,
                             Object parsedResponse)

HttpResponseDecorator

public HttpResponseDecorator(HttpResponse base,
                             HttpContextDecorator context,
                             Object parsedResponse)
Method Detail

getHeaders

public HttpResponseDecorator.HeadersDecorator getHeaders()
Return a HttpResponseDecorator.HeadersDecorator, which provides a more Groovy API for accessing response headers.

Returns:
the headers for this response

isSuccess

public boolean isSuccess()
Quickly determine if the request resulted in an error code.

Returns:
true if the response code is within the range of Status.SUCCESS

getStatus

public int getStatus()
Get the response status code.

Returns:
the HTTP response code.
See Also:
StatusLine.getStatusCode()

getContentType

public String getContentType()
Get the content-type for this response.

Returns:
the content-type string, without any charset information.
See Also:
ParserRegistry.getContentType(HttpResponse)

getData

public Object getData()
Return the parsed data from this response body.

Returns:
the parsed response object, or null if the response does not contain any data.

getContext

public HttpContextDecorator getContext()
Get the execution context used during this request

Returns:
the HttpContext
See Also:
ExecutionContext

getEntity

public HttpEntity getEntity()
Specified by:
getEntity in interface HttpResponse

getLocale

public Locale getLocale()
Specified by:
getLocale in interface HttpResponse

getStatusLine

public StatusLine getStatusLine()
Specified by:
getStatusLine in interface HttpResponse

setEntity

public void setEntity(HttpEntity arg0)
Specified by:
setEntity in interface HttpResponse

setLocale

public void setLocale(Locale arg0)
Specified by:
setLocale in interface HttpResponse

setReasonPhrase

public void setReasonPhrase(String arg0)
                     throws IllegalStateException
Specified by:
setReasonPhrase in interface HttpResponse
Throws:
IllegalStateException

setStatusCode

public void setStatusCode(int arg0)
                   throws IllegalStateException
Specified by:
setStatusCode in interface HttpResponse
Throws:
IllegalStateException

setStatusLine

public void setStatusLine(StatusLine arg0)
Specified by:
setStatusLine in interface HttpResponse

setStatusLine

public void setStatusLine(ProtocolVersion arg0,
                          int arg1)
Specified by:
setStatusLine in interface HttpResponse

setStatusLine

public void setStatusLine(ProtocolVersion arg0,
                          int arg1,
                          String arg2)
Specified by:
setStatusLine in interface HttpResponse

addHeader

public void addHeader(Header arg0)
Specified by:
addHeader in interface HttpMessage

addHeader

public void addHeader(String arg0,
                      String arg1)
Specified by:
addHeader in interface HttpMessage

containsHeader

public boolean containsHeader(String arg0)
Specified by:
containsHeader in interface HttpMessage

getAllHeaders

public Header[] getAllHeaders()
Specified by:
getAllHeaders in interface HttpMessage

getFirstHeader

public Header getFirstHeader(String arg0)
Specified by:
getFirstHeader in interface HttpMessage

getHeaders

public Header[] getHeaders(String arg0)
Specified by:
getHeaders in interface HttpMessage

getLastHeader

public Header getLastHeader(String arg0)
Specified by:
getLastHeader in interface HttpMessage

getParams

public HttpParams getParams()
Specified by:
getParams in interface HttpMessage

getProtocolVersion

public ProtocolVersion getProtocolVersion()
Specified by:
getProtocolVersion in interface HttpMessage

headerIterator

public HeaderIterator headerIterator()
Specified by:
headerIterator in interface HttpMessage

headerIterator

public HeaderIterator headerIterator(String arg0)
Specified by:
headerIterator in interface HttpMessage

removeHeader

public void removeHeader(Header arg0)
Specified by:
removeHeader in interface HttpMessage

removeHeaders

public void removeHeaders(String arg0)
Specified by:
removeHeaders in interface HttpMessage

setHeader

public void setHeader(Header arg0)
Specified by:
setHeader in interface HttpMessage

setHeader

public void setHeader(String arg0,
                      String arg1)
Specified by:
setHeader in interface HttpMessage

setHeaders

public void setHeaders(Header[] arg0)
Specified by:
setHeaders in interface HttpMessage

setParams

public void setParams(HttpParams arg0)
Specified by:
setParams in interface HttpMessage


Copyright © 2008-2011. All Rights Reserved.