Package org.springframework.http.server

# Class ServletServerHttpRequest

java.lang.Object
org.springframework.http.server.ServletServerHttpRequest

All Implemented Interfaces:
  `HttpInputMessage`, `HttpMessage`, `HttpRequest`, `ServerHttpRequest`

Direct Known Subclasses:
  `RequestPartServletServerHttpRequest`

public class ServletServerHttpRequest extends Object implements ServerHttpRequest
`ServerHttpRequest` implementation that is based on a `HttpServletRequest`.

Since:
  3.0
Author:
  Arjen Poutsma, Rossen Stoyanchev, Juergen Hoeller

## Field Summary

Fields
Modifier and Type
Field
Description
`protected static final Charset`
`FORM_CHARSET`

## Constructor Summary

Constructors
Constructor
Description
`ServletServerHttpRequest(HttpServletRequest servletRequest)`
Construct a new instance of the ServletServerHttpRequest based on the given `HttpServletRequest`.

## Method Summary

Modifier and Type
Method
Description
`ServerHttpAsyncRequestControl`
`getAsyncRequestControl(ServerHttpResponse response)`
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.
`Map<String,Object>`
`getAttributes()`
Return a mutable map of request attributes for this request.
`InputStream`
`getBody()`
Return the body of the message as an input stream.
`HttpHeaders`
`getHeaders()`
Return the headers of this message.
`InetSocketAddress`
`getLocalAddress()`
Return the address on which the request was received.
`HttpMethod`
`getMethod()`
Return the HTTP method of the request.
`Principal`
`getPrincipal()`
Return a `Principal` instance containing the name of the authenticated user.
`InetSocketAddress`
`getRemoteAddress()`
Return the address of the remote client.
`HttpServletRequest`
`getServletRequest()`
Returns the `HttpServletRequest` this object is based on.
`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).
`static URI`
`initURI(HttpServletRequest servletRequest)`
Initialize a URI from the given Servlet request.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### FORM_CHARSET

protected static final Charset FORM_CHARSET

## Constructor Details

### ServletServerHttpRequest

public ServletServerHttpRequest(HttpServletRequest servletRequest)
Construct a new instance of the ServletServerHttpRequest based on the given `HttpServletRequest`.

Parameters:
  `servletRequest` - the servlet request

## Method Details

### getServletRequest

public HttpServletRequest getServletRequest()
Returns the `HttpServletRequest` this object is based on.

### 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:
  - `HttpMethod.valueOf(String)`

### 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`)

### initURI

public static URI initURI(HttpServletRequest servletRequest)
Initialize a URI from the given Servlet request.

Parameters:
  `servletRequest` - the request
Returns:
  the initialized URI
Since:
  6.1

### 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`)

### getPrincipal

@Nullable public Principal getPrincipal()
Description copied from interface: `ServerHttpRequest`
Return a `Principal` instance containing the name of the authenticated user.

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

Specified by:
  `getPrincipal` in interface `ServerHttpRequest`

### getLocalAddress

public InetSocketAddress getLocalAddress()
Description copied from interface: `ServerHttpRequest`
Return the address on which the request was received.

Specified by:
  `getLocalAddress` in interface `ServerHttpRequest`

### getRemoteAddress

public InetSocketAddress getRemoteAddress()
Description copied from interface: `ServerHttpRequest`
Return the address of the remote client.

Specified by:
  `getRemoteAddress` in interface `ServerHttpRequest`

### getAttributes

public Map<String,Object> getAttributes()
Description copied from interface: `HttpRequest`
Return a mutable map of request attributes for this request.

Specified by:
  `getAttributes` in interface `HttpRequest`

### getBody

public InputStream getBody() throws IOException
Description copied from interface: `HttpInputMessage`
Return the body of the message as an input stream.

Specified by:
  `getBody` in interface `HttpInputMessage`
Returns:
  the input stream body (never `null`)
Throws:
  `IOException` - in case of I/O errors

### getAsyncRequestControl

public ServerHttpAsyncRequestControl getAsyncRequestControl(ServerHttpResponse response)
Description copied from interface: `ServerHttpRequest`
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.

Specified by:
  `getAsyncRequestControl` in interface `ServerHttpRequest`