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 anInputStream
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 aDefaultHTTPClient
instance already initializedString
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 anInputStream
from a given IRI.
-
-
-
Method Detail
-
createInitializedHTTPClient
public static DefaultHTTPClient createInitializedHTTPClient()
Creates aDefaultHTTPClient
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 interfaceHTTPClient
- Parameters:
configuration
- configuration for the HTTP Client.
-
openInputStream
public InputStream openInputStream(String uri) throws IOException
Opens anInputStream
from a given IRI. It follows redirects.- Specified by:
openInputStream
in interfaceHTTPClient
- Parameters:
uri
- to be opened- Returns:
InputStream
- Throws:
IOException
- if there is an error opening theInputStream
located at the URI.
-
close
public void close()
Shuts down the connection manager.- Specified by:
close
in interfaceHTTPClient
-
getContentLength
public long getContentLength()
- Specified by:
getContentLength
in interfaceHTTPClient
- 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 ofnull
means that the IRI is unchanged and the original IRI was used.- Specified by:
getActualDocumentIRI
in interfaceHTTPClient
- 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 benull
.- Specified by:
getContentType
in interfaceHTTPClient
- Returns:
- the content type as string.
-
getConnectionTimeout
protected int getConnectionTimeout()
-
getSoTimeout
protected int getSoTimeout()
-
-