Interface Response

All Known Subinterfaces:
All Known Implementing Classes:
HttpContentResponse, HttpResponse

public interface Response

Response represents an HTTP response and offers methods to retrieve status code, HTTP version and headers.

Response objects are passed as parameters to Response.Listener callbacks, or as future result of Request.send().

Response objects do not contain getters for the response content, because it may be too large to fit into memory. The response content should be retrieved via content events, or via utility classes such as BufferingResponseListener.

  • Method Details

    • getRequest

      Request getRequest()
      the request associated with this response
    • getListeners

      <T extends Response.ResponseListener> List<T> getListeners(Class<T> listenerClass)
      Type Parameters:
      T - the type of class
      listenerClass - the listener class
      the response listener passed to Request.send(org.eclipse.jetty.client.api.Response.CompleteListener)
    • getVersion

      HttpVersion getVersion()
      the HTTP version of this response, such as "HTTP/1.1"
    • getStatus

      int getStatus()
      the HTTP status code of this response, such as 200 or 404
    • getReason

      String getReason()
      the HTTP reason associated to the getStatus()
    • getHeaders

      HttpFields getHeaders()

      Returns the headers of this response.

      Some headers sent by the server may not be present, or be present but modified, while the content is being processed. A typical example is the Content-Length header when the content is sent compressed by the server and automatically decompressed by the client: the Content-Length header will be removed.

      Similarly, the Content-Encoding header may be removed or modified, as the content is decoded by the client.

      the headers of this response
    • abort

      boolean abort(Throwable cause)
      Attempts to abort the receive of this response.
      cause - the abort cause, must not be null
      whether the abort succeeded