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 anInputStreamon 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 voidclose()Shuts down the connection manager.static DefaultHTTPClientcreateInitializedHTTPClient()Creates aDefaultHTTPClientinstance already initializedStringgetActualDocumentIRI()Returns the actual IRI from which the document was fetched.protected intgetConnectionTimeout()longgetContentLength()StringgetContentType()The value of the Content-Type header reported by the server.protected intgetSoTimeout()voidinit(HTTPClientConfiguration configuration)Initializes the HTTP client.InputStreamopenInputStream(String uri)Opens anInputStreamfrom a given IRI.
-
-
-
Method Detail
-
createInitializedHTTPClient
public static DefaultHTTPClient createInitializedHTTPClient()
Creates aDefaultHTTPClientinstance already initialized- Returns:
- populated
DefaultHTTPClient
-
init
public void init(HTTPClientConfiguration configuration)
Description copied from interface:HTTPClientInitializes the HTTP client.- Specified by:
initin interfaceHTTPClient- Parameters:
configuration- configuration for the HTTP Client.
-
openInputStream
public InputStream openInputStream(String uri) throws IOException
Opens anInputStreamfrom a given IRI. It follows redirects.- Specified by:
openInputStreamin interfaceHTTPClient- Parameters:
uri- to be opened- Returns:
InputStream- Throws:
IOException- if there is an error opening theInputStreamlocated at the URI.
-
close
public void close()
Shuts down the connection manager.- Specified by:
closein interfaceHTTPClient
-
getContentLength
public long getContentLength()
- Specified by:
getContentLengthin interfaceHTTPClient- Returns:
- content length in bytes.
-
getActualDocumentIRI
public String getActualDocumentIRI()
Description copied from interface:HTTPClientReturns 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 ofnullmeans that the IRI is unchanged and the original IRI was used.- Specified by:
getActualDocumentIRIin interfaceHTTPClient- Returns:
- actual document IRI.
-
getContentType
public String getContentType()
Description copied from interface:HTTPClientThe value of the Content-Type header reported by the server. Can benull.- Specified by:
getContentTypein interfaceHTTPClient- Returns:
- the content type as string.
-
getConnectionTimeout
protected int getConnectionTimeout()
-
getSoTimeout
protected int getSoTimeout()
-
-