- All Known Implementing Classes:
HttpExchange
,HttpsExchange
public interface Request
A view of the immutable request state of an HTTP exchange.
- Since:
- 18
-
Method Details
-
getRequestURI
URI getRequestURI()Returns the requestURI
.- Returns:
- the request
URI
-
getRequestMethod
String getRequestMethod()Returns the request method.- Returns:
- the request method string
-
getRequestHeaders
Headers getRequestHeaders()Returns an immutableHeaders
containing the HTTP headers that were included with this request.The keys in this
Headers
are the header names, while the values are aList
of Strings containing each value that was included in the request, in the order they were included. Header fields appearing multiple times are represented as multiple string values.The keys in
Headers
are case-insensitive.- Returns:
- a read-only
Headers
which can be used to access request headers.
-
with
Returns an identicalRequest
with an additional header.The returned
Request
has the same set ofheaders
asthis
request, but with the addition of the given header. All other request state remains unchanged.If
this
request already contains a header with the same name as the givenheaderName
, then its value is not replaced.- Implementation Requirements:
- The default implementation first creates a new
Headers
,h
, then adds all the request headers fromthis
request toh
, then adds the given name-values mapping ifheaderName
is not present inh
. Then an unmodifiable view,h'
, ofh
and a newRequest
,r
, are created. ThegetRequestMethod
andgetRequestURI
methods ofr
simply invoke the equivalently named method ofthis
request. ThegetRequestHeaders
method returnsh'
. Lastly,r
is returned. - Parameters:
headerName
- the header nameheaderValues
- the list of header values- Returns:
- a request
- Throws:
NullPointerException
- if any argument is null, or if any element of headerValues is null.
-