Interface HttpRequestMetaData
-
- All Superinterfaces:
HttpMetaData
- All Known Subinterfaces:
BlockingStreamingHttpRequest
,HttpRequest
,StreamingHttpRequest
public interface HttpRequestMetaData extends HttpMetaData
Meta data associated with an HTTP request.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default HttpRequestMetaData
addCookie(HttpCookiePair cookie)
Adds a cookie.default HttpRequestMetaData
addCookie(java.lang.CharSequence name, java.lang.CharSequence value)
default HttpRequestMetaData
addHeader(java.lang.CharSequence name, java.lang.CharSequence value)
Adds a new header with the specifiedname
andvalue
.default HttpRequestMetaData
addHeaders(HttpHeaders headers)
Adds all header names and values ofheaders
object.HttpRequestMetaData
addQueryParameter(java.lang.String key, java.lang.String value)
Adds a new query parameter with the specifiedkey
andvalue
, which will be percent-encoded if needed.HttpRequestMetaData
addQueryParameters(java.lang.String key, java.lang.Iterable<java.lang.String> values)
Adds new query parameters with the specifiedkey
andvalues
.HttpRequestMetaData
addQueryParameters(java.lang.String key, java.lang.String... values)
Adds new query parameters with the specifiedkey
andvalues
.default HttpRequestMetaData
addSetCookie(HttpSetCookie cookie)
Adds a set-cookie.default HttpRequestMetaData
addSetCookie(java.lang.CharSequence name, java.lang.CharSequence value)
HttpRequestMetaData
appendPathSegments(java.lang.String... segments)
Appends segments to the currentpath()
, performing encoding of each segment (including ('/'
) characters) according to percent-encoding.HostAndPort
effectiveHostAndPort()
default boolean
hasQueryParameter(java.lang.String key)
Returnstrue
if a query parameter with thekey
exists,false
otherwise.boolean
hasQueryParameter(java.lang.String key, java.lang.String value)
Returnstrue
if a query parameter with thekey
andvalue
exists,false
otherwise.java.lang.String
host()
The host component derived fromrequestTarget()
.HttpRequestMethod
method()
Returns theHttpRequestMethod
of thisStreamingHttpRequest
.HttpRequestMetaData
method(HttpRequestMethod method)
Set theHttpRequestMethod
of thisStreamingHttpRequest
.java.lang.String
path()
Get an equivalent value asrawPath()
but decoded according to percent-encoding.HttpRequestMetaData
path(java.lang.String path)
Sets the path, performing encoding according to percent-encoding, except for forward-slash ('/'
) characters.int
port()
The port component derived fromrequestTarget()
.java.lang.String
query()
Get an equivalent value asrawQuery()
but decoded according to rfc3986, Query.HttpRequestMetaData
query(java.lang.String query)
Sets the path, performing encoding according to rfc3986, Query.java.lang.String
queryParameter(java.lang.String key)
Returns the value of a query parameter with the specified key.java.lang.Iterable<java.util.Map.Entry<java.lang.String,java.lang.String>>
queryParameters()
Returns all query parameters as key/value pairs.java.lang.Iterable<java.lang.String>
queryParameters(java.lang.String key)
Returns all values for the query parameter with the specified key.java.util.Iterator<java.lang.String>
queryParametersIterator(java.lang.String key)
Returns all values for the query parameter with the specified key.java.util.Set<java.lang.String>
queryParametersKeys()
Returns aSet
of all query parameter keys.int
queryParametersSize()
Returns the number of query parameters.java.lang.String
rawPath()
The path component derived fromrequestTarget()
.HttpRequestMetaData
rawPath(java.lang.String path)
Sets the path topath
, without any encoding performed.java.lang.String
rawQuery()
The query component derived fromrequestTarget()
.HttpRequestMetaData
rawQuery(java.lang.String query)
Sets the query component toquery
, without any encoding performed.boolean
removeQueryParameters(java.lang.String key)
Removes all query parameters with the specifiedkey
.boolean
removeQueryParameters(java.lang.String key, java.lang.String value)
Removes all query parameters with the specifiedkey
andvalue
.java.lang.String
requestTarget()
The request-target.HttpRequestMetaData
requestTarget(java.lang.String requestTarget)
Set the request-target.HttpRequestMetaData
requestTarget(java.lang.String requestTarget, java.nio.charset.Charset encoding)
Set the request-target.java.lang.String
requestTarget(java.nio.charset.Charset encoding)
The request-target.java.lang.String
scheme()
The scheme component derived fromrequestTarget()
in lower case.default HttpRequestMetaData
setHeader(java.lang.CharSequence name, java.lang.CharSequence value)
Sets a header with the specifiedname
andvalue
.default HttpRequestMetaData
setHeaders(HttpHeaders headers)
Clears the current header entries and copies all header entries of the specifiedheaders
object.HttpRequestMetaData
setQueryParameter(java.lang.String key, java.lang.String value)
HttpRequestMetaData
setQueryParameters(java.lang.String key, java.lang.Iterable<java.lang.String> values)
Sets new query parameters with the specifiedkey
andvalues
.HttpRequestMetaData
setQueryParameters(java.lang.String key, java.lang.String... values)
Sets new query parameters with the specifiedkey
andvalues
.java.lang.String
userInfo()
The user information component derived fromrequestTarget()
.HttpRequestMetaData
version(HttpProtocolVersion version)
Set the protocol version of thisHttpMetaData
.
-
-
-
Method Detail
-
method
HttpRequestMethod method()
Returns theHttpRequestMethod
of thisStreamingHttpRequest
.- Returns:
- The
HttpRequestMethod
of thisStreamingHttpRequest
-
method
HttpRequestMetaData method(HttpRequestMethod method)
Set theHttpRequestMethod
of thisStreamingHttpRequest
.- Parameters:
method
- theHttpRequestMethod
to set.- Returns:
this
.
-
requestTarget
java.lang.String requestTarget()
The request-target.No decoding has been done on the request-target.
- Returns:
- The request-target.
No decoding has been done on the request-target.
-
requestTarget
java.lang.String requestTarget(java.nio.charset.Charset encoding)
The request-target.- Parameters:
encoding
- theCharset
to use to decode the request-target.- Returns:
- The request-target.
-
requestTarget
HttpRequestMetaData requestTarget(java.lang.String requestTarget)
Set the request-target.This will be treated as encoded according to percent-encoding.
This may result in clearing of internal caches used by methods that are derived from the
request-target
, such aspath()
,rawQuery()
, etc.- Parameters:
requestTarget
- the percent-encoded request-target to set.- Returns:
this
.
-
requestTarget
HttpRequestMetaData requestTarget(java.lang.String requestTarget, java.nio.charset.Charset encoding)
Set the request-target.This may result in clearing of internal caches used by methods that are derived from the
request-target
, such aspath()
,rawQuery()
, etc.- Parameters:
requestTarget
- the request-target to set.encoding
- theCharset
to use to encoderequestTarget
before setting the value.- Returns:
this
.
-
scheme
@Nullable java.lang.String scheme()
The scheme component derived fromrequestTarget()
in lower case.- Returns:
- The scheme component derived
from
requestTarget()
in lower case, ornull
if none can be derived.
-
userInfo
@Nullable java.lang.String userInfo()
The user information component derived fromrequestTarget()
.- Returns:
- The user information component derived
from
requestTarget()
, ornull
if none can be derived.
-
host
@Nullable java.lang.String host()
The host component derived fromrequestTarget()
.- Returns:
- The host component derived
from
requestTarget()
, ornull
if none can be derived.
-
port
int port()
The port component derived fromrequestTarget()
.- Returns:
- The port component derived
from
requestTarget()
, or<0
if none can be derived.
-
rawPath
java.lang.String rawPath()
The path component derived fromrequestTarget()
.No decoding has been done on the query component: the value is provided as specified in the request target.
- Returns:
- The path component derived
from
requestTarget()
.No decoding has been done on the query component: the value is provided as specified in the request target.
-
path
java.lang.String path()
Get an equivalent value asrawPath()
but decoded according to percent-encoding.- Returns:
- an equivalent value as
rawPath()
but decoded according to percent-encoding.
-
rawPath
HttpRequestMetaData rawPath(java.lang.String path)
Sets the path topath
, without any encoding performed. This assumes that any characters that require encoding have been encoded according to percent-encoding by the caller.Because this modifies the request target, this may result in the clearing of internal caches. See
requestTarget(String)
.- Parameters:
path
- the encoded path to set.- Returns:
this
.
-
path
HttpRequestMetaData path(java.lang.String path)
Sets the path, performing encoding according to percent-encoding, except for forward-slash ('/'
) characters. This allows forpath("/abc")
without it turning into'%2Fabc'
.- Parameters:
path
- the un-encoded path to set.- Returns:
this
.
-
appendPathSegments
HttpRequestMetaData appendPathSegments(java.lang.String... segments)
Appends segments to the currentpath()
, performing encoding of each segment (including ('/'
) characters) according to percent-encoding. A/
is used to separate each segment and between the currentpath()
and the following segments.- Parameters:
segments
- the un-encoded path to set.- Returns:
this
.
-
rawQuery
@Nullable java.lang.String rawQuery()
The query component derived fromrequestTarget()
.No decoding has been done on the query component: the value is provided as specified in the request target.
- Returns:
- The query component derived
from
requestTarget()
.No decoding has been done on the query component: the value is provided as specified in the request target.
-
query
@Nullable java.lang.String query()
Get an equivalent value asrawQuery()
but decoded according to rfc3986, Query.- Returns:
- an equivalent value as
rawQuery()
but decoded according to rfc3986, Query.
-
rawQuery
HttpRequestMetaData rawQuery(@Nullable java.lang.String query)
Sets the query component toquery
, without any encoding performed. This assumes that any characters that require encoding have been encoded according to percent-encoding by the caller.Because this modifies the request target, this may result in the clearing of internal caches. See
requestTarget(String)
.- Parameters:
query
- the encoded query to set.null
will clear the query value (e.g. no?
present inrequestTarget()
.- Returns:
this
.
-
query
HttpRequestMetaData query(@Nullable java.lang.String query)
Sets the path, performing encoding according to rfc3986, Query.- Parameters:
query
- the un-encoded query to set.null
will clear the query value (e.g. no?
present inrequestTarget()
.- Returns:
this
.
-
queryParameter
@Nullable java.lang.String queryParameter(java.lang.String key)
Returns the value of a query parameter with the specified key. If there is more than one value for the specified key, the first value in insertion order is returned.- Parameters:
key
- the key of the query parameter to retrieve.- Returns:
- the first query parameter value if the key is found.
null
if there's no such key.
-
queryParameters
java.lang.Iterable<java.util.Map.Entry<java.lang.String,java.lang.String>> queryParameters()
Returns all query parameters as key/value pairs.- Returns:
- an
Iterable
of query parameter key/value pairs or an emptyIterable
if none present.
-
queryParameters
java.lang.Iterable<java.lang.String> queryParameters(java.lang.String key)
Returns all values for the query parameter with the specified key.- Parameters:
key
- the key of the query parameter to retrieve.- Returns:
- an
Iterable
of query parameter values or an emptyIterable
if no values are found.
-
queryParametersIterator
java.util.Iterator<java.lang.String> queryParametersIterator(java.lang.String key)
Returns all values for the query parameter with the specified key.- Parameters:
key
- the key of the query parameter to retrieve.- Returns:
- an
Iterator
of query parameter values or an emptyIterator
if no values are found.
-
queryParametersKeys
java.util.Set<java.lang.String> queryParametersKeys()
Returns aSet
of all query parameter keys. The returnedSet
cannot be modified.- Returns:
- a
Set
of all query parameter keys. The returnedSet
cannot be modified.
-
hasQueryParameter
default boolean hasQueryParameter(java.lang.String key)
Returnstrue
if a query parameter with thekey
exists,false
otherwise.- Parameters:
key
- the query parameter name.- Returns:
true
ifkey
exists.
-
hasQueryParameter
boolean hasQueryParameter(java.lang.String key, java.lang.String value)
Returnstrue
if a query parameter with thekey
andvalue
exists,false
otherwise.- Parameters:
key
- the query parameter key.value
- the query parameter value of the query parameter to find.- Returns:
true
if akey
,value
pair exists.
-
queryParametersSize
int queryParametersSize()
Returns the number of query parameters.- Returns:
- the number of query parameters.
-
addQueryParameter
HttpRequestMetaData addQueryParameter(java.lang.String key, java.lang.String value)
Adds a new query parameter with the specifiedkey
andvalue
, which will be percent-encoded if needed.- Parameters:
key
- the query parameter key.value
- the query parameter value.- Returns:
this
.
-
addQueryParameters
HttpRequestMetaData addQueryParameters(java.lang.String key, java.lang.Iterable<java.lang.String> values)
Adds new query parameters with the specifiedkey
andvalues
. This method is semantically equivalent to:for (T value : values) { addQueryParameter(key, value); }
- Parameters:
key
- the query parameter key.values
- the query parameter values.- Returns:
this
.
-
addQueryParameters
HttpRequestMetaData addQueryParameters(java.lang.String key, java.lang.String... values)
Adds new query parameters with the specifiedkey
andvalues
. This method is semantically equivalent to:for (T value : values) { query.addQueryParameter(key, value); }
- Parameters:
key
- the query parameter key.values
- the query parameter values.- Returns:
this
.
-
setQueryParameter
HttpRequestMetaData setQueryParameter(java.lang.String key, java.lang.String value)
Sets a query parameter with the specifiedkey
andvalue
, which will be percent-encoded if needed. Any existing query parameters with the same key are overwritten.- Parameters:
key
- the query parameter key.value
- the query parameter value.- Returns:
this
.
-
setQueryParameters
HttpRequestMetaData setQueryParameters(java.lang.String key, java.lang.Iterable<java.lang.String> values)
Sets new query parameters with the specifiedkey
andvalues
. This method is equivalent to:removeQueryParameter(key); for (T value : values) { query.addQueryParameter(key, value); }
- Parameters:
key
- the query parameter key.values
- the query parameter values.- Returns:
this
.
-
setQueryParameters
HttpRequestMetaData setQueryParameters(java.lang.String key, java.lang.String... values)
Sets new query parameters with the specifiedkey
andvalues
. This method is equivalent to:removeQueryParameter(key); for (T value : values) { query.addQueryParameter(key, value); }
- Parameters:
key
- the query parameter key.values
- the query parameter values.- Returns:
this
.
-
removeQueryParameters
boolean removeQueryParameters(java.lang.String key)
Removes all query parameters with the specifiedkey
.- Parameters:
key
- the query parameter key.- Returns:
true
if at least one entry has been removed.
-
removeQueryParameters
boolean removeQueryParameters(java.lang.String key, java.lang.String value)
Removes all query parameters with the specifiedkey
andvalue
.- Parameters:
key
- the query parameter key.value
- the query parameter value.- Returns:
true
if at least one entry has been removed.
-
effectiveHostAndPort
@Nullable HostAndPort effectiveHostAndPort()
Get the host and port components of the effective request URI. The port component will be<0
if none can be derived. This method typically pulls information fromrequestTarget()
andHttpHeaderNames.HOST
header.- Returns:
- The host and
port components
of the effective request URI.
null
if the request doesn't provide enough info to derive the host/port.
-
version
HttpRequestMetaData version(HttpProtocolVersion version)
Description copied from interface:HttpMetaData
Set the protocol version of thisHttpMetaData
.- Specified by:
version
in interfaceHttpMetaData
- Parameters:
version
- the protocol version to set.- Returns:
this
.
-
addHeader
default HttpRequestMetaData addHeader(java.lang.CharSequence name, java.lang.CharSequence value)
Description copied from interface:HttpMetaData
Adds a new header with the specifiedname
andvalue
.- Specified by:
addHeader
in interfaceHttpMetaData
- Parameters:
name
- the name of the header.value
- the value of the header.- Returns:
this
.
-
addHeaders
default HttpRequestMetaData addHeaders(HttpHeaders headers)
Description copied from interface:HttpMetaData
Adds all header names and values ofheaders
object.- Specified by:
addHeaders
in interfaceHttpMetaData
- Parameters:
headers
- the headers to add.- Returns:
this
.
-
setHeader
default HttpRequestMetaData setHeader(java.lang.CharSequence name, java.lang.CharSequence value)
Description copied from interface:HttpMetaData
Sets a header with the specifiedname
andvalue
. Any existing headers with the same name are overwritten.- Specified by:
setHeader
in interfaceHttpMetaData
- Parameters:
name
- the name of the header.value
- the value of the header.- Returns:
this
.
-
setHeaders
default HttpRequestMetaData setHeaders(HttpHeaders headers)
Description copied from interface:HttpMetaData
Clears the current header entries and copies all header entries of the specifiedheaders
object.- Specified by:
setHeaders
in interfaceHttpMetaData
- Parameters:
headers
- the headers object which contains new values.- Returns:
this
.
-
addCookie
default HttpRequestMetaData addCookie(HttpCookiePair cookie)
Description copied from interface:HttpMetaData
Adds a cookie.This may result in multiple
HttpCookiePair
s with same name.- Specified by:
addCookie
in interfaceHttpMetaData
- Parameters:
cookie
- the cookie to add.- Returns:
this
.
-
addCookie
default HttpRequestMetaData addCookie(java.lang.CharSequence name, java.lang.CharSequence value)
Description copied from interface:HttpMetaData
Adds a cookie with the specifiedname
andvalue
.This may result in multiple
HttpSetCookie
s with same name. Added cookie will not be wrapped, not secure, and not HTTP-only, with no path, domain, expire date and maximum age.- Specified by:
addCookie
in interfaceHttpMetaData
- Parameters:
name
- the name of the cookie.value
- the value of the cookie.- Returns:
this
.
-
addSetCookie
default HttpRequestMetaData addSetCookie(HttpSetCookie cookie)
Description copied from interface:HttpMetaData
Adds a set-cookie.This may result in multiple
HttpSetCookie
s with same name.- Specified by:
addSetCookie
in interfaceHttpMetaData
- Parameters:
cookie
- the cookie to add.- Returns:
this
.
-
addSetCookie
default HttpRequestMetaData addSetCookie(java.lang.CharSequence name, java.lang.CharSequence value)
Description copied from interface:HttpMetaData
Adds a set-cookie with the specifiedname
andvalue
.This may result in multiple
HttpSetCookie
s with same name. Added cookie will not be wrapped, not secure, and not HTTP-only, with no path, domain, expire date and maximum age.- Specified by:
addSetCookie
in interfaceHttpMetaData
- Parameters:
name
- the name of the cookie.value
- the value of the cookie.- Returns:
this
.
-
-