Package groovyx.net.http
Class HttpResponseDecorator
java.lang.Object
groovyx.net.http.HttpResponseDecorator
- All Implemented Interfaces:
org.apache.http.HttpMessage
,org.apache.http.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
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescription(package private) HttpContextDecorator
(package private) HttpResponseDecorator.HeadersDecorator
(package private) org.apache.http.HttpResponse
(package private) Object
-
Constructor Summary
ConstructorsConstructorDescriptionHttpResponseDecorator
(org.apache.http.HttpResponse base, HttpContextDecorator context, Object parsedResponse) HttpResponseDecorator
(org.apache.http.HttpResponse base, Object parsedResponse) -
Method Summary
Modifier and TypeMethodDescriptionvoid
void
addHeader
(org.apache.http.Header arg0) boolean
containsHeader
(String arg0) org.apache.http.Header[]
Get the content-type for this response.Get the execution context used during this requestgetData()
Return the parsed data from this response body.org.apache.http.HttpEntity
org.apache.http.Header
getFirstHeader
(String arg0) Return aHttpResponseDecorator.HeadersDecorator
, which provides a more Groovy API for accessing response headers.org.apache.http.Header[]
getHeaders
(String arg0) org.apache.http.Header
getLastHeader
(String arg0) org.apache.http.params.HttpParams
org.apache.http.ProtocolVersion
int
Get the response status code.org.apache.http.StatusLine
org.apache.http.HeaderIterator
org.apache.http.HeaderIterator
headerIterator
(String arg0) boolean
Quickly determine if the request resulted in an error code.void
removeHeader
(org.apache.http.Header arg0) void
removeHeaders
(String arg0) (package private) void
void
setEntity
(org.apache.http.HttpEntity arg0) void
void
setHeader
(org.apache.http.Header arg0) void
setHeaders
(org.apache.http.Header[] arg0) void
void
setParams
(org.apache.http.params.HttpParams arg0) void
setReasonPhrase
(String arg0) void
setStatusCode
(int arg0) void
setStatusLine
(org.apache.http.ProtocolVersion arg0, int arg1) void
setStatusLine
(org.apache.http.ProtocolVersion arg0, int arg1, String arg2) void
setStatusLine
(org.apache.http.StatusLine arg0)
-
Field Details
-
headers
-
responseBase
org.apache.http.HttpResponse responseBase -
context
HttpContextDecorator context -
responseData
Object responseData
-
-
Constructor Details
-
HttpResponseDecorator
-
HttpResponseDecorator
public HttpResponseDecorator(org.apache.http.HttpResponse base, HttpContextDecorator context, Object parsedResponse)
-
-
Method Details
-
getHeaders
Return aHttpResponseDecorator.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:
-
getContentType
Get the content-type for this response.- Returns:
- the content-type string, without any charset information.
- See Also:
-
getData
Return the parsed data from this response body.- Returns:
- the parsed response object, or
null
if the response does not contain any data.
-
setData
-
getContext
Get the execution context used during this request- Returns:
- the
HttpContext
- See Also:
-
getEntity
public org.apache.http.HttpEntity getEntity()- Specified by:
getEntity
in interfaceorg.apache.http.HttpResponse
-
getLocale
- Specified by:
getLocale
in interfaceorg.apache.http.HttpResponse
-
getStatusLine
public org.apache.http.StatusLine getStatusLine()- Specified by:
getStatusLine
in interfaceorg.apache.http.HttpResponse
-
setEntity
public void setEntity(org.apache.http.HttpEntity arg0) - Specified by:
setEntity
in interfaceorg.apache.http.HttpResponse
-
setLocale
- Specified by:
setLocale
in interfaceorg.apache.http.HttpResponse
-
setReasonPhrase
- Specified by:
setReasonPhrase
in interfaceorg.apache.http.HttpResponse
- Throws:
IllegalStateException
-
setStatusCode
- Specified by:
setStatusCode
in interfaceorg.apache.http.HttpResponse
- Throws:
IllegalStateException
-
setStatusLine
public void setStatusLine(org.apache.http.StatusLine arg0) - Specified by:
setStatusLine
in interfaceorg.apache.http.HttpResponse
-
setStatusLine
public void setStatusLine(org.apache.http.ProtocolVersion arg0, int arg1) - Specified by:
setStatusLine
in interfaceorg.apache.http.HttpResponse
-
setStatusLine
- Specified by:
setStatusLine
in interfaceorg.apache.http.HttpResponse
-
addHeader
public void addHeader(org.apache.http.Header arg0) - Specified by:
addHeader
in interfaceorg.apache.http.HttpMessage
-
addHeader
- Specified by:
addHeader
in interfaceorg.apache.http.HttpMessage
-
containsHeader
- Specified by:
containsHeader
in interfaceorg.apache.http.HttpMessage
-
getAllHeaders
public org.apache.http.Header[] getAllHeaders()- Specified by:
getAllHeaders
in interfaceorg.apache.http.HttpMessage
-
getFirstHeader
- Specified by:
getFirstHeader
in interfaceorg.apache.http.HttpMessage
-
getHeaders
- Specified by:
getHeaders
in interfaceorg.apache.http.HttpMessage
-
getLastHeader
- Specified by:
getLastHeader
in interfaceorg.apache.http.HttpMessage
-
getParams
public org.apache.http.params.HttpParams getParams()- Specified by:
getParams
in interfaceorg.apache.http.HttpMessage
-
getProtocolVersion
public org.apache.http.ProtocolVersion getProtocolVersion()- Specified by:
getProtocolVersion
in interfaceorg.apache.http.HttpMessage
-
headerIterator
public org.apache.http.HeaderIterator headerIterator()- Specified by:
headerIterator
in interfaceorg.apache.http.HttpMessage
-
headerIterator
- Specified by:
headerIterator
in interfaceorg.apache.http.HttpMessage
-
removeHeader
public void removeHeader(org.apache.http.Header arg0) - Specified by:
removeHeader
in interfaceorg.apache.http.HttpMessage
-
removeHeaders
- Specified by:
removeHeaders
in interfaceorg.apache.http.HttpMessage
-
setHeader
public void setHeader(org.apache.http.Header arg0) - Specified by:
setHeader
in interfaceorg.apache.http.HttpMessage
-
setHeader
- Specified by:
setHeader
in interfaceorg.apache.http.HttpMessage
-
setHeaders
public void setHeaders(org.apache.http.Header[] arg0) - Specified by:
setHeaders
in interfaceorg.apache.http.HttpMessage
-
setParams
public void setParams(org.apache.http.params.HttpParams arg0) - Specified by:
setParams
in interfaceorg.apache.http.HttpMessage
-