Class HttpResponseDecorator

java.lang.Object
groovyx.net.http.HttpResponseDecorator
All Implemented Interfaces:
org.apache.http.HttpMessage, org.apache.http.HttpResponse

public class HttpResponseDecorator extends Object implements 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:
  • Field Details

  • Constructor Details

    • HttpResponseDecorator

      public HttpResponseDecorator(org.apache.http.HttpResponse base, Object parsedResponse)
    • HttpResponseDecorator

      public HttpResponseDecorator(org.apache.http.HttpResponse base, HttpContextDecorator context, Object parsedResponse)
  • Method Details

    • 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:
    • 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.
    • setData

      void setData(Object responseData)
    • getContext

      public HttpContextDecorator getContext()
      Get the execution context used during this request
      Returns:
      the HttpContext
      See Also:
      • ExecutionContext
    • getEntity

      public org.apache.http.HttpEntity getEntity()
      Specified by:
      getEntity in interface org.apache.http.HttpResponse
    • getLocale

      public Locale getLocale()
      Specified by:
      getLocale in interface org.apache.http.HttpResponse
    • getStatusLine

      public org.apache.http.StatusLine getStatusLine()
      Specified by:
      getStatusLine in interface org.apache.http.HttpResponse
    • setEntity

      public void setEntity(org.apache.http.HttpEntity arg0)
      Specified by:
      setEntity in interface org.apache.http.HttpResponse
    • setLocale

      public void setLocale(Locale arg0)
      Specified by:
      setLocale in interface org.apache.http.HttpResponse
    • setReasonPhrase

      public void setReasonPhrase(String arg0) throws IllegalStateException
      Specified by:
      setReasonPhrase in interface org.apache.http.HttpResponse
      Throws:
      IllegalStateException
    • setStatusCode

      public void setStatusCode(int arg0) throws IllegalStateException
      Specified by:
      setStatusCode in interface org.apache.http.HttpResponse
      Throws:
      IllegalStateException
    • setStatusLine

      public void setStatusLine(org.apache.http.StatusLine arg0)
      Specified by:
      setStatusLine in interface org.apache.http.HttpResponse
    • setStatusLine

      public void setStatusLine(org.apache.http.ProtocolVersion arg0, int arg1)
      Specified by:
      setStatusLine in interface org.apache.http.HttpResponse
    • setStatusLine

      public void setStatusLine(org.apache.http.ProtocolVersion arg0, int arg1, String arg2)
      Specified by:
      setStatusLine in interface org.apache.http.HttpResponse
    • addHeader

      public void addHeader(org.apache.http.Header arg0)
      Specified by:
      addHeader in interface org.apache.http.HttpMessage
    • addHeader

      public void addHeader(String arg0, String arg1)
      Specified by:
      addHeader in interface org.apache.http.HttpMessage
    • containsHeader

      public boolean containsHeader(String arg0)
      Specified by:
      containsHeader in interface org.apache.http.HttpMessage
    • getAllHeaders

      public org.apache.http.Header[] getAllHeaders()
      Specified by:
      getAllHeaders in interface org.apache.http.HttpMessage
    • getFirstHeader

      public org.apache.http.Header getFirstHeader(String arg0)
      Specified by:
      getFirstHeader in interface org.apache.http.HttpMessage
    • getHeaders

      public org.apache.http.Header[] getHeaders(String arg0)
      Specified by:
      getHeaders in interface org.apache.http.HttpMessage
    • getLastHeader

      public org.apache.http.Header getLastHeader(String arg0)
      Specified by:
      getLastHeader in interface org.apache.http.HttpMessage
    • getParams

      public org.apache.http.params.HttpParams getParams()
      Specified by:
      getParams in interface org.apache.http.HttpMessage
    • getProtocolVersion

      public org.apache.http.ProtocolVersion getProtocolVersion()
      Specified by:
      getProtocolVersion in interface org.apache.http.HttpMessage
    • headerIterator

      public org.apache.http.HeaderIterator headerIterator()
      Specified by:
      headerIterator in interface org.apache.http.HttpMessage
    • headerIterator

      public org.apache.http.HeaderIterator headerIterator(String arg0)
      Specified by:
      headerIterator in interface org.apache.http.HttpMessage
    • removeHeader

      public void removeHeader(org.apache.http.Header arg0)
      Specified by:
      removeHeader in interface org.apache.http.HttpMessage
    • removeHeaders

      public void removeHeaders(String arg0)
      Specified by:
      removeHeaders in interface org.apache.http.HttpMessage
    • setHeader

      public void setHeader(org.apache.http.Header arg0)
      Specified by:
      setHeader in interface org.apache.http.HttpMessage
    • setHeader

      public void setHeader(String arg0, String arg1)
      Specified by:
      setHeader in interface org.apache.http.HttpMessage
    • setHeaders

      public void setHeaders(org.apache.http.Header[] arg0)
      Specified by:
      setHeaders in interface org.apache.http.HttpMessage
    • setParams

      public void setParams(org.apache.http.params.HttpParams arg0)
      Specified by:
      setParams in interface org.apache.http.HttpMessage