Package org.apache.any23.http

## Class DefaultHTTPClient

- java.lang.Object
- - org.apache.any23.http.DefaultHTTPClient

- All Implemented Interfaces:
    `HTTPClient`

      public class DefaultHTTPClient
      extends Object
      implements HTTPClient

  Opens an `InputStream` on an HTTP IRI. Is configured with sane values for timeouts, default headers and so on.
  Author:
    Paolo Capriotti, Richard Cyganiak (richard@cyganiak.de)

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `DefaultHTTPClient()` |

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `close()` | Shuts down the connection manager.
    `static DefaultHTTPClient` | `createInitializedHTTPClient()` | Creates a `DefaultHTTPClient` instance already initialized
    `String` | `getActualDocumentIRI()` | Returns the actual IRI from which the document was fetched.
    `protected int` | `getConnectionTimeout()` |
    `long` | `getContentLength()` |
    `String` | `getContentType()` | The value of the Content-Type header reported by the server.
    `protected int` | `getSoTimeout()` |
    `void` | `init​(HTTPClientConfiguration configuration)` | Initializes the HTTP client.
    `InputStream` | `openInputStream​(String uri)` | Opens an `InputStream` from a given IRI.

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

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

- - ### Constructor Detail

    - #### DefaultHTTPClient

          public DefaultHTTPClient()

  - ### Method Detail

    - #### createInitializedHTTPClient

          public static DefaultHTTPClient createInitializedHTTPClient()

      Creates a `DefaultHTTPClient` instance already initialized
      Returns:
        populated `DefaultHTTPClient`

    - #### init

          public void init​(HTTPClientConfiguration configuration)

      Description copied from interface: `HTTPClient`
      Initializes the HTTP client.
      Specified by:
        `init` in interface `HTTPClient`
      Parameters:
        `configuration` - configuration for the HTTP Client.

    - #### openInputStream

          public InputStream openInputStream​(String uri)
                                      throws IOException

      Opens an `InputStream` from a given IRI. It follows redirects.
      Specified by:
        `openInputStream` in interface `HTTPClient`
      Parameters:
        `uri` - to be opened
      Returns:
        `InputStream`
      Throws:
        `IOException` - if there is an error opening the `InputStream` located at the URI.

    - #### close

          public void close()

      Shuts down the connection manager.
      Specified by:
        `close` in interface `HTTPClient`

    - #### getContentLength

          public long getContentLength()

      Specified by:
        `getContentLength` in interface `HTTPClient`
      Returns:
        content length in bytes.

    - #### getActualDocumentIRI

          public String getActualDocumentIRI()

      Description copied from interface: `HTTPClient`
      Returns the actual IRI from which the document was fetched. This might differ from the IRI passed to openInputStream() if a redirect was performed. A return value of `null` means that the IRI is unchanged and the original IRI was used.
      Specified by:
        `getActualDocumentIRI` in interface `HTTPClient`
      Returns:
        actual document IRI.

    - #### getContentType

          public String getContentType()

      Description copied from interface: `HTTPClient`
      The value of the Content-Type header reported by the server. Can be `null`.
      Specified by:
        `getContentType` in interface `HTTPClient`
      Returns:
        the content type as string.

    - #### getConnectionTimeout

          protected int getConnectionTimeout()

    - #### getSoTimeout

          protected int getSoTimeout()