org.cybergarage.http

## Class HTTPResponse

- java.lang.Object
- - org.cybergarage.http.HTTPPacket
  - - org.cybergarage.http.HTTPResponse

- Direct Known Subclasses:
    SOAPResponse, SSDPResponse, SubscriptionResponse

      public class HTTPResponse
      extends HTTPPacket

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `HTTPResponse()` Creates a new HTTP response with default settings.
    `HTTPResponse(HTTPResponse httpRes)` Creates a copy of an existing HTTP response.
    `HTTPResponse(HTTPSocket httpSock)` Creates an HTTP response from an HTTP socket.
    `HTTPResponse(InputStream in)` Creates an HTTP response by parsing from an input stream.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `String` | `getHeader()`
    `int` | `getStatusCode()` Gets the HTTP status code of this response.
    `String` | `getStatusLineString()` Gets the status line string of this HTTP response.
    `boolean` | `isSuccessful()` Checks if this response has a successful status code.
    `void` | `print()`
    `void` | `setStatusCode(int code)` Sets the HTTP status code of this response.
    `String` | `toString()`

    - ### Methods inherited from class org.cybergarage.http.HTTPPacket

      `addHeader, addHeader, clearHeaders, getCacheControl, getCharSet, getConnection, getContent, getContentInputStream, getContentLanguage, getContentLength, getContentRange, getContentRangeFirstPosition, getContentRangeInstanceLength, getContentRangeLastPosition, getContentString, getContentType, getDate, getFirstLine, getFirstLineToken, getHeader, getHeader, getHeaderString, getHeaderValue, getHost, getIntegerHeaderValue, getLongHeaderValue, getNHeaders, getServer, getStringHeaderValue, getStringHeaderValue, getTransferEncoding, getVersion, hasConnection, hasContent, hasContentInputStream, hasContentRange, hasFirstLine, hasHeader, hasTransferEncoding, init, isChunked, isCloseConnection, isKeepAliveConnection, read, set, set, set, set, setCacheControl, setCacheControl, setCacheControl, setConnection, setContent, setContent, setContent, setContent, setContentInputStream, setContentLanguage, setContentLength, setContentRange, setContentType, setDate, setHeader, setHeader, setHeader, setHeader, setHost, setIntegerHeader, setLongHeader, setServer, setStringHeader, setStringHeader, setTransferEncoding, setVersion`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

- - ### Constructor Detail

    - #### HTTPResponse

          public HTTPResponse()

      Creates a new HTTP response with default settings. Sets HTTP version to 1.1, content type to HTML, server name, and empty content.

    - #### HTTPResponse

          public HTTPResponse(HTTPResponse httpRes)

      Creates a copy of an existing HTTP response.
      Parameters:
        `httpRes` - HTTP response to copy

    - #### HTTPResponse

          public HTTPResponse(HTTPSocket httpSock)

      Creates an HTTP response from an HTTP socket.
      Parameters:
        `httpSock` - HTTP socket containing the response data

    - #### HTTPResponse

          public HTTPResponse(InputStream in)

      Creates an HTTP response by parsing from an input stream.
      Parameters:
        `in` - input stream containing the HTTP response

  - ### Method Detail

    - #### getHeader

          public String getHeader()

    - #### getStatusCode

          public int getStatusCode()

      Gets the HTTP status code of this response.
      Returns:
        HTTP status code, or parsed status code from first line if not explicitly set

    - #### getStatusLineString

          public String getStatusLineString()

      Gets the status line string of this HTTP response.
      Returns:
        status line in format "HTTP/version code message"

    - #### isSuccessful

          public boolean isSuccessful()

      Checks if this response has a successful status code.
      Returns:
        true if status code is in the 2xx range, false otherwise

    - #### print

          public void print()

    - #### setStatusCode

          public void setStatusCode(int code)

      Sets the HTTP status code of this response.
      Parameters:
        `code` - HTTP status code (e.g., 200, 404, 500)

    - #### toString

          public String toString()

      Overrides:
        `toString` in class `Object`