public interface RequestHeader
Method, Path, QueryString, Headers and Cookies.
No Entity.
Helper methods.
Parameters are available once bound to a Route, see bind(io.werval.api.routes.ParameterBinders, io.werval.api.routes.Route)
and parameters()
.
Modifier and Type | Method and Description |
---|---|
List<Lang> |
acceptedLangs()
Accepted Languages.
|
List<MediaRange> |
acceptedMimeTypes()
Accepted content mime types.
|
boolean |
acceptsMimeType(String mimeType)
Test if this request accepts the given mime type.
|
RequestHeader |
bind(ParameterBinders parameterBinders, Route route)
Bind Route parameters.
|
Optional<String> |
charset()
The HTTP Request Charset, optional.
|
Optional<String> |
contentType()
The HTTP Request content type, optional.
|
Cookies |
cookies() |
String |
domain()
The HTTP Domain.
|
Headers |
headers() |
String |
host()
The HTTP Host with or without the port.
|
String |
identity() |
boolean |
isKeepAlive()
Return true if and only if the connection can remain open.
|
Method |
method() |
Map<String,Object> |
parameters()
Bound Route parameters.
|
String |
path() |
int |
port()
The HTTP Port.
|
Lang |
preferredLang()
Preferred Language.
|
String |
preferredMimeType(String... mimeTypes)
Preferred Mime Type.
|
QueryString |
queryString() |
String |
remoteAddress()
The HTTP Client Address.
|
String |
uri() |
ProtocolVersion |
version() |
String identity()
ProtocolVersion version()
Method method()
String uri()
String path()
QueryString queryString()
Headers headers()
Cookies cookies()
String remoteAddress()
Default value is the underlying socket client address.
If the werval.http.headers.x_forwarded_for.enabled configuration property is yes, then the value is computed from the X-Forwarded-For header value. This is the default behaviour.
If the werval.http.headers.x_forwarded_for.check_proxies configuration property is yes, then X-Forwarded-For value is accepted only if all proxies in the chain are present in the werval.http.headers.x_forwarded_for.trusted_proxies configuration list. This is the default behaviour trusting only 127.0.0.1.
If the X-Forwarded-For cannot be trusted, Werval will respond with a 400 Bad Request.
String host()
HTTP Host header, mandatory since HTTP 1.1.
int port()
Computed from the request URI or HTTP Host header and standard defaults 80/443.
String domain()
Computed from the request URI.
Optional<String> contentType()
Computed from the Content-Type header, charset removed.
Optional<String> charset()
Computed from the Content-Type header.
boolean isKeepAlive()
Honnor Headers.Names.CONNECTION
header and then protocol version defaults.
RequestHeader bind(ParameterBinders parameterBinders, Route route)
Successive calls to parameters()
will return bound parameters.
parameterBinders
- Parameter binders
route
- Route
Map<String,Object> parameters()
List<Lang> acceptedLangs()
Lang preferredLang()
Guess the preferred language according to the Accept-Language request header or Application's preferred language, or the language of the default Locale.
List<MediaRange> acceptedMimeTypes()
boolean acceptsMimeType(String mimeType)
mimeType
- Mime type
String preferredMimeType(String... mimeTypes)
Guess the preferred mime types among given mime types according to the Accept request header.
If the request accepts any mime type and no candidate were given, return *\/*, otherwise return the first candidate.
If no candidate is accepted, return the preferred mime type according the the Accept request header.
mimeTypes
- Candidate mime types