Package play.mvc
Interface Http.RequestHeader
-
- All Known Subinterfaces:
Http.Request
- All Known Implementing Classes:
Http.RequestImpl
,play.core.j.RequestHeaderImpl
,play.core.j.RequestImpl
- Enclosing class:
- Http
public static interface Http.RequestHeader
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Deprecated Methods Modifier and Type Method Description List<play.api.http.MediaRange>
acceptedTypes()
List<Lang>
acceptLanguages()
The Request Langs extracted from the Accept-Language header and sorted by preference (preferred first).boolean
accepts(String mimeType)
Check if this request accepts a given media type.<A> Http.RequestHeader
addAttr(TypedKey<A> key, A value)
Create a new versions of this object with the given attribute attached to it.Http.RequestHeader
addAttrs(List<TypedEntry<?>> entries)
Create a new versions of this object with the given attributes attached to it.Http.RequestHeader
addAttrs(TypedEntry<?> e1)
Create a new versions of this object with the given attribute attached to it.Http.RequestHeader
addAttrs(TypedEntry<?> e1, TypedEntry<?> e2)
Create a new versions of this object with the given attributes attached to it.Http.RequestHeader
addAttrs(TypedEntry<?> e1, TypedEntry<?> e2, TypedEntry<?> e3)
Create a new versions of this object with the given attributes attached to it.play.api.mvc.RequestHeader
asScala()
TypedMap
attrs()
Optional<String>
charset()
Optional<List<X509Certificate>>
clientCertificateChain()
The X509 certificate chain presented by a client during SSL requests.Optional<String>
contentType()
Optional<Http.Cookie>
cookie(String name)
Http.Cookies
cookies()
default Http.Flash
flash()
Parses the Flash cookie and returns the Flash data.Optional<Http.Cookie>
getCookie(String name)
Deprecated.Deprecated as of 2.9.0.Http.Headers
getHeaders()
Deprecated.Deprecated as of 2.9.0.String
getQueryString(String key)
Deprecated.Deprecated as of 2.8.0.boolean
hasBody()
default boolean
hasHeader(String headerName)
Checks if the request has the header.default Optional<String>
header(String headerName)
Retrieves a single header.Http.Headers
headers()
Retrieve all headers.String
host()
default Long
id()
The request id.String
method()
String
path()
Map<String,String[]>
queryString()
The query string content.Optional<String>
queryString(String key)
Helper method to access a queryString parameter.String
remoteAddress()
The client IP address.Http.RequestHeader
removeAttr(TypedKey<?> key)
Create a new versions of this object with the given attribute removed.boolean
secure()
default Http.Session
session()
Parses the Session cookie and returns the Session data.default Optional<Lang>
transientLang()
The transient language will be taken into account when usingMessagesApi.preferred(RequestHeader)
} (It will take precedence over any other language).String
uri()
String
version()
Http.RequestHeader
withAttrs(TypedMap newAttrs)
Create a new version of this object with the given attributes attached to it.Http.Request
withBody(Http.RequestBody body)
Attach a body to this header.default Http.RequestHeader
withoutTransientLang()
Create a new version of this object with the given transient language removed.default Http.RequestHeader
withTransientLang(String code)
Deprecated.Deprecated as of 2.8.0 UsewithTransientLang(Lang)
instead.default Http.RequestHeader
withTransientLang(Locale locale)
Create a new version of this object with the given transient language set.default Http.RequestHeader
withTransientLang(Lang lang)
Create a new version of this object with the given transient language set.
-
-
-
Method Detail
-
id
default Long id()
The request id. The request id is stored as an attribute indexed byRequestAttrKey.Id()
.
-
uri
String uri()
- Returns:
- The complete request URI, containing both path and query string
-
method
String method()
- Returns:
- the HTTP Method
-
version
String version()
- Returns:
- the HTTP version
-
remoteAddress
String remoteAddress()
The client IP address.Retrieves the last untrusted proxy from the Forwarded-Headers or the X-Forwarded-*-Headers.
- Returns:
- the remote address
-
secure
boolean secure()
- Returns:
- true if the client is using SSL
-
attrs
TypedMap attrs()
- Returns:
- a map of typed attributes associated with the request.
-
withAttrs
Http.RequestHeader withAttrs(TypedMap newAttrs)
Create a new version of this object with the given attributes attached to it.- Parameters:
newAttrs
- The new attributes to add.- Returns:
- The new version of this object with the attributes attached.
-
addAttr
<A> Http.RequestHeader addAttr(TypedKey<A> key, A value)
Create a new versions of this object with the given attribute attached to it.- Type Parameters:
A
- the attribute type- Parameters:
key
- The new attribute key.value
- The attribute value.- Returns:
- The new version of this object with the new attribute.
-
addAttrs
Http.RequestHeader addAttrs(TypedEntry<?> e1)
Create a new versions of this object with the given attribute attached to it.- Parameters:
e1
- The new attribute.- Returns:
- The new version of this object with the new attribute.
-
addAttrs
Http.RequestHeader addAttrs(TypedEntry<?> e1, TypedEntry<?> e2)
Create a new versions of this object with the given attributes attached to it.- Parameters:
e1
- The first new attribute.e2
- The second new attribute.- Returns:
- The new version of this object with the new attributes.
-
addAttrs
Http.RequestHeader addAttrs(TypedEntry<?> e1, TypedEntry<?> e2, TypedEntry<?> e3)
Create a new versions of this object with the given attributes attached to it.- Parameters:
e1
- The first new attribute.e2
- The second new attribute.e3
- The third new attribute.- Returns:
- The new version of this object with the new attributes.
-
addAttrs
Http.RequestHeader addAttrs(List<TypedEntry<?>> entries)
Create a new versions of this object with the given attributes attached to it.- Parameters:
entries
- The new attributes.- Returns:
- The new version of this object with the new attributes.
-
removeAttr
Http.RequestHeader removeAttr(TypedKey<?> key)
Create a new versions of this object with the given attribute removed.- Parameters:
key
- The key of the attribute to remove.- Returns:
- The new version of this object with the attribute removed.
-
withBody
Http.Request withBody(Http.RequestBody body)
Attach a body to this header.- Parameters:
body
- The body to attach.- Returns:
- A new request with the body attached to the header.
-
host
String host()
- Returns:
- the request host
-
path
String path()
- Returns:
- the URI path
-
acceptLanguages
List<Lang> acceptLanguages()
The Request Langs extracted from the Accept-Language header and sorted by preference (preferred first).- Returns:
- the preference-ordered list of languages accepted by the client
-
acceptedTypes
List<play.api.http.MediaRange> acceptedTypes()
- Returns:
- The media types set in the request Accept header, sorted by preference (preferred first)
-
accepts
boolean accepts(String mimeType)
Check if this request accepts a given media type.- Parameters:
mimeType
- the mimeType to check for support.- Returns:
- true if
mimeType
is in the Accept header, otherwise false
-
queryString
Map<String,String[]> queryString()
The query string content.- Returns:
- the query string map
-
getQueryString
@Deprecated String getQueryString(String key)
Deprecated.Deprecated as of 2.8.0. UsequeryString(String)
instead.Helper method to access a queryString parameter.- Parameters:
key
- the query string parameter to look up- Returns:
- the value for the provided
key
.
-
queryString
Optional<String> queryString(String key)
Helper method to access a queryString parameter.- Parameters:
key
- the query string parameter to look up- Returns:
- the value for the provided
key
, if it exists.
-
cookies
Http.Cookies cookies()
- Returns:
- the request cookies
-
cookie
Optional<Http.Cookie> cookie(String name)
- Parameters:
name
- Name of the cookie to retrieve- Returns:
- the cookie, if found, otherwise null
-
getCookie
@Deprecated Optional<Http.Cookie> getCookie(String name)
Deprecated.Deprecated as of 2.9.0. Usecookie(String)
instead.- Parameters:
name
- Name of the cookie to retrieve- Returns:
- the cookie, if found
-
session
default Http.Session session()
Parses the Session cookie and returns the Session data. The request's session cookie is stored in an attribute indexed byRequestAttrKey.Session()
. The attribute uses aCell
to store the session cookie, to allow it to be evaluated on-demand.
-
flash
default Http.Flash flash()
Parses the Flash cookie and returns the Flash data. The request's flash cookie is stored in an attribute indexed byRequestAttrKey.Flash()
}. The attribute uses aCell
to store the flash, to allow it to be evaluated on-demand.
-
getHeaders
Http.Headers getHeaders()
Deprecated.Deprecated as of 2.9.0. Renamed toheaders()
.Retrieve all headers.- Returns:
- the request headers for this request.
-
headers
Http.Headers headers()
Retrieve all headers.- Returns:
- the request headers for this request.
-
header
default Optional<String> header(String headerName)
Retrieves a single header.- Parameters:
headerName
- The name of the header (case-insensitive)- Returns:
- the value corresponding to
headerName
, or empty if it was not present
-
hasHeader
default boolean hasHeader(String headerName)
Checks if the request has the header.- Parameters:
headerName
- The name of the header (case-insensitive)- Returns:
true
if the request did contain the header.
-
hasBody
boolean hasBody()
- Returns:
- true if request has a body, false otherwise.
-
contentType
Optional<String> contentType()
- Returns:
- The request content type excluding the charset, if it exists.
-
charset
Optional<String> charset()
- Returns:
- The request charset, which comes from the content type header, if it exists.
-
clientCertificateChain
Optional<List<X509Certificate>> clientCertificateChain()
The X509 certificate chain presented by a client during SSL requests.- Returns:
- The chain of X509Certificates used for the request if the request is secure and the server supports it.
-
withTransientLang
default Http.RequestHeader withTransientLang(Lang lang)
Create a new version of this object with the given transient language set. The transient language will be taken into account when usingMessagesApi.preferred(RequestHeader)
} (It will take precedence over any other language).- Parameters:
lang
- The language to use.- Returns:
- The new version of this object with the given transient language set.
-
withTransientLang
@Deprecated default Http.RequestHeader withTransientLang(String code)
Deprecated.Deprecated as of 2.8.0 UsewithTransientLang(Lang)
instead.Create a new version of this object with the given transient language set. The transient language will be taken into account when usingMessagesApi.preferred(RequestHeader)
} (It will take precedence over any other language).- Parameters:
code
- The language to use.- Returns:
- The new version of this object with the given transient language set.
-
withTransientLang
default Http.RequestHeader withTransientLang(Locale locale)
Create a new version of this object with the given transient language set. The transient language will be taken into account when usingMessagesApi.preferred(RequestHeader)
} (It will take precedence over any other language).- Parameters:
locale
- The language to use.- Returns:
- The new version of this object with the given transient language set.
-
withoutTransientLang
default Http.RequestHeader withoutTransientLang()
Create a new version of this object with the given transient language removed.- Returns:
- The new version of this object with the transient language removed.
-
transientLang
default Optional<Lang> transientLang()
The transient language will be taken into account when usingMessagesApi.preferred(RequestHeader)
} (It will take precedence over any other language).- Returns:
- The current transient language of this request.
-
asScala
play.api.mvc.RequestHeader asScala()
- Returns:
- the Scala version for this request header.
- See Also:
RequestHeader
-
-