Top Description Inners Methods
org.springframework.http.server.reactive

public Interface ServerHttpRequest

extends HttpRequest, ReactiveHttpInputMessage
Known Direct Implementers
org.springframework.http.server.reactive.ServerHttpRequestDecorator, org.springframework.http.server.reactive.AbstractServerHttpRequest
Imports
java.net.InetSocketAddress, .URI, java.util.function.Consumer, org.springframework.http.HttpCookie, .HttpHeaders, .HttpMethod, .HttpRequest, .ReactiveHttpInputMessage, org.springframework.http.server.RequestPath, org.springframework.lang.Nullable, org.springframework.util.MultiValueMap

Represents a reactive server-side HTTP request.
Authors
Arjen Poutsma, Rossen Stoyanchev, Sam Brannen
Since
5.0

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static interface
ServerHttpRequest.Builder

Builder for mutating an existing ServerHttpRequest.

Method Summary

Modifier and TypeMethod and Description
public MultiValueMap<String, HttpCookie>
getCookies()

Return a read-only map of cookies sent by the client.

public String
getId()

Return an id that represents the underlying connection, if available, or the request for the purpose of correlating log messages.

public default InetSocketAddress
getLocalAddress()

Return the local address the request was accepted on, if available.

public RequestPath
getPath()

Returns a structured representation of the full request path up to but not including the query.

public MultiValueMap<String, String>
getQueryParams()

Return a read-only map with parsed and decoded query parameter values.

public default InetSocketAddress
getRemoteAddress()

Return the remote address where this request is connected to, if available.

public default SslInfo

Returns:

the session information, or null if none available
getSslInfo
()

Return the SSL session information if the request has been transmitted over a secure protocol including SSL certificates, if available.

public default ServerHttpRequest.Builder
mutate()

Return a builder to mutate properties of this request by wrapping it with ServerHttpRequestDecorator and returning either mutated values or delegating back to this instance.

Inherited from org.springframework.http.HttpRequest:
getMethodgetURI
Inherited from org.springframework.http.ReactiveHttpInputMessage:
getBody

Method Detail

getCookiesback to summary
public MultiValueMap<String, HttpCookie> getCookies()

Return a read-only map of cookies sent by the client.

getIdback to summary
public String getId()

Return an id that represents the underlying connection, if available, or the request for the purpose of correlating log messages.

Since
5.1
See Also
org.springframework.web.server.ServerWebExchange#getLogPrefix()
getLocalAddressback to summary
public default InetSocketAddress getLocalAddress()

Return the local address the request was accepted on, if available.

Annotations
@Nullable
Since
5.2.3
getPathback to summary
public RequestPath getPath()

Returns a structured representation of the full request path up to but not including the query.

The returned path is subdivided into a RequestPath#contextPath() portion and the remaining pathWithinApplication portion. The latter can be passed into methods of org.springframework.web.util.pattern.PathPattern for path matching purposes.

getQueryParamsback to summary
public MultiValueMap<String, String> getQueryParams()

Return a read-only map with parsed and decoded query parameter values.

getRemoteAddressback to summary
public default InetSocketAddress getRemoteAddress()

Return the remote address where this request is connected to, if available.

Annotations
@Nullable
getSslInfoback to summary
public default SslInfo getSslInfo()

Return the SSL session information if the request has been transmitted over a secure protocol including SSL certificates, if available.

Returns:SslInfo

the session information, or null if none available

Annotations
@Nullable
Since
5.0.2
mutateback to summary
public default ServerHttpRequest.Builder mutate()

Return a builder to mutate properties of this request by wrapping it with ServerHttpRequestDecorator and returning either mutated values or delegating back to this instance.

org.springframework.http.server.reactive back to summary

public Interface ServerHttpRequest.Builder

Known Direct Implementers
org.springframework.http.server.reactive.DefaultServerHttpRequestBuilder

Builder for mutating an existing ServerHttpRequest.

Method Summary

Modifier and TypeMethod and Description
public ServerHttpRequest
build()

Build a ServerHttpRequest decorator with the mutated properties.

public ServerHttpRequest.Builder
contextPath(String contextPath)

Set the contextPath to use.

public ServerHttpRequest.Builder
header(String
the header name
headerName
,
String...
the header values
headerValues
)

Set or override the specified header values under the given name.

public ServerHttpRequest.Builder
headers(Consumer<HttpHeaders> headersConsumer)

Manipulate request headers.

public ServerHttpRequest.Builder
method(HttpMethod httpMethod)

Set the HTTP method to return.

public ServerHttpRequest.Builder
path(String path)

Set the path to use instead of the "rawPath" of the URI of the request with the following conditions:

  • If uri is also set, the path given here overrides the path of the given URI.
  • If contextPath is also set, or already present, it must match the start of the path given here.
  • The given value must begin with a slash.
public ServerHttpRequest.Builder
remoteAddress(InetSocketAddress remoteAddress)

Set the address of the remote client.

public ServerHttpRequest.Builder
sslInfo(SslInfo sslInfo)

Set the SSL session information.

public ServerHttpRequest.Builder
uri(URI uri)

Set the URI to use with the following conditions:

  • If path is also set, it overrides the path of the URI provided here.
  • If contextPath is also set, or already present, it must match the start of the path of the URI provided here.

Method Detail

buildback to summary
public ServerHttpRequest build()

Build a ServerHttpRequest decorator with the mutated properties.

contextPathback to summary
public ServerHttpRequest.Builder contextPath(String contextPath)

Set the contextPath to use.

The given value must be a valid contextPath and it must match the start of the path of the URI of the request. That means changing the contextPath, implies also changing the path via path(String).

headerback to summary
public ServerHttpRequest.Builder header(String headerName, String... headerValues)

Set or override the specified header values under the given name.

If you need to add header values, remove headers, etc., use headers(Consumer) for greater control.

Parameters
headerName:String

the header name

headerValues:String[]

the header values

Since
5.1.9
See Also
headers(Consumer)
headersback to summary
public ServerHttpRequest.Builder headers(Consumer<HttpHeaders> headersConsumer)

Manipulate request headers. The provided HttpHeaders contains current request headers, so that the Consumer can overwrite or remove existing values, or use any other HttpHeaders methods.

See Also
header(String, String...)
methodback to summary
public ServerHttpRequest.Builder method(HttpMethod httpMethod)

Set the HTTP method to return.

pathback to summary
public ServerHttpRequest.Builder path(String path)

Set the path to use instead of the "rawPath" of the URI of the request with the following conditions:

  • If uri is also set, the path given here overrides the path of the given URI.
  • If contextPath is also set, or already present, it must match the start of the path given here.
  • The given value must begin with a slash.
remoteAddressback to summary
public ServerHttpRequest.Builder remoteAddress(InetSocketAddress remoteAddress)

Set the address of the remote client.

Since
5.3
sslInfoback to summary
public ServerHttpRequest.Builder sslInfo(SslInfo sslInfo)

Set the SSL session information. This may be useful in environments where TLS termination is done at the router, but SSL information is made available in some other way such as through a header.

Since
5.0.7
uriback to summary
public ServerHttpRequest.Builder uri(URI uri)

Set the URI to use with the following conditions:

  • If path is also set, it overrides the path of the URI provided here.
  • If contextPath is also set, or already present, it must match the start of the path of the URI provided here.