java.lang.Object | |
↳ | com.neomades.io.http.HttpResponse |
HttpResponse object represents an http/https connection response.
Protected Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
HttpResponse(HttpRequest request)
Internal
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
long |
getContentLength()
Returns the response content length.
| ||||||||||
byte[] |
getData()
Returns the downloaded data byte array.
| ||||||||||
InputStream |
getDataStream()
Opens the downloaded data.
| ||||||||||
String |
getDataString()
Returns the downloaded data string.
| ||||||||||
String |
getHeader(String headerName)
Get a Header value.
| ||||||||||
Map<String, String> |
getHeaders()
Returns an unmodifiable Map of the header fields.
| ||||||||||
List<String> |
getHeaders(String headerName)
Get the list of values corresponding to a header's name.
| ||||||||||
int |
getHttpCode()
Gets the server response
| ||||||||||
String |
getMessage()
Returns the associated message (could be "OK" in case of Success, otherwise
the reason of the error)
| ||||||||||
HttpRequest |
getRequest()
Get the associated request.
| ||||||||||
boolean |
isSuccess()
Return if the HTTP response is corresponding to success.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Returns the response content length.
Returns the downloaded data byte array.
Since the data byte array is kept in memory, prefer using
getDataStream()
to download big data.
Opens the downloaded data.
Once the stream returned and consumed, it is released from memory and cannot
be accessed again using this method. It enables to save memory usage for big
response. To access several time to the HttpResponse data, use
getDataString()
or getData()
.
Returns the downloaded data string.
Since the data string is kept in memory, prefer using
getDataStream()
to download big data.
Get a Header value.
Note: If the header appears several times in the response, the first header value is returned. If one header contains a comma-separated value list, the value before the first comma will be returned.
headerName | the header's name |
---|
Returns an unmodifiable Map of the header fields.
The Map keys are Strings that represent the response-header field names. Each Map value is the raw String that represents the corresponding field values.
Get the list of values corresponding to a header's name.
A header may appear several times in the response. The values are ordered as they are sent over the connection.
Note: if a header contains a comma-separated value list, this method will split the value into several values in the result list.
headerName | the header's name |
---|
Returns the associated message (could be "OK" in case of Success, otherwise the reason of the error)
Get the associated request.
Return if the HTTP response is corresponding to success.
This method returns true if the HTTP Status code corresponds :
To get more details about HTTP status see the getHttpCode()
method.