Package com.groiss.http
Class Response
java.lang.Object
com.groiss.http.Response
- All Implemented Interfaces:
SilentCloseable
,AutoCloseable
This class implements the response of a request executed via one of the request methods of
Client
.-
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Closes the response and therefore releases all resources.Returns the headers of the response.Deprecated, for removal: This API element is subject to removal in a future version.since ep 10.0 (rev. 36486) as it cannot handle the case of multiple headers with the same name (case-sensitive) - this method will only return the last value for such headers.getHeaderValues
(String headerName) Returns the values of the header with the given name (case-insensitive) of the response.Returns the result of the request as JSONArrayReturns the result of the request as JSONObjectget the request details thisResponse
originated fromReturns the result of the request as InputStream (e.g. needed if the result is a file)int
Returns the HTTP status code of the response (e.g. 200 for SUCCESS)Returns the HTTP status message of the responseReturns the result of the request as string object
-
Method Details
-
close
public void close()Closes the response and therefore releases all resources.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceSilentCloseable
-
getStatusCode
public int getStatusCode()Returns the HTTP status code of the response (e.g. 200 for SUCCESS)- Returns:
- the HTTP status code of the response
-
getStatusMessage
Returns the HTTP status message of the response- Returns:
- the HTTP status message of the response
-
getStringResult
Returns the result of the request as string object- Returns:
- the result of the response
-
getJSONObjectResult
Returns the result of the request as JSONObject- Returns:
- the result of the response
-
getJSONArrayResult
Returns the result of the request as JSONArray- Returns:
- the result of the response
-
getResult
Returns the result of the request as InputStream (e.g. needed if the result is a file)- Returns:
- the result of the response
-
getHeaders
Deprecated, for removal: This API element is subject to removal in a future version.since ep 10.0 (rev. 36486) as it cannot handle the case of multiple headers with the same name (case-sensitive) - this method will only return the last value for such headers. UsegetAllHeaders()
orgetHeaderValues(String)
instead.Returns the headers of the response- Returns:
- the headers of the response
-
getAllHeaders
Returns the headers of the response. If the response contains multiple headers with the same name (case-sensitive) each value will be present in the list of the map entry with the header's name. The lists are ordered by the sequence of the corresponding header in the response. Note: for retrieval of header values by case-insensitive header names, methodgetHeaderValues(String)
can be used.- Returns:
- the headers and their values. If the response has no such headers, an empty map is returned.
-
getHeaderValues
Returns the values of the header with the given name (case-insensitive) of the response.- Parameters:
headerName
- the name of the header which values shall be returned (name comparison is done case-insensitive)- Returns:
- all values of the specified header in the order of the sequence of the headers in the response. If the response has no such headers, an empty list is returned.
-
getRequestString
get the request details thisResponse
originated from- Returns:
- the request method + URL + protocol used when requesting this
Response
-