Class HTTPResponse

  • All Implemented Interfaces:
    java.lang.Cloneable

    public class HTTPResponse
    extends Inventor
    implements java.lang.Cloneable
    This class encapsulates an HTTP response message. Used in the ServiceListener onHTTPRequest() method.

    • Constructor Detail

      • HTTPResponse

        public HTTPResponse​(HTTPResponse.HTTPStatus statusCode,
                            java.lang.String reason,
                            java.lang.String body,
                            int versionMajor,
                            int versionMinor,
                            HTTPHeaders headers)
        Creates a HTTP response with the given status, reason phrase, message body data, version and headers.
      • HTTPResponse

        public HTTPResponse()
        Creates a HTTP/1.1 response with "200 OK" status.
      • HTTPResponse

        public HTTPResponse​(HTTPResponse.HTTPStatus statusCode,
                            java.lang.String reason,
                            java.lang.String body)
        Creates a HTTP/1.1 response with the given status, reason phrase and message body data.
      • HTTPResponse

        public HTTPResponse​(HTTPResponse obj)
        Copy constructor.
      • HTTPResponse

        public HTTPResponse​(HTTPResponse.HTTPStatus statusCode,
                            java.lang.String reason)
        Creates a HTTP/1.1 response with the given status and reason phrase.
      • HTTPResponse

        public HTTPResponse​(HTTPResponse.HTTPStatus statusCode)
        Creates a HTTP/1.1 response with the given status and a standard reason phrase.
    • Method Detail

      • clone

        public java.lang.Object clone()
      • getHeaders

        public HTTPHeaders getHeaders()
        Returns HTTP headers.
      • getVersionMinor

        public int getVersionMinor()
        HTTP uses a "major.minor" numbering scheme to indicate versions of the protocol. Returns the version minor.
      • getContentLength

        public long getContentLength()
        Returns the size of the body, in bytes (Content-Length entity header)
      • getVersionMajor

        public int getVersionMajor()
        HTTP uses a "major.minor" numbering scheme to indicate versions of the protocol. Returns the version major.
      • getVersion

        public java.lang.String getVersion()
        Returns the HTTP version for incoming request (example "HTTP/1.1").
      • getReasonPhrase

        public static java.lang.String getReasonPhrase​(HTTPResponse.HTTPStatus status)
        Returns the standard HTTP reason phrase for a HTTP status code.
      • getBody

        public java.lang.String getBody()
        Returns the HTTP message body data (optional). Returns an empty string if the response does not have a body message.
      • getReason

        public java.lang.String getReason()
        Returns the HTTP reason phrase.