public static final class HttpClient.Response extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.net.HttpURLConnection |
connection |
private ProgressMonitor |
monitor |
private int |
responseCode |
private java.lang.String |
responseMessage |
private boolean |
uncompress |
private boolean |
uncompressAccordingToContentDisposition |
Modifier | Constructor and Description |
---|---|
private |
Response(java.net.HttpURLConnection connection,
ProgressMonitor monitor) |
Modifier and Type | Method and Description |
---|---|
void |
disconnect() |
java.lang.String |
fetchContent()
Fetches the HTTP response as String.
|
java.io.InputStream |
getContent()
Returns an input stream that reads from this HTTP connection, or,
error stream if the connection failed but the server sent useful data.
|
java.lang.String |
getContentEncoding()
Returns the
Content-Encoding header. |
long |
getContentLength()
Returns the
Content-Length header. |
java.io.BufferedReader |
getContentReader()
Returns
getContent() wrapped in a buffered reader. |
java.lang.String |
getContentType()
Returns the
Content-Type header. |
long |
getExpiration()
Returns the
Expire header. |
java.lang.String |
getHeaderField(java.lang.String name)
Returns the value of the named header field.
|
java.util.Map<java.lang.String,java.util.List<java.lang.String>> |
getHeaderFields()
Returns an unmodifiable Map mapping header keys to a List of header values.
|
long |
getLastModified()
Returns the
Last-Modified header. |
java.lang.String |
getRequestMethod()
Returns the request method.
|
int |
getResponseCode()
Gets the response code from this HTTP connection.
|
java.lang.String |
getResponseMessage()
Gets the response message from this HTTP connection.
|
java.net.URL |
getURL()
Returns the URL.
|
HttpClient.Response |
uncompress(boolean uncompress)
Sets whether
getContent() should uncompress the input stream if necessary. |
HttpClient.Response |
uncompressAccordingToContentDisposition(boolean uncompressAccordingToContentDisposition)
Sets whether
getContent() should uncompress the input stream according to Content-Disposition
HTTP header. |
private final java.net.HttpURLConnection connection
private final ProgressMonitor monitor
private final int responseCode
private final java.lang.String responseMessage
private boolean uncompress
private boolean uncompressAccordingToContentDisposition
private Response(java.net.HttpURLConnection connection, ProgressMonitor monitor) throws java.io.IOException
java.io.IOException
public HttpClient.Response uncompress(boolean uncompress)
getContent()
should uncompress the input stream if necessary.uncompress
- whether the input stream should be uncompressed if necessarythis
public HttpClient.Response uncompressAccordingToContentDisposition(boolean uncompressAccordingToContentDisposition)
getContent()
should uncompress the input stream according to Content-Disposition
HTTP header.uncompressAccordingToContentDisposition
- whether the input stream should be uncompressed according to
Content-Disposition
this
public java.net.URL getURL()
URLConnection.getURL()
public java.lang.String getRequestMethod()
HttpURLConnection.getRequestMethod()
public java.io.InputStream getContent() throws java.io.IOException
Note: the return value can be null, if both the input and the error stream are null. Seems to be the case if the OSM server replies a 401 Unauthorized, see #3887
java.io.IOException
- if any I/O error occursURLConnection.getInputStream()
,
HttpURLConnection.getErrorStream()
public java.io.BufferedReader getContentReader() throws java.io.IOException
getContent()
wrapped in a buffered reader.
Detects Unicode charset in use utilizing UTFInputStreamReader
.java.io.IOException
- if any I/O error occurspublic java.lang.String fetchContent() throws java.io.IOException
java.io.IOException
- if any I/O error occurspublic int getResponseCode()
HttpURLConnection.getResponseCode()
public java.lang.String getResponseMessage()
HttpURLConnection.getResponseMessage()
public java.lang.String getContentEncoding()
Content-Encoding
header.Content-Encoding
HTTP headerURLConnection.getContentEncoding()
public java.lang.String getContentType()
Content-Type
header.Content-Type
HTTP headerpublic long getExpiration()
Expire
header.Expire
HTTP headerURLConnection.getExpiration()
public long getLastModified()
Last-Modified
header.Last-Modified
HTTP headerURLConnection.getLastModified()
public long getContentLength()
Content-Length
header.Content-Length
HTTP headerURLConnection.getContentLengthLong()
public java.lang.String getHeaderField(java.lang.String name)
name
- the name of a header fieldnull
if there is no such field in the headerURLConnection.getHeaderField(String)
public java.util.Map<java.lang.String,java.util.List<java.lang.String>> getHeaderFields()
URLConnection.getHeaderFields()
public void disconnect()
HttpURLConnection.disconnect()