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 HttpRequestMetaDataaddCookie(HttpCookiePair cookie)Adds a cookie.default HttpRequestMetaDataaddCookie(java.lang.CharSequence name, java.lang.CharSequence value)default HttpRequestMetaDataaddHeader(java.lang.CharSequence name, java.lang.CharSequence value)Adds a new header with the specifiednameandvalue.default HttpRequestMetaDataaddHeaders(HttpHeaders headers)Adds all header names and values ofheadersobject.HttpRequestMetaDataaddQueryParameter(java.lang.String key, java.lang.String value)Adds a new query parameter with the specifiedkeyandvalue, which will be percent-encoded if needed.HttpRequestMetaDataaddQueryParameters(java.lang.String key, java.lang.Iterable<java.lang.String> values)Adds new query parameters with the specifiedkeyandvalues.HttpRequestMetaDataaddQueryParameters(java.lang.String key, java.lang.String... values)Adds new query parameters with the specifiedkeyandvalues.default HttpRequestMetaDataaddSetCookie(HttpSetCookie cookie)Adds a set-cookie.default HttpRequestMetaDataaddSetCookie(java.lang.CharSequence name, java.lang.CharSequence value)HttpRequestMetaDataappendPathSegments(java.lang.String... segments)Appends segments to the currentpath(), performing encoding of each segment (including ('/') characters) according to percent-encoding.HostAndPorteffectiveHostAndPort()default booleanhasQueryParameter(java.lang.String key)Returnstrueif a query parameter with thekeyexists,falseotherwise.booleanhasQueryParameter(java.lang.String key, java.lang.String value)Returnstrueif a query parameter with thekeyandvalueexists,falseotherwise.java.lang.Stringhost()The host component derived fromrequestTarget().HttpRequestMethodmethod()Returns theHttpRequestMethodof thisStreamingHttpRequest.HttpRequestMetaDatamethod(HttpRequestMethod method)Set theHttpRequestMethodof thisStreamingHttpRequest.java.lang.Stringpath()Get an equivalent value asrawPath()but decoded according to percent-encoding.HttpRequestMetaDatapath(java.lang.String path)Sets the path, performing encoding according to percent-encoding, except for forward-slash ('/') characters.intport()The port component derived fromrequestTarget().java.lang.Stringquery()Get an equivalent value asrawQuery()but decoded according to rfc3986, Query.HttpRequestMetaDataquery(java.lang.String query)Sets the path, performing encoding according to rfc3986, Query.java.lang.StringqueryParameter(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 aSetof all query parameter keys.intqueryParametersSize()Returns the number of query parameters.java.lang.StringrawPath()The path component derived fromrequestTarget().HttpRequestMetaDatarawPath(java.lang.String path)Sets the path topath, without any encoding performed.java.lang.StringrawQuery()The query component derived fromrequestTarget().HttpRequestMetaDatarawQuery(java.lang.String query)Sets the query component toquery, without any encoding performed.booleanremoveQueryParameters(java.lang.String key)Removes all query parameters with the specifiedkey.booleanremoveQueryParameters(java.lang.String key, java.lang.String value)Removes all query parameters with the specifiedkeyandvalue.java.lang.StringrequestTarget()The request-target.HttpRequestMetaDatarequestTarget(java.lang.String requestTarget)Set the request-target.HttpRequestMetaDatarequestTarget(java.lang.String requestTarget, java.nio.charset.Charset encoding)Set the request-target.java.lang.StringrequestTarget(java.nio.charset.Charset encoding)The request-target.java.lang.Stringscheme()The scheme component derived fromrequestTarget()in lower case.default HttpRequestMetaDatasetHeader(java.lang.CharSequence name, java.lang.CharSequence value)Sets a header with the specifiednameandvalue.default HttpRequestMetaDatasetHeaders(HttpHeaders headers)Clears the current header entries and copies all header entries of the specifiedheadersobject.HttpRequestMetaDatasetQueryParameter(java.lang.String key, java.lang.String value)HttpRequestMetaDatasetQueryParameters(java.lang.String key, java.lang.Iterable<java.lang.String> values)Sets new query parameters with the specifiedkeyandvalues.HttpRequestMetaDatasetQueryParameters(java.lang.String key, java.lang.String... values)Sets new query parameters with the specifiedkeyandvalues.java.lang.StringuserInfo()The user information component derived fromrequestTarget().HttpRequestMetaDataversion(HttpProtocolVersion version)Set the protocol version of thisHttpMetaData.
-
-
-
Method Detail
-
method
HttpRequestMethod method()
Returns theHttpRequestMethodof thisStreamingHttpRequest.- Returns:
- The
HttpRequestMethodof thisStreamingHttpRequest
-
method
HttpRequestMetaData method(HttpRequestMethod method)
Set theHttpRequestMethodof thisStreamingHttpRequest.- Parameters:
method- theHttpRequestMethodto 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- theCharsetto 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- theCharsetto use to encoderequestTargetbefore 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, ornullif none can be derived.
-
userInfo
@Nullable java.lang.String userInfo()
The user information component derived fromrequestTarget().- Returns:
- The user information component derived
from
requestTarget(), ornullif none can be derived.
-
host
@Nullable java.lang.String host()
The host component derived fromrequestTarget().- Returns:
- The host component derived
from
requestTarget(), ornullif none can be derived.
-
port
int port()
The port component derived fromrequestTarget().- Returns:
- The port component derived
from
requestTarget(), or<0if 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.nullwill 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.nullwill 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.
nullif 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
Iterableof query parameter key/value pairs or an emptyIterableif 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
Iterableof query parameter values or an emptyIterableif 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
Iteratorof query parameter values or an emptyIteratorif no values are found.
-
queryParametersKeys
java.util.Set<java.lang.String> queryParametersKeys()
Returns aSetof all query parameter keys. The returnedSetcannot be modified.- Returns:
- a
Setof all query parameter keys. The returnedSetcannot be modified.
-
hasQueryParameter
default boolean hasQueryParameter(java.lang.String key)
Returnstrueif a query parameter with thekeyexists,falseotherwise.- Parameters:
key- the query parameter name.- Returns:
trueifkeyexists.
-
hasQueryParameter
boolean hasQueryParameter(java.lang.String key, java.lang.String value)Returnstrueif a query parameter with thekeyandvalueexists,falseotherwise.- Parameters:
key- the query parameter key.value- the query parameter value of the query parameter to find.- Returns:
trueif akey,valuepair 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 specifiedkeyandvalue, 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 specifiedkeyandvalues. 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 specifiedkeyandvalues. 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 specifiedkeyandvalue, 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 specifiedkeyandvalues. 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 specifiedkeyandvalues. 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:
trueif at least one entry has been removed.
-
removeQueryParameters
boolean removeQueryParameters(java.lang.String key, java.lang.String value)Removes all query parameters with the specifiedkeyandvalue.- Parameters:
key- the query parameter key.value- the query parameter value.- Returns:
trueif 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<0if none can be derived. This method typically pulls information fromrequestTarget()andHttpHeaderNames.HOSTheader.- Returns:
- The host and
port components
of the effective request URI.
nullif the request doesn't provide enough info to derive the host/port.
-
version
HttpRequestMetaData version(HttpProtocolVersion version)
Description copied from interface:HttpMetaDataSet the protocol version of thisHttpMetaData.- Specified by:
versionin 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:HttpMetaDataAdds a new header with the specifiednameandvalue.- Specified by:
addHeaderin 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:HttpMetaDataAdds all header names and values ofheadersobject.- Specified by:
addHeadersin 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:HttpMetaDataSets a header with the specifiednameandvalue. Any existing headers with the same name are overwritten.- Specified by:
setHeaderin 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:HttpMetaDataClears the current header entries and copies all header entries of the specifiedheadersobject.- Specified by:
setHeadersin interfaceHttpMetaData- Parameters:
headers- the headers object which contains new values.- Returns:
this.
-
addCookie
default HttpRequestMetaData addCookie(HttpCookiePair cookie)
Description copied from interface:HttpMetaDataAdds a cookie.This may result in multiple
HttpCookiePairs with same name.- Specified by:
addCookiein 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:HttpMetaDataAdds a cookie with the specifiednameandvalue.This may result in multiple
HttpSetCookies 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:
addCookiein 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:HttpMetaDataAdds a set-cookie.This may result in multiple
HttpSetCookies with same name.- Specified by:
addSetCookiein 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:HttpMetaDataAdds a set-cookie with the specifiednameandvalue.This may result in multiple
HttpSetCookies 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:
addSetCookiein interfaceHttpMetaData- Parameters:
name- the name of the cookie.value- the value of the cookie.- Returns:
this.
-
-