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 aHttpServletRequest
.- Since:
- 3.0
- Author:
- Arjen Poutsma, Rossen Stoyanchev, Juergen Hoeller
Field Summary
Fields Modifier and Type Field Description protected static Charset
FORM_CHARSET
protected static String
FORM_CONTENT_TYPE
Constructor Summary
Constructors Constructor Description ServletServerHttpRequest(HttpServletRequest servletRequest)
Construct a new instance of the ServletServerHttpRequest based on the givenHttpServletRequest
.
Method Summary
All Methods Instance Methods Concrete Methods 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.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.String
getMethodValue()
Return the HTTP method of the request as a String value.Principal
getPrincipal()
Return aPrincipal
instance containing the name of the authenticated user.InetSocketAddress
getRemoteAddress()
Return the address of the remote client.HttpServletRequest
getServletRequest()
Returns theHttpServletRequest
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).
Field Detail
FORM_CONTENT_TYPE
protected static final String FORM_CONTENT_TYPE
- See Also:
- Constant Field Values
FORM_CHARSET
protected static final Charset FORM_CHARSET
Constructor Detail
ServletServerHttpRequest
public ServletServerHttpRequest(HttpServletRequest servletRequest)
Construct a new instance of the ServletServerHttpRequest based on the givenHttpServletRequest
.- Parameters:
servletRequest
- the servlet request
Method Detail
getServletRequest
public HttpServletRequest getServletRequest()
Returns theHttpServletRequest
this object is based on.
getMethod
@Nullable public HttpMethod getMethod()
Description copied from interface:HttpRequest
Return the HTTP method of the request.- Specified by:
getMethod
in interfaceHttpRequest
- Returns:
- the HTTP method as an HttpMethod enum value, or
null
if not resolvable (e.g. in case of a non-standard HTTP method) - See Also:
HttpRequest.getMethodValue()
,HttpMethod.resolve(String)
getMethodValue
public String getMethodValue()
Description copied from interface:HttpRequest
Return the HTTP method of the request as a String value.- Specified by:
getMethodValue
in interfaceHttpRequest
- Returns:
- the HTTP method as a plain String
- See Also:
HttpRequest.getMethod()
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
)
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
)
getPrincipal
public Principal getPrincipal()
Description copied from interface:ServerHttpRequest
Return aPrincipal
instance containing the name of the authenticated user.If the user has not been authenticated, the method returns
null
.- Specified by:
getPrincipal
in interfaceServerHttpRequest
getLocalAddress
public InetSocketAddress getLocalAddress()
Description copied from interface:ServerHttpRequest
Return the address on which the request was received.- Specified by:
getLocalAddress
in interfaceServerHttpRequest
getRemoteAddress
public InetSocketAddress getRemoteAddress()
Description copied from interface:ServerHttpRequest
Return the address of the remote client.- Specified by:
getRemoteAddress
in interfaceServerHttpRequest
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 interfaceHttpInputMessage
- 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 interfaceServerHttpRequest