Class HttpResponse


public class HttpResponse extends HttpBase<HttpResponse>
HTTP response.
  • Field Details

    • statusCode

      protected int statusCode
    • statusPhrase

      protected String statusPhrase
    • httpRequest

      protected HttpRequest httpRequest
  • Constructor Details

    • HttpResponse

      public HttpResponse()
  • Method Details

    • statusCode

      public int statusCode()
      Returns response status code.
    • statusCode

      public HttpResponse statusCode(int statusCode)
      Sets response status code.
    • statusPhrase

      public String statusPhrase()
      Returns response status phrase.
    • statusPhrase

      public HttpResponse statusPhrase(String statusPhrase)
      Sets response status phrase.
    • location

      public String location()
      Parses the 'location' header and returns an absolute URL for the provided path. Returns null if no location was specified or throws HttpException if it was impossible to assemble a valid URL.

      RFC 2616 still required an absolute URL, whereas RFC 9110 introduced the support for relative paths.

    • cookies

      public Cookie[] cookies()
      Returns list of valid cookies sent from server. If no cookie found, returns an empty array. Invalid cookies are ignored.
      Overrides:
      cookies in class HttpBase<HttpResponse>
    • unzip

      public HttpResponse unzip()
      Unzips GZip-ed body content, removes the content-encoding header and sets the new content-length value.
    • buffer

      protected Buffer buffer(boolean fullResponse)
      Creates response buffer.
      Specified by:
      buffer in class HttpBase<HttpResponse>
    • readFrom

      public static HttpResponse readFrom(InputStream in)
      Reads response input stream and returns response. Supports both streamed and chunked response.
    • assignHttpRequest

      void assignHttpRequest(HttpRequest httpRequest)
      Binds HttpRequest to this response.
    • getHttpRequest

      public HttpRequest getHttpRequest()
      Returns HttpRequest that created this response.
    • close

      public HttpResponse close()
      Closes requests connection if it was open. Should be called when using keep-alive connections. Otherwise, connection will be already closed.