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 for ServerHttpRequest implementations.
Since:
5.0
Author:
Rossen Stoyanchev
  • Constructor Details

    • AbstractServerHttpRequest

      public AbstractServerHttpRequest(HttpMethod method, URI uri, @Nullable String contextPath, MultiValueMap<String,String> headers)
      Constructor with the method, URI and headers for the request.
      Parameters:
      method - the HTTP method for the request
      uri - the URI for the request
      contextPath - the context path for the request
      headers - the headers for the request (as MultiValueMap)
      Since:
      6.0.8
  • Method Details

    • 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 interface ServerHttpRequest
      See Also:
    • initId

      @Nullable protected String initId()
      Obtain the request id to use, or null in which case the Object identity of this request instance is used.
      Since:
      5.1
    • getMethod

      public HttpMethod getMethod()
      Description copied from interface: HttpRequest
      Return the HTTP method of the request.
      Specified by:
      getMethod in interface HttpRequest
      Returns:
      the HTTP method as an HttpMethod value
      See Also:
    • 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 interface HttpRequest
      Returns:
      the URI of the request (never null)
    • getPath

      public RequestPath getPath()
      Description copied from interface: ServerHttpRequest
      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 PathPattern for path matching purposes.

      Specified by:
      getPath in interface ServerHttpRequest
    • getHeaders

      public HttpHeaders getHeaders()
      Description copied from interface: HttpMessage
      Return the headers of this message.
      Specified by:
      getHeaders in interface HttpMessage
      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 interface ServerHttpRequest
    • 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 interface ServerHttpRequest
    • initCookies

      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.

    • 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 interface ServerHttpRequest
      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.

    • initLogPrefix

      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