org.modeshape.web.jcr.rest.client.http

## Class HttpClientConnection

- java.lang.Object
- - org.modeshape.web.jcr.rest.client.http.HttpClientConnection

-     public final class HttpClientConnection
      extends Object

  `HttpClientConnection` uses the `Apache HttpClient`.

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `HttpClientConnection(Server server, URL url, IJsonConstants.RequestMethod method)`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `disconnect()` Disconnects this connection.
    `int` | `getResponseCode()`
    `String` | `read()`
    `void` | `setContentType(String contentType)` Sets the content type for the request
    `void` | `write(byte[] bytes)`

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

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

- - ### Constructor Detail

    - #### HttpClientConnection

          public HttpClientConnection(Server server,
                              URL url,
                              IJsonConstants.RequestMethod method)
                               throws Exception

      Parameters:
        `server` - the server with the host and port information (never `null`)
        `url` - the URL that will be used in the request (never `null`)
        `method` - the HTTP request method (never `null`)
      Throws:
        `Exception` - if there is a problem establishing the connection

  - ### Method Detail

    - #### disconnect

          public void disconnect()

      Disconnects this connection.

    - #### getResponseCode

          public int getResponseCode()
                              throws Exception

      Returns:
        the HTTP response code
      Throws:
        `Exception` - if there is a problem getting the response code

    - #### read

          public String read()
                      throws Exception

      Returns:
        the HTTP response body as a string
      Throws:
        `Exception` - if there is a problem reading from the connection

    - #### write

          public void write(byte[] bytes)
                     throws Exception

      Parameters:
        `bytes` - the bytes being posted to the HTTP connection (never `null`)
      Throws:
        `Exception` - if there is a problem writing to the connection

    - #### setContentType

          public void setContentType(String contentType)

      Sets the content type for the request
      Parameters:
        `contentType` - the content type to use

Copyright © 2008-2014 JBoss, a division of Red Hat. All Rights Reserved.