public static final class HttpClient.Response extends Object
Modifier and Type | Field and Description |
---|---|
private HttpURLConnection |
connection |
private ProgressMonitor |
monitor |
private int |
responseCode |
private String |
responseMessage |
private boolean |
uncompress |
private boolean |
uncompressAccordingToContentDisposition |
Modifier | Constructor and Description |
---|---|
private |
Response(HttpURLConnection connection,
ProgressMonitor monitor) |
Modifier and Type | Method and Description |
---|---|
void |
disconnect() |
String |
fetchContent()
Fetches the HTTP response as String.
|
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.
|
String |
getContentEncoding()
Returns the
Content-Encoding header. |
long |
getContentLength()
Returns the
Content-Length header. |
BufferedReader |
getContentReader()
Returns
getContent() wrapped in a buffered reader. |
String |
getContentType()
Returns the
Content-Type header. |
long |
getExpiration()
Returns the
Expire header. |
String |
getHeaderField(String name)
Returns the value of the named header field.
|
Map<String,List<String>> |
getHeaderFields()
Returns an unmodifiable Map mapping header keys to a List of header values.
|
long |
getLastModified()
Returns the
Last-Modified header. |
String |
getRequestMethod()
Returns the request method.
|
int |
getResponseCode()
Gets the response code from this HTTP connection.
|
String |
getResponseMessage()
Gets the response message from this HTTP connection.
|
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 HttpURLConnection connection
private final ProgressMonitor monitor
private final int responseCode
private final String responseMessage
private boolean uncompress
private boolean uncompressAccordingToContentDisposition
private Response(HttpURLConnection connection, ProgressMonitor monitor) throws IOException
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 URL getURL()
URLConnection.getURL()
public String getRequestMethod()
HttpURLConnection.getRequestMethod()
public InputStream getContent() throws 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
IOException
- if any I/O error occursURLConnection.getInputStream()
,
HttpURLConnection.getErrorStream()
public BufferedReader getContentReader() throws IOException
getContent()
wrapped in a buffered reader.
Detects Unicode charset in use utilizing UTFInputStreamReader
.IOException
- if any I/O error occurspublic String fetchContent() throws IOException
IOException
- if any I/O error occurspublic int getResponseCode()
HttpURLConnection.getResponseCode()
public String getResponseMessage()
HttpURLConnection.getResponseMessage()
public String getContentEncoding()
Content-Encoding
header.Content-Encoding
HTTP headerURLConnection.getContentEncoding()
public 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 String getHeaderField(String name)
name
- the name of a header fieldnull
if there is no such field in the headerURLConnection.getHeaderField(String)
public Map<String,List<String>> getHeaderFields()
URLConnection.getHeaderFields()
public void disconnect()
HttpURLConnection.disconnect()