public abstract static class HttpClient.Response extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private ProgressMonitor |
monitor |
private int |
responseCode |
private java.lang.String |
responseData |
private java.lang.String |
responseMessage |
private boolean |
uncompress |
private boolean |
uncompressAccordingToContentDisposition |
Modifier | Constructor and Description |
---|---|
protected |
Response(ProgressMonitor monitor,
int responseCode,
java.lang.String responseMessage) |
Modifier and Type | Method and Description |
---|---|
protected void |
debugRedirect() |
abstract 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.
|
abstract java.lang.String |
getContentEncoding()
Returns the
Content-Encoding header. |
abstract long |
getContentLength()
Returns the
Content-Length header. |
java.io.BufferedReader |
getContentReader()
Returns
getContent() wrapped in a buffered reader. |
abstract java.lang.String |
getContentType()
Returns the
Content-Type header. |
abstract long |
getExpiration()
Returns the
Expire header. |
abstract java.lang.String |
getHeaderField(java.lang.String name)
Returns the value of the named header field.
|
abstract 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.
|
protected abstract java.io.InputStream |
getInputStream() |
abstract long |
getLastModified()
Returns the
Last-Modified header. |
abstract 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.
|
abstract 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 ProgressMonitor monitor
private final int responseCode
private final java.lang.String responseMessage
private boolean uncompress
private boolean uncompressAccordingToContentDisposition
private java.lang.String responseData
protected Response(ProgressMonitor monitor, int responseCode, java.lang.String responseMessage)
protected final void debugRedirect() throws java.io.IOException
java.io.IOException
public final HttpClient.Response uncompress(boolean uncompress)
getContent()
should uncompress the input stream if necessary.uncompress
- whether the input stream should be uncompressed if necessarythis
public final 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 abstract java.net.URL getURL()
URLConnection.getURL()
public abstract java.lang.String getRequestMethod()
HttpURLConnection.getRequestMethod()
public final 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()
protected abstract java.io.InputStream getInputStream() throws java.io.IOException
java.io.IOException
public final 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 final java.lang.String fetchContent() throws java.io.IOException
java.io.IOException
- if any I/O error occurspublic final int getResponseCode()
HttpURLConnection.getResponseCode()
public final java.lang.String getResponseMessage()
HttpURLConnection.getResponseMessage()
public abstract java.lang.String getContentEncoding()
Content-Encoding
header.Content-Encoding
HTTP headerURLConnection.getContentEncoding()
public abstract java.lang.String getContentType()
Content-Type
header.Content-Type
HTTP headerURLConnection.getContentType()
public abstract long getExpiration()
Expire
header.Expire
HTTP headerURLConnection.getExpiration()
public abstract long getLastModified()
Last-Modified
header.Last-Modified
HTTP headerURLConnection.getLastModified()
public abstract long getContentLength()
Content-Length
header.Content-Length
HTTP headerURLConnection.getContentLengthLong()
public abstract 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 abstract java.util.Map<java.lang.String,java.util.List<java.lang.String>> getHeaderFields()
URLConnection.getHeaderFields()
public abstract void disconnect()
HttpURLConnection.disconnect()