APIdia Launch Partner
Top Description Methods
com.sun.net.httpserver

public Interface Request

Known Direct Implementers
com.sun.net.httpserver.HttpExchange
Imports
java.net.URI, java.util.List, .Objects

A view of the immutable request state of an HTTP exchange.
Since
18

Method Summary

Modifier and TypeMethod and Description
public Headers

Returns:

a read-only Headers which can be used to access request headers.
getRequestHeaders
()

Returns an immutable Headers containing the HTTP headers that were included with this request.

public String

Returns:

the request method string
getRequestMethod
()

Returns the request method.

public URI

Returns:

the request URI
getRequestURI
()

Returns the request URI.

public default Request

Returns:

a request
with
(String
the header name
headerName
,
List<String>
the list of header values
headerValues
)

Returns an identical Request with an additional header.

Method Detail

getRequestHeadersback to summary
public Headers getRequestHeaders()

Returns an immutable Headers containing the HTTP headers that were included with this request.

The keys in this Headers are the header names, while the values are a java.util.List 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:Headers

a read-only Headers which can be used to access request headers.

getRequestMethodback to summary
public String getRequestMethod()

Returns the request method.

Returns:String

the request method string

getRequestURIback to summary
public URI getRequestURI()

Returns the request URI.

Returns:URI

the request URI

withback to summary
public default Request with(String headerName, List<String> headerValues)

Returns an identical Request with an additional header.

The returned Request has the same set of headers as this 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 given headerName, then its value is not replaced.

Implementation Specification

The default implementation first creates a new Headers, h, then adds all the request headers from this request to h, then adds the given name-values mapping if headerName is not present in h. Then an unmodifiable view, h', of h and a new Request, r, are created. The getRequestMethod and getRequestURI methods of r simply invoke the equivalently named method of this request. The getRequestHeaders method returns h'. Lastly, r is returned.

Parameters
headerName:String

the header name

headerValues:List<String>

the list of header values

Returns:Request

a request

Exceptions
NullPointerException:
if any argument is null, or if any element of headerValues is null.