public final class RequestHeader extends MessageHeader
This header may or may not be mapped down onto HTTP. In order to remain agnostic to the underlying protocol, information required by Lagom, such as protocol information, is extracted. It is encouraged that the protocol information always be used in preference to reading the information directly out of headers, since the headers may not contain the necessary protocol information.
The headers are however still provided, in case information needs to be extracted out of non standard headers.
Modifier and Type | Field and Description |
---|---|
static RequestHeader |
DEFAULT
A default request header object.
|
Constructor and Description |
---|
RequestHeader(Method method,
URI uri,
MessageProtocol protocol,
org.pcollections.PSequence<MessageProtocol> acceptedResponseProtocols,
Optional<Principal> principal,
org.pcollections.PMap<String,org.pcollections.PSequence<String>> headers) |
Modifier and Type | Method and Description |
---|---|
org.pcollections.PSequence<MessageProtocol> |
acceptedResponseProtocols()
Get the accepted response protocols for this request.
|
RequestHeader |
clearPrincipal()
Return a copy of this request header with the principal cleared.
|
boolean |
equals(Object o) |
int |
hashCode() |
Method |
method()
Get the method used to make this request.
|
Optional<Principal> |
principal()
Get the principal for this request, if there is one.
|
RequestHeader |
replaceAllHeaders(org.pcollections.PMap<String,org.pcollections.PSequence<String>> headers)
Return a copy of this message header with the headers replaced by the given map of headers.
|
String |
toString() |
URI |
uri()
Get the URI for this request.
|
RequestHeader |
withAcceptedResponseProtocols(org.pcollections.PSequence<MessageProtocol> acceptedResponseProtocols)
Return a copy of this request header with the given accepted response protocols set.
|
RequestHeader |
withHeader(String name,
String value)
Return a copy of this message header with the given header added to the map of headers.
|
RequestHeader |
withMethod(Method method)
Return a copy of this request header with the given method set.
|
RequestHeader |
withPrincipal(Principal principal)
Return a copy of this request header with the principal set.
|
RequestHeader |
withProtocol(MessageProtocol protocol)
Return a copy of this message header with the given protocol.
|
RequestHeader |
withUri(URI uri)
Return a copy of this request header with the given uri set.
|
getHeader, headers, protocol
public static final RequestHeader DEFAULT
This is a convenience supplied so that server implementations of service calls can pass this request to the request header handler, in order to get the actual incoming request header.
public RequestHeader(Method method, URI uri, MessageProtocol protocol, org.pcollections.PSequence<MessageProtocol> acceptedResponseProtocols, Optional<Principal> principal, org.pcollections.PMap<String,org.pcollections.PSequence<String>> headers)
public Method method()
public URI uri()
public org.pcollections.PSequence<MessageProtocol> acceptedResponseProtocols()
public Optional<Principal> principal()
public RequestHeader withMethod(Method method)
method
- The method to set.public RequestHeader withUri(URI uri)
uri
- The uri to set.public RequestHeader withProtocol(MessageProtocol protocol)
MessageHeader
withProtocol
in class MessageHeader
protocol
- The protocol to set.public RequestHeader withAcceptedResponseProtocols(org.pcollections.PSequence<MessageProtocol> acceptedResponseProtocols)
acceptedResponseProtocols
- The accepted response protocols to set.public RequestHeader withPrincipal(Principal principal)
principal
- The principal to set.public RequestHeader clearPrincipal()
public RequestHeader replaceAllHeaders(org.pcollections.PMap<String,org.pcollections.PSequence<String>> headers)
MessageHeader
replaceAllHeaders
in class MessageHeader
headers
- The map of headers.public RequestHeader withHeader(String name, String value)
MessageHeader
If the header already has a value, this value will replace it.
withHeader
in class MessageHeader
name
- The name of the header to add.value
- The value of the header to add.