Interface WebResponse

All Known Implementing Classes:
AbstractWebResponse, BlockingWebResponse, NettyWebResponse, NonBlockingWebResponse

public interface WebResponse
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    end()
    Completes the asynchronous operation that was started on the request.
    Returns the value of the specified response header as a String.
    Returns the internal object of this WebResponse.
    Returns the value to which the specified "name" is mapped, or null if this WebResponse contains no mapping for the "name".
    int
    Gets the current status code of this response.
    void
    send(byte[] bytes)
    Writes b.length bytes of body from the specified byte array to the output stream.
    void
    setHeader(String name, String value)
    Sets a response header with the given name and value.
    void
    setProperty(String name, Object value)
    Associates the specified value with the specified "name" in this WebResponse.
    void
    setStatus(int code)
    Sets the status code for this response.
  • Method Details

    • setStatus

      void setStatus(int code)
      Sets the status code for this response. This method is used to set the return status code when there is no error (for example, for the 200 or 404 status codes). This method preserves any cookies and other response headers. Valid status codes are those in the 2XX, 3XX, 4XX, and 5XX ranges. Other status codes are treated as container specific.
      Parameters:
      code - the status code
    • getStatus

      int getStatus()
      Gets the current status code of this response.
      Returns:
      the status code
    • setHeader

      void setHeader(String name, String value)
      Sets a response header with the given name and value. If the header had already been set, the new value overwrites the previous one.
      Parameters:
      name - the name of the header
      value - the header value If it contains octet string, it should be encoded according to RFC 2047
    • getHeader

      String getHeader(String name)
      Returns the value of the specified response header as a String. If the response did not include a header of the specified name, this method returns null. If there are multiple headers with the same name, this method returns the first head in the response.
      Parameters:
      name - name a String specifying the header name
      Returns:
      a String containing the value of the response header, or null if the response does not have a header of that name
    • send

      void send(byte[] bytes) throws IOException
      Writes b.length bytes of body from the specified byte array to the output stream.
      Parameters:
      bytes - the data
      Throws:
      IOException - if an I/O error occurs
    • end

      boolean end()
      Completes the asynchronous operation that was started on the request.
      Returns:
      first call of this method returns with true
    • setProperty

      void setProperty(String name, Object value)
      Associates the specified value with the specified "name" in this WebResponse. If the WebResponse previously contained a mapping for the "name", the old value is replaced.
      Parameters:
      name - a "name" with which the specified value is to be associated
      value - value to be associated with the specified "name"
    • getProperty

      Object getProperty(String name)
      Returns the value to which the specified "name" is mapped, or null if this WebResponse contains no mapping for the "name".
      Parameters:
      name - the "name" whose associated value is to be returned
      Returns:
      the value to which the specified "name" is mapped, or null if this WebResponse contains no mapping for the "name"
    • getInternalObject

      Object getInternalObject()
      Returns the internal object of this WebResponse.
      Returns:
      internal object (HttpServletResponse or Netty Context)