org.cybergarage.http

## Class HTTPSocket

- java.lang.Object
- - org.cybergarage.http.HTTPSocket

-     public class HTTPSocket
      extends Object

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `HTTPSocket(HTTPSocket socket)` Creates an HTTP socket wrapper around another HTTP socket.
    `HTTPSocket(Socket socket)` Creates an HTTP socket wrapper around a standard socket.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `close()` Closes the socket and all associated streams.
    `InputStream` | `getInputStream()`
    `String` | `getLocalAddress()` Gets the local address of this socket.
    `int` | `getLocalPort()` Gets the local port of this socket.
    `Socket` | `getSocket()`
    `boolean` | `open()` Opens the socket streams for input/output operations.
    `boolean` | `post(HTTPResponse httpRes, long contentOffset, long contentLength, boolean isOnlyHeader)` Posts an HTTP response with the specified content parameters.

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

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

- - ### Constructor Detail

    - #### HTTPSocket

          public HTTPSocket(HTTPSocket socket)

      Creates an HTTP socket wrapper around another HTTP socket.
      Parameters:
        `socket` - HTTP socket to wrap

    - #### HTTPSocket

          public HTTPSocket(Socket socket)

      Creates an HTTP socket wrapper around a standard socket.
      Parameters:
        `socket` - underlying socket to wrap

  - ### Method Detail

    - #### close

          public boolean close()

      Closes the socket and all associated streams.
      Returns:
        true if closed successfully

    - #### getInputStream

          public InputStream getInputStream()

    - #### getLocalAddress

          public String getLocalAddress()

      Gets the local address of this socket.
      Returns:
        local host address

    - #### getLocalPort

          public int getLocalPort()

      Gets the local port of this socket.
      Returns:
        local port number

    - #### getSocket

          public Socket getSocket()

    - #### open

          public boolean open()

      Opens the socket streams for input/output operations.
      Returns:
        true if streams were opened successfully, false otherwise

    - #### post

          public boolean post(HTTPResponse httpRes,
                              long contentOffset,
                              long contentLength,
                              boolean isOnlyHeader)

      Posts an HTTP response with the specified content parameters.
      Parameters:
        `httpRes` - the HTTP response to post
        `contentOffset` - the offset in the content to start from
        `contentLength` - the length of content to send
        `isOnlyHeader` - true if only headers should be sent
      Returns:
        true if posted successfully