public class HttpConnectionManager extends java.lang.Object implements ResumableConnectionManager
Modifier and Type | Class and Description |
---|---|
(package private) static class |
HttpConnectionManager.TimeoutTimer |
Modifier and Type | Field and Description |
---|---|
private UriMetadata |
metadata |
private ConnectionParameters |
parameters |
private Filter<org.apache.http.HttpResponse> |
responseFilter |
private int |
timeout |
private java.net.URI |
uri |
Constructor and Description |
---|
HttpConnectionManager(java.net.URI uri,
ConnectionParameters parameters) |
Modifier and Type | Method and Description |
---|---|
org.apache.http.impl.client.CloseableHttpClient |
createCloseableHttpClient(java.net.URI uri,
ConnectionParameters parameters)
Get a HttpClient object that has been configured to access the
given URI.
|
UriMetadata |
createMetadata(java.net.URI uri,
org.apache.http.HttpResponse response)
Read metadata from the given http response and put the information
in a UriMetadata object.
|
java.io.InputStream |
getInputStream()
Get an InputStream for reading the contents of the resource.
|
java.io.InputStream |
getInputStream(long offset)
Get an InputStream for reading the contents of the resource.
|
UriMetadata |
getMetadata()
Get metadata about the resource.
|
java.net.URI |
getURI()
Get the URI of the resource we are interested in.
|
void |
setResponseFilter(Filter<org.apache.http.HttpResponse> filter)
Set a filter that will inspect the response before an input stream
is returned to the calling code.
|
void |
setTimeout(int timeoutInSeconds)
Set a timeout in seconds to allocate for the request to return
(not including downloading of data).
|
private final java.net.URI uri
private final ConnectionParameters parameters
private UriMetadata metadata
private Filter<org.apache.http.HttpResponse> responseFilter
private int timeout
public HttpConnectionManager(java.net.URI uri, ConnectionParameters parameters)
public java.net.URI getURI()
ConnectionManager
getURI
in interface ConnectionManager
public java.io.InputStream getInputStream() throws java.io.IOException
ConnectionManager
getInputStream
in interface ConnectionManager
java.io.IOException
- If there is an error creating the streampublic java.io.InputStream getInputStream(long offset) throws java.io.IOException
ResumableConnectionManager
getInputStream
in interface ResumableConnectionManager
offset
- The offset to start reading fromjava.io.IOException
- If there is an error creating the streampublic UriMetadata getMetadata() throws java.io.IOException
ConnectionManager
getMetadata
in interface ConnectionManager
java.io.IOException
- If there is an error getting the metadatapublic void setResponseFilter(Filter<org.apache.http.HttpResponse> filter)
public void setTimeout(int timeoutInSeconds)
timeoutInSeconds
- Timeout in secondspublic org.apache.http.impl.client.CloseableHttpClient createCloseableHttpClient(java.net.URI uri, ConnectionParameters parameters) throws java.io.IOException
java.io.IOException
public UriMetadata createMetadata(java.net.URI uri, org.apache.http.HttpResponse response)