Class AbstractServerHttpRequest
- java.lang.Object
- org.springframework.http.server.reactive.AbstractServerHttpRequest
- All Implemented Interfaces:
HttpMessage
,HttpRequest
,ReactiveHttpInputMessage
,ServerHttpRequest
- Direct Known Subclasses:
MockServerHttpRequest
public abstract class AbstractServerHttpRequest extends Object implements ServerHttpRequest
Common base class forServerHttpRequest
implementations.- Since:
- 5.0
- Author:
- Rossen Stoyanchev
Nested Class Summary
Nested classes/interfaces inherited from interface org.springframework.http.server.reactive.ServerHttpRequest
ServerHttpRequest.Builder
Constructor Summary
Constructors Constructor Description AbstractServerHttpRequest(URI uri, String contextPath, HttpHeaders headers)
Constructor with the URI and headers for the request.
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description MultiValueMap<String,HttpCookie>
getCookies()
Return a read-only map of cookies sent by the client.HttpHeaders
getHeaders()
Return the headers of this message.String
getId()
Return an id that represents the underlying connection, if available, or the request for the purpose of correlating log messages.abstract <T> T
getNativeRequest()
Return the underlying server response.RequestPath
getPath()
Returns a structured representation of the request path including the context path + path within application portions, path segments with encoded and decoded values, and path parameters.MultiValueMap<String,String>
getQueryParams()
Return a read-only map with parsed and decoded query parameter values.SslInfo
getSslInfo()
Return the SSL session information if the request has been transmitted over a secure protocol including SSL certificates, if available.URI
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 anHttpCookie
map.protected String
initId()
Obtain the request id to use, ornull
in which case the Object identity of this request instance is used.protected MultiValueMap<String,String>
initQueryParams()
A method for parsing of the query into name-value pairs.protected abstract SslInfo
initSslInfo()
Obtain SSL session information from the underlying "native" request.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.http.HttpRequest
getMethod, getMethodValue
Methods inherited from interface org.springframework.http.ReactiveHttpInputMessage
getBody
Methods inherited from interface org.springframework.http.server.reactive.ServerHttpRequest
getLocalAddress, getRemoteAddress, mutate
Constructor Detail
AbstractServerHttpRequest
public AbstractServerHttpRequest(URI uri, @Nullable String contextPath, HttpHeaders headers)
Constructor with the URI and headers for the request.- Parameters:
uri
- the URI for the requestcontextPath
- the context path for the requestheaders
- the headers for the request
Method Detail
getId
public String getId()
Description copied from interface:ServerHttpRequest
Return an id that represents the underlying connection, if available, or the request for the purpose of correlating log messages.- Specified by:
getId
in interfaceServerHttpRequest
- See Also:
ServerWebExchange.getLogPrefix()
initId
@Nullable protected String initId()
Obtain the request id to use, ornull
in which case the Object identity of this request instance is used.- Since:
- 5.1
getURI
public URI getURI()
Description copied from interface:HttpRequest
Return the URI of the request (including a query string if any, but only if it is well-formed for a URI representation).- Specified by:
getURI
in interfaceHttpRequest
- Returns:
- the URI of the request (never
null
)
getPath
public RequestPath getPath()
Description copied from interface:ServerHttpRequest
Returns a structured representation of the request path including the context path + path within application portions, path segments with encoded and decoded values, and path parameters.- Specified by:
getPath
in interfaceServerHttpRequest
getHeaders
public HttpHeaders getHeaders()
Description copied from interface:HttpMessage
Return the headers of this message.- Specified by:
getHeaders
in interfaceHttpMessage
- Returns:
- a corresponding HttpHeaders object (never
null
)
getQueryParams
public MultiValueMap<String,String> getQueryParams()
Description copied from interface:ServerHttpRequest
Return a read-only map with parsed and decoded query parameter values.- Specified by:
getQueryParams
in interfaceServerHttpRequest
initQueryParams
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.
getCookies
public MultiValueMap<String,HttpCookie> getCookies()
Description copied from interface:ServerHttpRequest
Return a read-only map of cookies sent by the client.- Specified by:
getCookies
in interfaceServerHttpRequest
initCookies
protected abstract MultiValueMap<String,HttpCookie> initCookies()
Obtain the cookies from the underlying "native" request and adapt those to anHttpCookie
map. The return value is turned into an immutable map and cached.Note that this method is invoked lazily on access to
getCookies()
. Sub-classes should synchronize cookie initialization if the underlying "native" request does not provide thread-safe access to cookie data.
getSslInfo
@Nullable public SslInfo getSslInfo()
Description copied from interface:ServerHttpRequest
Return the SSL session information if the request has been transmitted over a secure protocol including SSL certificates, if available.- Specified by:
getSslInfo
in interfaceServerHttpRequest
- Returns:
- the session information, or
null
if none available
initSslInfo
@Nullable protected abstract SslInfo initSslInfo()
Obtain SSL session information from the underlying "native" request.- Returns:
- the session information, or
null
if none available - Since:
- 5.0.2
getNativeRequest
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.