Package org.openstreetmap.josm.tools
Class HttpClient.Response
java.lang.Object
org.openstreetmap.josm.tools.HttpClient.Response
- Direct Known Subclasses:
Http1Client.Http1Response
- Enclosing class:
- HttpClient
A wrapper for the HTTP response.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ProgressMonitorprivate final intprivate Stringprivate final Stringprivate booleanprivate boolean -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedResponse(ProgressMonitor monitor, int responseCode, String responseMessage) -
Method Summary
Modifier and TypeMethodDescriptionprotected final voidabstract voidIndicates that other requests to the server are unlikely in the near future.final StringFetches the HTTP response as String.final InputStreamReturns an input stream that reads from this HTTP connection, or, error stream if the connection failed but the server sent useful data.abstract StringReturns theContent-Encodingheader.abstract longReturns theContent-Lengthheader.final BufferedReaderReturnsgetContent()wrapped in a buffered reader.abstract StringReturns theContent-Typeheader.abstract longReturns theExpireheader.abstract StringgetHeaderField(String name) Returns the value of the named header field.Returns an unmodifiable Map mapping header keys to a List of header values.protected abstract InputStreamabstract longReturns theLast-Modifiedheader.abstract StringReturns the request method.final intGets the response code from this HTTP connection.final StringGets the response message from this HTTP connection.abstract URLgetURL()Returns the URL.final HttpClient.Responseuncompress(boolean uncompress) Sets whethergetContent()should uncompress the input stream if necessary.final HttpClient.ResponseuncompressAccordingToContentDisposition(boolean uncompressAccordingToContentDisposition) Sets whethergetContent()should uncompress the input stream according toContent-DispositionHTTP header.
-
Field Details
-
monitor
-
responseCode
-
responseMessage
-
uncompress
-
uncompressAccordingToContentDisposition
-
responseData
-
-
Constructor Details
-
Response
-
-
Method Details
-
debugRedirect
- Throws:
IOException
-
uncompress
Sets whethergetContent()should uncompress the input stream if necessary.- Parameters:
uncompress- whether the input stream should be uncompressed if necessary- Returns:
this
-
uncompressAccordingToContentDisposition
public final HttpClient.Response uncompressAccordingToContentDisposition(boolean uncompressAccordingToContentDisposition) Sets whethergetContent()should uncompress the input stream according toContent-DispositionHTTP header.- Parameters:
uncompressAccordingToContentDisposition- whether the input stream should be uncompressed according toContent-Disposition- Returns:
this- Since:
- 9172
-
getURL
Returns the URL.- Returns:
- the URL
- Since:
- 9172
- See Also:
-
getRequestMethod
Returns the request method.- Returns:
- the HTTP request method
- Since:
- 9172
- See Also:
-
getContent
Returns an input stream that reads from this HTTP connection, or, error stream if the connection failed but the server sent useful data.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
- Returns:
- input or error stream
- Throws:
IOException- if any I/O error occurs- See Also:
-
getInputStream
- Throws:
IOException
-
getContentReader
ReturnsgetContent()wrapped in a buffered reader. Detects Unicode charset in use utilizingUTFInputStreamReader.- Returns:
- buffered reader
- Throws:
IOException- if any I/O error occurs
-
fetchContent
Fetches the HTTP response as String.- Returns:
- the response
- Throws:
IOException- if any I/O error occurs
-
getResponseCode
Gets the response code from this HTTP connection.- Returns:
- HTTP response code
- See Also:
-
getResponseMessage
Gets the response message from this HTTP connection.- Returns:
- HTTP response message
- Since:
- 9172
- See Also:
-
getContentEncoding
Returns theContent-Encodingheader.- Returns:
Content-EncodingHTTP header- See Also:
-
getContentType
Returns theContent-Typeheader.- Returns:
Content-TypeHTTP header- See Also:
-
getExpiration
Returns theExpireheader.- Returns:
ExpireHTTP header- Since:
- 9232
- See Also:
-
getLastModified
Returns theLast-Modifiedheader.- Returns:
Last-ModifiedHTTP header- Since:
- 9232
- See Also:
-
getContentLength
Returns theContent-Lengthheader.- Returns:
Content-LengthHTTP header- See Also:
-
getHeaderField
Returns the value of the named header field.- Parameters:
name- the name of a header field- Returns:
- the value of the named header field, or
nullif there is no such field in the header - Since:
- 9172
- See Also:
-
getHeaderFields
Returns an unmodifiable Map mapping header keys to a List of header values. As per RFC 2616, section 4.2 header names are case insensitive, so returned map is also case insensitive- Returns:
- unmodifiable Map mapping header keys to a List of header values
- Since:
- 9232
- See Also:
-
disconnect
Indicates that other requests to the server are unlikely in the near future.- See Also:
-