Interface HttpResponse


public interface HttpResponse
Representation of an HTTP response message provided by the dispatcher to any HTTP container.
  • Method Details

    • setStatus

      void setStatus(int code)
      Set the status code to the input value.
      Parameters:
      code -
    • setReason

      void setReason(String phrase)
      Set the reason phrase to the input value.
      Parameters:
      phrase -
    • setVersion

      void setVersion(String version)
      Set the HTTP version of this message to the input value. This is expected to be of the form "HTTP/.".
      Parameters:
      version -
    • setContentLength

      void setContentLength(long length)
      Set the content-length header of this message.
      Parameters:
      length -
    • setHeader

      void setHeader(String name, String value)
      Set a header on the message using the provided name and value pair. This will replace any currently existing instances of the header name.
      Parameters:
      name -
      value -
      See Also:
    • addHeader

      void addHeader(String name, String value)
      Append a header on the message using the provided name and value pair. This will be added to any current instance of the header name.
      Parameters:
      name -
      value -
      See Also:
    • addCookie

      void addCookie(HttpCookie cookie)
      Add a cookie object to the message.
      Parameters:
      cookie -
    • removeCookie

      void removeCookie(HttpCookie cookie)
      Remove a cookie object from the message.
      Parameters:
      cookie -
    • removeHeader

      void removeHeader(String name)
      Remove the target header from the message.
      Parameters:
      name -
    • removeAllHeaders

      void removeAllHeaders()
      Remove all headers and cookies from the message.
    • isCommitted

      boolean isCommitted()
      Check whether the response headers have been committed and sent out on the network or not.
      Returns:
      boolean
    • isPersistent

      boolean isPersistent()
      Check whether the connection is persistent or not.
      Returns:
      boolean
    • reset

      void reset()
      Resets the status code, version, and headers.
    • getStatus

      int getStatus()
      Query the current status code of this message.
      Returns:
      int
    • getReason

      String getReason()
      Query the current reason phrase of this message.
      Returns:
      String
    • getVersion

      String getVersion()
      Query the current HTTP version of this message. It will be in the form of "HTTP/.".
      Returns:
      String
    • getContentLength

      long getContentLength()
      Query the current content-length header of the message. This will be -1L if the header is not set.
      Returns:
      long
    • getHeader

      String getHeader(String name)
      Access the value associated with the first instance of the target header name. This will return null if no instance was found.
      Parameters:
      name -
      Returns:
      String
    • getHeaders

      List<String> getHeaders(String name)
      Access a list of all header values for a given header name. This list is never null, but might be empty.
      Parameters:
      name -
      Returns:
      List
    • getHeaders

      List<String> getHeaders()
      Access a list of all header values in this message. This list is never null, but might be empty.
      Returns:
      List
    • getHeaderNames

      List<String> getHeaderNames()
      Access a list of all header names found in this message. This list is never null, but might be empty.
      Returns:
      List
    • getCookie

      HttpCookie getCookie(String name)
      Access the first instance of a cookie with the provided name. This might be null if no match is found.
      Parameters:
      name -
      Returns:
      HttpCookie
    • getCookies

      List<HttpCookie> getCookies(String name)
      Access a list of all cookie instances matching the provided name. This list is never null, but might be empty.
      Parameters:
      name -
      Returns:
      List
    • getCookies

      List<HttpCookie> getCookies()
      Access a list of all cookies found in this message. The list is never null, but might be empty.
      Returns:
      List
    • getBody

      HttpOutputStream getBody()
      Access the output stream representation of the body for this message.
      Returns:
      HttpOutputStream
    • setTrailer

      void setTrailer(String name, String value)
      Sets a trailer header to follow the body of this message
      Parameters:
      name -
      value -
    • writeTrailers

      void writeTrailers()
      Write trailer when all have been set.
      Parameters:
      name -
      value -