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
Modifier and TypeMethodDescriptionList<play.api.http.MediaRange>The Request Langs extracted from the Accept-Language header and sorted by preference (preferred first).booleanCheck if this request accepts a given media type.Create a new versions of this object with the given attribute attached to it.addAttrs(List<TypedEntry<?>> entries) Create a new versions of this object with the given attributes attached to it.addAttrs(TypedEntry<?> e1) Create a new versions of this object with the given attribute attached to it.addAttrs(TypedEntry<?> e1, TypedEntry<?> e2) Create a new versions of this object with the given attributes attached to it.addAttrs(TypedEntry<?> e1, TypedEntry<?> e2, TypedEntry<?> e3) Create a new versions of this object with the given attributes attached to it.play.api.mvc.RequestHeaderasScala()attrs()charset()The X509 certificate chain presented by a client during SSL requests.cookies()default Http.Flashflash()Parses the Flash cookie and returns the Flash data.Deprecated.Deprecated as of 2.9.0.Deprecated.Deprecated as of 2.9.0.getQueryString(String key) Deprecated.Deprecated as of 2.8.0.booleanhasBody()default booleanChecks if the request has the header.Retrieves a single header.headers()Retrieve all headers.host()default Longid()The request id.method()path()The query string content.queryString(String key) Helper method to access a queryString parameter.The client IP address.removeAttr(TypedKey<?> key) Create a new versions of this object with the given attribute removed.booleansecure()default Http.Sessionsession()Parses the Session cookie and returns the Session data.The transient language will be taken into account when usingMessagesApi.preferred(RequestHeader)} (It will take precedence over any other language).uri()version()Create a new version of this object with the given attributes attached to it.withBody(Http.RequestBody body) Attach a body to this header.default Http.RequestHeaderCreate a new version of this object with the given transient language removed.default Http.RequestHeaderwithTransientLang(String code) Deprecated.Deprecated as of 2.8.0 UsewithTransientLang(Lang)instead.default Http.RequestHeaderwithTransientLang(Locale locale) Create a new version of this object with the given transient language set.default Http.RequestHeaderwithTransientLang(Lang lang) Create a new version of this object with the given transient language set.
-
Method Details
-
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
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
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
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
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
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
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
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
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
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
Check if this request accepts a given media type.- Parameters:
mimeType- the mimeType to check for support.- Returns:
- true if
mimeTypeis in the Accept header, otherwise false
-
queryString
The query string content.- Returns:
- the query string map
-
getQueryString
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
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
- Parameters:
name- Name of the cookie to retrieve- Returns:
- the cookie, if found, otherwise null
-
getCookie
Deprecated.Deprecated as of 2.9.0. Usecookie(String)instead.- Parameters:
name- Name of the cookie to retrieve- Returns:
- the cookie, if found
-
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 aCellto store the session cookie, to allow it to be evaluated on-demand. -
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 aCellto 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
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
Checks if the request has the header.- Parameters:
headerName- The name of the header (case-insensitive)- Returns:
trueif the request did contain the header.
-
hasBody
boolean hasBody()- Returns:
- true if request has a body, false otherwise.
-
contentType
- Returns:
- The request content type excluding the charset, if it exists.
-
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
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.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
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
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
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
-