Interface HttpResponse
- All Known Implementing Classes:
AbstractHttpResponse
,DefaultHttpResponse
public interface HttpResponse
Http response, defined by:
- A status code: http return code (i.e 200, 400, 500 etc.).
- A response body: this is the body of the http response as textual representation.
- A set of headers.
- Duration: time to produce http response.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbody()
Http response body.boolean
containsHeader
(String name) Check that given header is available.GetCache-Control
header from http response.GetContent-Encoding
header from http response.GetContent-Security-Policy
header from http response.GetContent-Type
header from http response.Get cookie by its name (if cookie is missing,null
is returned).Get all cookies sent by server.getETag()
GetETag
header from http response.Get header from HTTP response (if header is missing,null
will be returned).Get the list of headers.GetLast-Modified
header from http response.GetLocation
header from http response.long
Get duration of request execution in nano seconds.long
Get duration of request execution in milli seconds (shortcut forgetRequestDuration() / 100
).GetStrict-Transport-Security
header from http response.GetX-Content-Security-Policy
header from http response: this header was initially an experimental header implemented in Firefox.GetX-Content-Type-Options
header from http response.GetX-Webkit-CSP
header from http response: this header was initially an experimental header implemented in Webkit browser (Chrome and Safari).GetX-XSS-Protection
header from http response.int
status()
Http status code.
-
Method Details
-
getRequestDuration
long getRequestDuration()Get duration of request execution in nano seconds.- Returns:
- Request execution duration.
-
getRequestDurationInMillis
long getRequestDurationInMillis()Get duration of request execution in milli seconds (shortcut forgetRequestDuration() / 100
).- Returns:
- Request execution duration.
- See Also:
-
status
int status()Http status code.- Returns:
- Status code.
- See Also:
-
body
String body()Http response body.- Returns:
- Body.
- See Also:
-
getHeaders
Collection<HttpHeader> getHeaders()Get the list of headers.- Returns:
- Header list.
- See Also:
-
containsHeader
Check that given header is available.- Parameters:
name
- Header name.- Returns:
true
if header is in response,false
otherwise.- See Also:
-
getHeader
Get header from HTTP response (if header is missing,null
will be returned).- Parameters:
name
- Header name.- Returns:
- Header,
null
if header is not in http response. - Throws:
NullPointerException
- If name isnull
.- See Also:
-
getCookie
Get cookie by its name (if cookie is missing,null
is returned).- Parameters:
name
- Cookie name.- Returns:
- Cookie.
- See Also:
-
getCookies
Get all cookies sent by server.- Returns:
- Cookies.
- See Also:
-
getETag
HttpHeader getETag()GetETag
header from http response.- Returns:
- ETag header.
- See Also:
-
getContentType
HttpHeader getContentType()GetContent-Type
header from http response.- Returns:
- Content-Type header.
- See Also:
-
getContentEncoding
HttpHeader getContentEncoding()GetContent-Encoding
header from http response.- Returns:
- Content-Encoding header.
- See Also:
-
getLocation
HttpHeader getLocation()GetLocation
header from http response.- Returns:
- Location header.
- See Also:
-
getCacheControl
HttpHeader getCacheControl()GetCache-Control
header from http response.- Returns:
- Cache-Control header.
- See Also:
-
getLastModified
HttpHeader getLastModified()GetLast-Modified
header from http response.- Returns:
- Last-Modified header.
- See Also:
-
getStrictTransportSecurity
HttpHeader getStrictTransportSecurity()GetStrict-Transport-Security
header from http response.- Returns:
- Strict-Transport-Security header.
- See Also:
-
getContentSecurityPolicy
HttpHeader getContentSecurityPolicy()GetContent-Security-Policy
header from http response.- Returns:
- Content-Security-Policy header.
- See Also:
-
getXContentSecurityPolicy
HttpHeader getXContentSecurityPolicy()GetX-Content-Security-Policy
header from http response: this header was initially an experimental header implemented in Firefox.- Returns:
- X-Content-Security-Policy header.
- See Also:
-
getXWebkitCSP
HttpHeader getXWebkitCSP()GetX-Webkit-CSP
header from http response: this header was initially an experimental header implemented in Webkit browser (Chrome and Safari).- Returns:
- }X-Content-Security-Policy header.
- See Also:
-
getXContentTypeOptions
HttpHeader getXContentTypeOptions()GetX-Content-Type-Options
header from http response.- Returns:
- X-Content-Type-Options header.
- See Also:
-
getXXSSProtection
HttpHeader getXXSSProtection()GetX-XSS-Protection
header from http response.- Returns:
- X-XSS-Protection header.
- See Also:
-