Represents the HTTP headers of a server response in a server exchange as defined by RFC 7230 Section 3.2.
- Since:
- 1.0
- Author:
- Jeremy Kuhn
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionAdds the specified headers.add(CharSequence name, CharSequence value) Adds a header with the specified name and value.booleancontains(CharSequence name) Determines whether a header with the specified name is present.booleancontains(CharSequence name, CharSequence value) Determines whether a header with the specified name and value is present.contentLength(long length) Sets the response content length.contentType(String contentType) Sets the response content type header field value.get(CharSequence name) Returns the value of the header with the specified name.getAll()Returns all headers in the response.getAll(CharSequence name) Returns the values of all headers with the specified name.Decodes and returns all headers in the response.getAllHeader(CharSequence name) Decodes and returns all headers with the specified name.Returns all headers in the response as parameters.getAllParameter(CharSequence name) Returns all headers with the specified name as parameters.Returns the response content type header field value.Decodes and returns the response content type header.getHeader(CharSequence name) Decodes and returns the header with the specified name.getNames()Returns the names of the headers in the response.getParameter(CharSequence name) Returns the header with the specified name as a parameter.Returns the response HTTP status.intReturns the response HTTP status code.remove(CharSequence... names) Removes the headers with the specified names.Sets the specified headers.set(CharSequence name, CharSequence value) Sets the value of the header with the specified name.status(int status) Sets the response HTTP status codeSets the response HTTP status.
-
Method Details
-
status
Sets the response HTTP status.
- Parameters:
status- the HTTP status- Returns:
- the response headers
-
status
Sets the response HTTP status code
- Parameters:
status- the HTTP status code- Returns:
- the response headers
-
contentType
Sets the response content type header field value.
- Parameters:
contentType- the content type- Returns:
- the response headers
-
contentLength
Sets the response content length.
- Parameters:
length- the content length- Returns:
- the response headers
-
add
Adds a header with the specified name and value.
- Parameters:
name- the header namevalue- the header value- Returns:
- the response headers
-
add
Adds the specified headers.
- Parameters:
headers- the headers to add- Returns:
- the response headers
-
set
Sets the value of the header with the specified name.
- Parameters:
name- the header namevalue- the header value- Returns:
- the response headers
-
set
Sets the specified headers.
- Parameters:
headers- the headers to set- Returns:
- the response headers
-
remove
Removes the headers with the specified names.
- Parameters:
names- the names of the headers to remove- Returns:
- the response headers
-
getStatus
Status getStatus()Returns the response HTTP status.
- Returns:
- the response status
-
getStatusCode
int getStatusCode()Returns the response HTTP status code.
- Returns:
- the response status code
-
getContentType
Returns the response content type header field value.
- Returns:
- an optional returning the content type or an empty optional if there's no content type header
-
getContentTypeHeader
Optional<Headers.ContentType> getContentTypeHeader()Decodes and returns the response content type header.
- Returns:
- an optional returning the content type header or an empty optional if there's no content type header
-
contains
Determines whether a header with the specified name is present.
- Parameters:
name- a header name- Returns:
- true if a header is present, false otherwise
-
contains
Determines whether a header with the specified name and value is present.
- Parameters:
name- a header namevalue- a header value- Returns:
- true if a header is present, false otherwise
-
getNames
Returns the names of the headers in the response.
- Returns:
- a list of header names
-
get
Returns the value of the header with the specified name.
If there are multiple headers with the same name, this method returns the first one.
- Parameters:
name- a header name- Returns:
- an optional returning the value of the header or an empty optional if there's no header with the specified name
-
getAll
Returns the values of all headers with the specified name.
- Parameters:
name- a header name- Returns:
- a list of header values or an empty list if there's no header with the specified name
-
getAll
Returns all headers in the response.
- Returns:
- a list of header entries or an empty list if there's no header
-
getHeader
Decodes and returns the header with the specified name.
If there are multiple headers with the same name, this method returns the first one.
- Type Parameters:
T- the decoded header type- Parameters:
name- a header name- Returns:
- an optional returning the decoded header or an empty optional if there's no header with the specified name
-
getAllHeader
Decodes and returns all headers with the specified name.
- Type Parameters:
T- the decoded header type- Parameters:
name- a header name- Returns:
- a list of header values or an empty list if there's no header with the specified name
-
getAllHeader
Decodes and returns all headers in the response.
- Returns:
- a list of headers or an empty list if there's no header
-
getParameter
Returns the header with the specified name as a parameter.
If there are multiple headers with the same name, this method returns the first one.
- Parameters:
name- a header name- Returns:
- an optional returning the parameter or an empty optional if there's no header with the specified name
-
getAllParameter
Returns all headers with the specified name as parameters.
- Parameters:
name- a header name- Returns:
- a list of parameters or an empty list if there's no header with the specified name
-
getAllParameter
Returns all headers in the response as parameters.
- Returns:
- a list of parameters or an empty list if there's no header
-