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 TypeMethodDescriptionvoidvoidaddHeader(org.apache.http.Header arg0) booleancontainsHeader(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.HttpEntityorg.apache.http.HeadergetFirstHeader(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.HeadergetLastHeader(String arg0) org.apache.http.params.HttpParamsorg.apache.http.ProtocolVersionintGet the response status code.org.apache.http.StatusLineorg.apache.http.HeaderIteratororg.apache.http.HeaderIteratorheaderIterator(String arg0) booleanQuickly determine if the request resulted in an error code.voidremoveHeader(org.apache.http.Header arg0) voidremoveHeaders(String arg0) (package private) voidvoidsetEntity(org.apache.http.HttpEntity arg0) voidvoidsetHeader(org.apache.http.Header arg0) voidsetHeaders(org.apache.http.Header[] arg0) voidvoidsetParams(org.apache.http.params.HttpParams arg0) voidsetReasonPhrase(String arg0) voidsetStatusCode(int arg0) voidsetStatusLine(org.apache.http.ProtocolVersion arg0, int arg1) voidsetStatusLine(org.apache.http.ProtocolVersion arg0, int arg1, String arg2) voidsetStatusLine(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
nullif 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:
getEntityin interfaceorg.apache.http.HttpResponse
-
getLocale
- Specified by:
getLocalein interfaceorg.apache.http.HttpResponse
-
getStatusLine
public org.apache.http.StatusLine getStatusLine()- Specified by:
getStatusLinein interfaceorg.apache.http.HttpResponse
-
setEntity
public void setEntity(org.apache.http.HttpEntity arg0) - Specified by:
setEntityin interfaceorg.apache.http.HttpResponse
-
setLocale
- Specified by:
setLocalein interfaceorg.apache.http.HttpResponse
-
setReasonPhrase
- Specified by:
setReasonPhrasein interfaceorg.apache.http.HttpResponse- Throws:
IllegalStateException
-
setStatusCode
- Specified by:
setStatusCodein interfaceorg.apache.http.HttpResponse- Throws:
IllegalStateException
-
setStatusLine
public void setStatusLine(org.apache.http.StatusLine arg0) - Specified by:
setStatusLinein interfaceorg.apache.http.HttpResponse
-
setStatusLine
public void setStatusLine(org.apache.http.ProtocolVersion arg0, int arg1) - Specified by:
setStatusLinein interfaceorg.apache.http.HttpResponse
-
setStatusLine
- Specified by:
setStatusLinein interfaceorg.apache.http.HttpResponse
-
addHeader
public void addHeader(org.apache.http.Header arg0) - Specified by:
addHeaderin interfaceorg.apache.http.HttpMessage
-
addHeader
-
containsHeader
- Specified by:
containsHeaderin interfaceorg.apache.http.HttpMessage
-
getAllHeaders
public org.apache.http.Header[] getAllHeaders()- Specified by:
getAllHeadersin interfaceorg.apache.http.HttpMessage
-
getFirstHeader
- Specified by:
getFirstHeaderin interfaceorg.apache.http.HttpMessage
-
getHeaders
- Specified by:
getHeadersin interfaceorg.apache.http.HttpMessage
-
getLastHeader
- Specified by:
getLastHeaderin interfaceorg.apache.http.HttpMessage
-
getParams
public org.apache.http.params.HttpParams getParams()- Specified by:
getParamsin interfaceorg.apache.http.HttpMessage
-
getProtocolVersion
public org.apache.http.ProtocolVersion getProtocolVersion()- Specified by:
getProtocolVersionin interfaceorg.apache.http.HttpMessage
-
headerIterator
public org.apache.http.HeaderIterator headerIterator()- Specified by:
headerIteratorin interfaceorg.apache.http.HttpMessage
-
headerIterator
- Specified by:
headerIteratorin interfaceorg.apache.http.HttpMessage
-
removeHeader
public void removeHeader(org.apache.http.Header arg0) - Specified by:
removeHeaderin interfaceorg.apache.http.HttpMessage
-
removeHeaders
- Specified by:
removeHeadersin interfaceorg.apache.http.HttpMessage
-
setHeader
public void setHeader(org.apache.http.Header arg0) - Specified by:
setHeaderin interfaceorg.apache.http.HttpMessage
-
setHeader
-
setHeaders
public void setHeaders(org.apache.http.Header[] arg0) - Specified by:
setHeadersin interfaceorg.apache.http.HttpMessage
-
setParams
public void setParams(org.apache.http.params.HttpParams arg0) - Specified by:
setParamsin interfaceorg.apache.http.HttpMessage
-