Package io.helidon.webserver
Interface RequestHeaders
-
- All Superinterfaces:
Headers
,Parameters
public interface RequestHeaders extends Headers
ExtendsParameters
interface by adding HTTP request headers oriented convenient methods. Use constants located inHttp.Header
as standard header names.- See Also:
Http.Header
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description Optional<ZonedDateTime>
acceptDatetime()
Optionally returns acceptedTypes version in time ("Accept-Datetime" header).List<MediaType>
acceptedTypes()
Returns a list of acceptedTypes ("Accept" header) content types in quality factor order.Optional<MediaType>
bestAccepted(MediaType... mediaTypes)
Optionally returns a single media type from the given media types that is the best one accepted by the client.OptionalLong
contentLength()
Optionally returns the length of the request body in octets (8-bit bytes).Optional<MediaType>
contentType()
Optionally returns the MIME type of the body of the request.Parameters
cookies()
Returns cookies (parsed from 'Cookie:
' header) based on RFC6265.Optional<ZonedDateTime>
date()
Optionally returns request date ("Accept-Datetime" header).Optional<ZonedDateTime>
ifModifiedSince()
Optionally returns a value of "If-Modified-Since" header.Optional<ZonedDateTime>
ifUnmodifiedSince()
Optionally returns a value of "If-Unmodified-Since" header.boolean
isAccepted(MediaType mediaType)
Test if the given media type is acceptable as a response for this request.Optional<URI>
referer()
Optionally returns the address of the previous web page (header "Referer") from which a link to the currently requested page was followed.-
Methods inherited from interface io.helidon.common.http.Parameters
add, add, addAll, computeIfAbsent, computeSingleIfAbsent, first, put, put, putAll, putIfAbsent, putIfAbsent, remove, toMap
-
-
-
-
Method Detail
-
contentType
Optional<MediaType> contentType()
Optionally returns the MIME type of the body of the request.- Returns:
- Media type of the content.
-
contentLength
OptionalLong contentLength()
Optionally returns the length of the request body in octets (8-bit bytes).- Returns:
- Length of the body in octets.
-
cookies
Parameters cookies()
Returns cookies (parsed from 'Cookie:
' header) based on RFC6265. It parse also older formats including RFC2965 but skips parameters. Only cookiename
andvalue
is returned.Multiple cookies can be returned in a single headers and a single cookie-name can have multiple values. Note that base on RFC6265 an order of cookie values has no semantics.
- Returns:
- An unmodifiable cookies represented by
Parameters
interface where key is a name of the cookie and values are cookie values.
-
acceptedTypes
List<MediaType> acceptedTypes()
Returns a list of acceptedTypes ("Accept" header) content types in quality factor order. Nevernull
.- Returns:
- A list of acceptedTypes media types.
-
isAccepted
boolean isAccepted(MediaType mediaType)
Test if the given media type is acceptable as a response for this request. A media type is accepted if theAccept
header is not present in the request or if it contains the provided media type.- Parameters:
mediaType
- the media type to test- Returns:
true
if provided type is acceptable,false
otherwise- Throws:
NullPointerException
- if the provided type isnull
.
-
bestAccepted
Optional<MediaType> bestAccepted(MediaType... mediaTypes)
Optionally returns a single media type from the given media types that is the best one accepted by the client. Method uses content negotiation "Accept" header parameter and returns an empty value in case nothing matches.- Parameters:
mediaTypes
- media type candidates.- Returns:
- an accepted media type.
-
acceptDatetime
Optional<ZonedDateTime> acceptDatetime()
Optionally returns acceptedTypes version in time ("Accept-Datetime" header).- Returns:
- Acceptable version in time.
-
date
Optional<ZonedDateTime> date()
Optionally returns request date ("Accept-Datetime" header).- Returns:
- Request date.
-
ifModifiedSince
Optional<ZonedDateTime> ifModifiedSince()
Optionally returns a value of "If-Modified-Since" header.Allows a 304 Not Modified to be returned if content is unchanged.
- Returns:
- Content of "If-Modified-Since" header.
-
ifUnmodifiedSince
Optional<ZonedDateTime> ifUnmodifiedSince()
Optionally returns a value of "If-Unmodified-Since" header.Only send the response if the entity has not been modified since a specific time.
- Returns:
- Content of "If-Modified-Since" header.
-
referer
Optional<URI> referer()
Optionally returns the address of the previous web page (header "Referer") from which a link to the currently requested page was followed.The word
referrer
has been misspelled in the RFC as well as in most implementations to the point that it has become standard usage and is considered correct terminology- Returns:
- Referrers URI
-
-