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

public Class ServletServerHttpRequest

extends Object
implements ServerHttpRequest
Class Inheritance
All Implemented Interfaces
org.springframework.http.server.ServerHttpRequest, org.springframework.http.HttpInputMessage, org.springframework.http.HttpMessage, org.springframework.http.HttpRequest
Known Direct Subclasses
org.springframework.web.multipart.support.RequestPartServletServerHttpRequest
Imports
java.io.ByteArrayInputStream, .ByteArrayOutputStream, .IOException, .InputStream, .OutputStreamWriter, .Writer, java.net.InetSocketAddress, .URI, .URISyntaxException, .URLEncoder, java.nio.charset.Charset, .StandardCharsets, java.security.Principal, java.util.Arrays, .Enumeration, .Iterator, .List, .Map, jakarta.servlet.http.HttpServletRequest, org.springframework.http.HttpHeaders, .HttpMethod, .InvalidMediaTypeException, .MediaType, org.springframework.lang.Nullable, org.springframework.util.Assert, .LinkedCaseInsensitiveMap, .StringUtils

ServerHttpRequest implementation that is based on a HttpServletRequest.
Authors
Arjen Poutsma, Rossen Stoyanchev, Juergen Hoeller
Since
3.0

Field Summary

Modifier and TypeField and Description
private ServerHttpAsyncRequestControl
protected static final Charset
private HttpHeaders
private final HttpServletRequest
private URI

Constructor Summary

AccessConstructor and Description
public
ServletServerHttpRequest(HttpServletRequest
the servlet request
servletRequest
)

Construct a new instance of the ServletServerHttpRequest based on the given HttpServletRequest.

Method Summary

Modifier and TypeMethod and Description
public ServerHttpAsyncRequestControl
getAsyncRequestControl(ServerHttpResponse response)

Implements org.springframework.http.server.ServerHttpRequest.getAsyncRequestControl.

Return a control that allows putting the request in asynchronous mode so the response remains open until closed explicitly from the current or another thread.
public InputStream
getBody()

Implements org.springframework.http.HttpInputMessage.getBody.

Return the body of the message as an input stream.
private static InputStream
getBodyFromServletRequestParameters(HttpServletRequest request)

Use jakarta.servlet.ServletRequest#getParameterMap() to reconstruct the body of a form 'POST' providing a predictable outcome as opposed to reading from the body, which can fail if any other code has used the ServletRequest to access a parameter, thus causing the input stream to be "consumed".

public HttpHeaders
getHeaders()

Implements org.springframework.http.HttpMessage.getHeaders.

Return the headers of this message.
public InetSocketAddress
getLocalAddress()

Implements org.springframework.http.server.ServerHttpRequest.getLocalAddress.

Return the address on which the request was received.
public HttpMethod
getMethod()

Implements org.springframework.http.HttpRequest.getMethod.

Return the HTTP method of the request.
public Principal
getPrincipal()

Implements org.springframework.http.server.ServerHttpRequest.getPrincipal.

Return a java.security.Principal instance containing the name of the authenticated user.
public InetSocketAddress
getRemoteAddress()

Implements org.springframework.http.server.ServerHttpRequest.getRemoteAddress.

Return the address of the remote client.
public HttpServletRequest
getServletRequest()

Returns the HttpServletRequest this object is based on.

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).
public static URI

Returns:

the initialized URI
initURI
(HttpServletRequest
the request
servletRequest
)

Initialize a URI from the given Servlet request.

private static boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

asyncRequestControlback to summary
private ServerHttpAsyncRequestControl asyncRequestControl
Annotations
@Nullable
FORM_CHARSETback to summary
protected static final Charset FORM_CHARSET
headersback to summary
private HttpHeaders headers
Annotations
@Nullable
servletRequestback to summary
private final HttpServletRequest servletRequest
uriback to summary
private URI uri
Annotations
@Nullable

Constructor Detail

ServletServerHttpRequestback to summary
public ServletServerHttpRequest(HttpServletRequest servletRequest)

Construct a new instance of the ServletServerHttpRequest based on the given HttpServletRequest.

Parameters
servletRequest:HttpServletRequest

the servlet request

Method Detail

getAsyncRequestControlback to summary
public ServerHttpAsyncRequestControl getAsyncRequestControl(ServerHttpResponse response)

Implements org.springframework.http.server.ServerHttpRequest.getAsyncRequestControl.

Doc from org.springframework.http.server.ServerHttpRequest.getAsyncRequestControl.

Return a control that allows putting the request in asynchronous mode so the response remains open until closed explicitly from the current or another thread.

Annotations
@Override
getBodyback to summary
public InputStream getBody() throws IOException

Implements org.springframework.http.HttpInputMessage.getBody.

Doc from org.springframework.http.HttpInputMessage.getBody.

Return the body of the message as an input stream.

Returns:InputStream

the input stream body (never null)

Annotations
@Override
Exceptions
IOException:
in case of I/O errors
getBodyFromServletRequestParametersback to summary
private static InputStream getBodyFromServletRequestParameters(HttpServletRequest request) throws IOException

Use jakarta.servlet.ServletRequest#getParameterMap() to reconstruct the body of a form 'POST' providing a predictable outcome as opposed to reading from the body, which can fail if any other code has used the ServletRequest to access a parameter, thus causing the input stream to be "consumed".

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
getLocalAddressback to summary
public InetSocketAddress getLocalAddress()

Implements org.springframework.http.server.ServerHttpRequest.getLocalAddress.

Doc from org.springframework.http.server.ServerHttpRequest.getLocalAddress.

Return the address on which the request was received.

Annotations
@Override
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
getPrincipalback to summary
public Principal getPrincipal()

Implements org.springframework.http.server.ServerHttpRequest.getPrincipal.

Doc from org.springframework.http.server.ServerHttpRequest.getPrincipal.

Return a java.security.Principal instance containing the name of the authenticated user.

If the user has not been authenticated, the method returns null.

Annotations
@Override
getRemoteAddressback to summary
public InetSocketAddress getRemoteAddress()

Implements org.springframework.http.server.ServerHttpRequest.getRemoteAddress.

Doc from org.springframework.http.server.ServerHttpRequest.getRemoteAddress.

Return the address of the remote client.

Annotations
@Override
getServletRequestback to summary
public HttpServletRequest getServletRequest()

Returns the HttpServletRequest this object is based on.

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
initURIback to summary
public static URI initURI(HttpServletRequest servletRequest)

Initialize a URI from the given Servlet request.

Parameters
servletRequest:HttpServletRequest

the request

Returns:URI

the initialized URI

Since
6.1
isFormPostback to summary
private static boolean isFormPost(HttpServletRequest request)