Top Description Fields Constructors Methods
org.springframework.http.server.reactive

public abstract Class AbstractServerHttpRequest

extends Object
implements ServerHttpRequest
Class Inheritance
All Implemented Interfaces
org.springframework.http.server.reactive.ServerHttpRequest, org.springframework.http.ReactiveHttpInputMessage, org.springframework.http.HttpMessage, org.springframework.http.HttpRequest
Known Direct Subclasses
org.springframework.http.server.reactive.DefaultServerHttpRequestBuilder.MutatedServerHttpRequest, org.springframework.http.server.reactive.ReactorServerHttpRequest, org.springframework.http.server.reactive.ServletServerHttpRequest, org.springframework.http.server.reactive.UndertowServerHttpRequest, org.springframework.http.server.reactive.ReactorNetty2ServerHttpRequest
Imports
java.net.URI, .URLDecoder, java.nio.charset.StandardCharsets, java.util.regex.Matcher, .Pattern, org.springframework.http.HttpCookie, .HttpHeaders, .HttpMethod, org.springframework.http.server.RequestPath, org.springframework.lang.Nullable, org.springframework.util.Assert, .CollectionUtils, .LinkedMultiValueMap, .MultiValueMap, .ObjectUtils, .StringUtils

Common base class for ServerHttpRequest implementations.
Author
Rossen Stoyanchev
Since
5.0

Field Summary

Modifier and TypeField and Description
private MultiValueMap<String, HttpCookie>
private final HttpHeaders
private String
private String
private final HttpMethod
private final RequestPath
private static final Pattern
private MultiValueMap<String, String>
private SslInfo
private final URI

Constructor Summary

AccessConstructor and Description
public
AbstractServerHttpRequest(HttpMethod
the HTTP method for the request
method
,
URI
the URI for the request
uri
,
String
the context path for the request
contextPath
,
MultiValueMap<String, String>
the headers for the request (as MultiValueMap)
headers
)

Constructor with the method, URI and headers for the request.

Method Summary

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

Implements org.springframework.http.server.reactive.ServerHttpRequest.getCookies.

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

public HttpHeaders
getHeaders()

Implements org.springframework.http.HttpMessage.getHeaders.

Return the headers of this message.

public String
getId()

Implements org.springframework.http.server.reactive.ServerHttpRequest.getId.

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

pack-priv String
getLogPrefix()

For internal use in logging at the HTTP adapter layer.

public HttpMethod
getMethod()

Implements org.springframework.http.HttpRequest.getMethod.

Return the HTTP method of the request.

public abstract <T> T
getNativeRequest()

Return the underlying server response.

public RequestPath
getPath()

Implements org.springframework.http.server.reactive.ServerHttpRequest.getPath.

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

public MultiValueMap<String, String>
getQueryParams()

Implements org.springframework.http.server.reactive.ServerHttpRequest.getQueryParams.

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

public SslInfo
getSslInfo()

Overrides default org.springframework.http.server.reactive.ServerHttpRequest.getSslInfo.

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

public URI
getURI()

Implements org.springframework.http.HttpRequest.getURI.

Return the URI of the request (including a query string if any, but only if it is well-formed for a URI representation).

protected abstract MultiValueMap<String, HttpCookie>
initCookies()

Obtain the cookies from the underlying "native" request and adapt those to an HttpCookie map.

protected String
initId()

Obtain the request id to use, or null in which case the Object identity of this request instance is used.

protected String
initLogPrefix()

Subclasses can override this to provide the prefix to use for log messages.

protected MultiValueMap<String, String>
initQueryParams()

A method for parsing of the query into name-value pairs.

protected abstract SslInfo

Returns:

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

Obtain SSL session information from the underlying "native" request.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cookiesback to summary
private MultiValueMap<String, HttpCookie> cookies
Annotations
@Nullable
headersback to summary
private final HttpHeaders headers
idback to summary
private String id
Annotations
@Nullable
logPrefixback to summary
private String logPrefix
Annotations
@Nullable
methodback to summary
private final HttpMethod method
pathback to summary
private final RequestPath path
QUERY_PATTERNback to summary
private static final Pattern QUERY_PATTERN
queryParamsback to summary
private MultiValueMap<String, String> queryParams
Annotations
@Nullable
sslInfoback to summary
private SslInfo sslInfo
Annotations
@Nullable
uriback to summary
private final URI uri

Constructor Detail

AbstractServerHttpRequestback to summary
public AbstractServerHttpRequest(HttpMethod method, URI uri, String contextPath, MultiValueMap<String, String> headers)

Constructor with the method, URI and headers for the request.

Parameters
method:HttpMethod

the HTTP method for the request

uri:URI

the URI for the request

contextPath:String

the context path for the request

headers:MultiValueMap<String, String>

the headers for the request (as MultiValueMap)

Since
6.0.8

Method Detail

decodeQueryParamback to summary
private String decodeQueryParam(String value)
getCookiesback to summary
public MultiValueMap<String, HttpCookie> getCookies()

Implements org.springframework.http.server.reactive.ServerHttpRequest.getCookies.

Doc from org.springframework.http.server.reactive.ServerHttpRequest.getCookies.

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

Annotations
@Override
getHeadersback to summary
public HttpHeaders getHeaders()

Implements org.springframework.http.HttpMessage.getHeaders.

Doc from org.springframework.http.HttpMessage.getHeaders.

Return the headers of this message.

Returns:HttpHeaders

a corresponding HttpHeaders object (never null)

Annotations
@Override
getIdback to summary
public String getId()

Implements org.springframework.http.server.reactive.ServerHttpRequest.getId.

Doc from org.springframework.http.server.reactive.ServerHttpRequest.getId.

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

Annotations
@Override
getLogPrefixback to summary
pack-priv String getLogPrefix()

For internal use in logging at the HTTP adapter layer.

Since
5.1
getMethodback to summary
public HttpMethod getMethod()

Implements org.springframework.http.HttpRequest.getMethod.

Doc from org.springframework.http.HttpRequest.getMethod.

Return the HTTP method of the request.

Returns:HttpMethod

the HTTP method as an HttpMethod value

Annotations
@Override
getNativeRequestback to summary
public abstract <T> T getNativeRequest()

Return the underlying server response.

Note

This is exposed mainly for internal framework use such as WebSocket upgrades in the spring-webflux module.

getPathback to summary
public RequestPath getPath()

Implements org.springframework.http.server.reactive.ServerHttpRequest.getPath.

Doc from org.springframework.http.server.reactive.ServerHttpRequest.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.

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

Implements org.springframework.http.server.reactive.ServerHttpRequest.getQueryParams.

Doc from org.springframework.http.server.reactive.ServerHttpRequest.getQueryParams.

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

Annotations
@Override
getSslInfoback to summary
public SslInfo getSslInfo()

Overrides default org.springframework.http.server.reactive.ServerHttpRequest.getSslInfo.

Doc from org.springframework.http.server.reactive.ServerHttpRequest.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
@Override
getURIback to summary
public URI getURI()

Implements org.springframework.http.HttpRequest.getURI.

Doc from org.springframework.http.HttpRequest.getURI.

Return the URI of the request (including a query string if any, but only if it is well-formed for a URI representation).

Returns:URI

the URI of the request (never null)

Annotations
@Override
initCookiesback to summary
protected abstract MultiValueMap<String, HttpCookie> initCookies()

Obtain the cookies from the underlying "native" request and adapt those to an HttpCookie map. The return value is turned into an immutable map and cached.

Note that this method is invoked lazily on access to getCookies(). Subclasses should synchronize cookie initialization if the underlying "native" request does not provide thread-safe access to cookie data.

initIdback to summary
protected String initId()

Obtain the request id to use, or null in which case the Object identity of this request instance is used.

Annotations
@Nullable
Since
5.1
initLogPrefixback to summary
protected String initLogPrefix()

Subclasses can override this to provide the prefix to use for log messages.

By default, this is getId().

Since
5.3.15
initQueryParamsback to summary
protected MultiValueMap<String, String> initQueryParams()

A method for parsing of the query into name-value pairs. The return value is turned into an immutable map and cached.

Note that this method is invoked lazily on first access to getQueryParams(). The invocation is not synchronized but the parsing is thread-safe nevertheless.

initSslInfoback to summary
protected abstract SslInfo initSslInfo()

Obtain SSL session information from the underlying "native" request.

Returns:SslInfo

the session information, or null if none available

Annotations
@Nullable
Since
5.0.2