Package org.bzdev.net

Interface HttpServerResponse

All Known Implementing Classes:
WebMap.Info

public interface HttpServerResponse
Servlet-compatibility interface for HTTP responses.
  • Method Details

    • addCookie

      void addCookie(ServerCookie cookie) throws IllegalStateException
      Add a cookie to the response headers.
      Parameters:
      cookie - the cookie
      Throws:
      IllegalStateException - an implementation-dependent error occurred (for WebMap.Info the constructor was not given an instance of WebMap.RequestInfo)
    • addDateHeader

      default void addDateHeader(String name, long date) throws IllegalStateException
      Add a date header.
      Parameters:
      name - the name of the header
      date - the date provided in milliseconds since 00:00:00 January 1, 1970 GMT.
      Throws:
      IllegalStateException - an implementation-dependent error occurred (for WebMap.Info the constructor was not given an instance of WebMap.RequestInfo)
    • addHeader

      void addHeader(String name, String value) throws IllegalStateException
      Add a header. This method is used when multiple headers with the same name are needed.
      Parameters:
      name - the name of the header
      value - the value of the header
      Throws:
      IllegalStateException - an implementation-dependent error occurred (for WebMap.Info the constructor was not given an instance of WebMap.RequestInfo)
    • addIntHeader

      default void addIntHeader(String name, int value) throws IllegalStateException
      Add an integer header.
      Parameters:
      name - the ename of the header
      value - the value of the header
      Throws:
      IllegalStateException - an implementation-dependent error occurred (for WebMap.Info the constructor was not given an instance of WebMap.RequestInfo)
    • containsHeader

      boolean containsHeader(String name) throws IllegalStateException
      Determine if a response header with the specified name exists.
      Parameters:
      name - the header name
      Returns:
      true if the header exists; false otherwise
      Throws:
      IllegalStateException - an implementation-dependent error occurred (for WebMap.Info the constructor was not given an instance of WebMap.RequestInfo)
    • encodeRedirectURL

      String encodeRedirectURL(String url)
      Encode a URL for use in sendRedirect(String). This method is needed by the Servlet specification where encoding may be necessary to include a session ID.
      Parameters:
      url - the URL
      Returns:
      the encoded URL
    • encodeURL

      String encodeURL(String url)
      Encode a URL so that it includes a session ID if necessary. This method is needed by the Servlet specification where encoding may be necessary to include a session ID.
      Parameters:
      url - the URL
      Returns:
      the encoded URL
    • getHeaderNames

      Collection<String> getHeaderNames() throws IllegalStateException
      Get the names of the current response header names.
      Returns:
      a collection of the response header names
      Throws:
      IllegalStateException - an implementation-dependent error occurred (for WebMap.Info the constructor was not given an instance of WebMap.RequestInfo)
    • getHeaders

      Collection<String> getHeaders(String name) throws IllegalStateException
      Get the headers with a given name.
      Parameters:
      name - the name
      Returns:
      a collection of the header values for a given name
      Throws:
      IllegalStateException - an implementation-dependent error occurred (for WebMap.Info the constructor was not given an instance of WebMap.RequestInfo)
    • sendError

      void sendError(int rc) throws IllegalStateException, IOException
      Sends a response with a given HTML response code for an error with no content. If this method is called, sendResponseHeaders(int,long) should not be called.
      Parameters:
      rc - the response code
      Throws:
      IllegalStateException - an implementation-dependent error occurred (for WebMap.Info the constructor was not given an instance of WebMap.RequestInfo)
      IOException - an IO error occurred
    • sendRedirect

      void sendRedirect(String location) throws IllegalStateException, IOException
      Sends an HTTP redirect response with a given location.
      Parameters:
      location - a URL providing the location
      Throws:
      IllegalStateException - an implementation-dependent error occurred (for WebMap.Info the constructor was not given an instance of WebMap.RequestInfo)
      IOException - an IO error occurred
    • setDateHeader

      default void setDateHeader(String name, long date) throws IllegalStateException
      Add a date header.
      Parameters:
      name - the name of the header
      date - the date provided in milliseconds since 00:00:00 January 1, 1970 GMT.
      Throws:
      IllegalStateException - an implementation-dependent error occurred (for WebMap.Info the constructor was not given an instance of WebMap.RequestInfo)
    • setHeader

      void setHeader(String name, String value) throws IllegalStateException
      Set the specified header.
      Parameters:
      name - the name of the header
      value - the value for the header
      Throws:
      IllegalStateException - an implementation-dependent error occurred (for WebMap.Info the constructor was not given an instance of WebMap.RequestInfo)
    • setIntHeader

      default void setIntHeader(String name, int value) throws IllegalStateException
      Set an integer header.
      Parameters:
      name - the ename of the header
      value - the value of the header
      Throws:
      IllegalStateException - an implementation-dependent error occurred (for WebMap.Info the constructor was not given an instance of WebMap.RequestInfo)
    • setEncoding

      void setEncoding(String encoding)
      Set whether or not a response uses compression or some other transfer encoding.
      Parameters:
      encoding - the encoding ("identity", "gzip", "compress", and "deflate" are standard values); null defaults to "identity"
    • sendResponseHeaders

      void sendResponseHeaders(int code, long length) throws IllegalStateException
      Set the response code and content length. If the length is 0, indicating that the length is not known, chunked transfer encoding is automatically used. As a result, one should generally avoid the explicit use of the transfer-encoding header.

      If this method is called, sendError(int) should not be called.

      When used in a servlet, this method should call the one-argument servlet-response method setStatus, and also call setContentLength or setContentLengthLong. Headers may not be modified after this method is called.

      Parameters:
      code - the response code
      length - the length of the response; 0 if the length is not known, and -1 if there is no response.
      Throws:
      IllegalStateException - an implementation-dependent error occurred (for WebMap.Info the constructor was not given an instance of WebMap.RequestInfo)
    • getOutputStream

      Get the output stream for responses.
      Returns:
      the output stream.
      Throws:
      IllegalStateException - an implementation-dependent error occurred (for WebMap.Info the constructor was not given an instance of WebMap.RequestInfo)
      IOException - an IO error occurred
    • isCommitted

      boolean isCommitted()
      Determine if this response has been committed. A response is committed if its status code and headers have been written.
      Returns:
      true if this response has been committed; false otherwise