Class HTMLContext.Response

  • Enclosing interface:
    HTMLContext

    public static class HTMLContext.Response
    extends Object
    A HTTP-response to be sent to the HTTP-client.
    • Field Detail

      • status

        protected int status
        HTTP status code after processing, e.g. "200 OK", HTTP_OK
      • mimeType

        protected String mimeType
        MIME type of content, e.g. "text/html".
      • data

        protected InputStream data
        Data of the response, may be null.
      • header

        protected Map<String,​String> header
        Headers for the HTTP response. Use addHeader() to add lines.
    • Constructor Detail

      • Response

        public Response​(int status,
                        String origMimeType,
                        InputStream data)
        Creates a new HTTP-response with the designated status, MIME-type and data.
        Parameters:
        status - The HTTP-status of the response to create.
        origMimeType - The MIME-type of the HTTP-response to create. null is interpreted as HTMLContext.Response.MimeType.MIME_PLAINTEXT.
        data - The contents of the HTTP-response to create.
      • Response

        public Response​(int status,
                        String mimeType,
                        String txt)
        Convenience method that creates a HTTP-response by wrapping the designated String by an InputStream.
        Parameters:
        status - The HTTP-status of the response to create.
        mimeType - The MIME-type of the HTTP-response to create.
        txt - The contents of the HTTP-response to create.
    • Method Detail

      • addHeader

        public void addHeader​(String name,
                              String value)
        Adds the designated line to the header of this HTTP-response.
        Parameters:
        name - The name of the header-field to add to this HTTP-response.
        value - The value of the header-field to add to this HTTP-response.
      • getStatus

        public int getStatus()
        Return the HTTP status code of the response.
        Returns:
        The HTTP status code of the response.
      • getMimeType

        public String getMimeType()
        Returns the mime type of the response.
        Returns:
        The mime type of the response.
      • getData

        public InputStream getData()
        Returns the response data.
        Returns:
        The response data.
      • getHeader

        public Map<String,​String> getHeader()
        Returns the additional response headers.
        Returns:
        Additional response headers.