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
ServerHttpRequestimplementation that is based on aHttpServletRequest.- Since:
- 3.0
- Author:
- Arjen Poutsma, Rossen Stoyanchev
Field Summary
Fields Modifier and Type Field Description protected static StringFORM_CHARSETprotected static StringFORM_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 ServerHttpAsyncRequestControlgetAsyncRequestControl(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.InputStreamgetBody()Return the body of the message as an input stream.HttpHeadersgetHeaders()Return the headers of this message.InetSocketAddressgetLocalAddress()Return the address on which the request was received.HttpMethodgetMethod()Return the HTTP method of the request.PrincipalgetPrincipal()Return aPrincipalinstance containing the name of the authenticated user.InetSocketAddressgetRemoteAddress()Return the address of the remote client.HttpServletRequestgetServletRequest()Returns theHttpServletRequestthis object is based on.URIgetURI()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 String FORM_CHARSET
- See Also:
- Constant Field Values
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 theHttpServletRequestthis object is based on.
getMethod
public HttpMethod getMethod()
Description copied from interface:HttpRequestReturn the HTTP method of the request.- Specified by:
getMethodin interfaceHttpRequest- Returns:
- the HTTP method as an HttpMethod enum value, or
nullif not resolvable (e.g. in case of a non-standard HTTP method)
getURI
public URI getURI()
Description copied from interface:HttpRequestReturn the URI of the request (including a query string if any, but only if it is well-formed for a URI representation).- Specified by:
getURIin interfaceHttpRequest- Returns:
- the URI of the request (never
null)
getHeaders
public HttpHeaders getHeaders()
Description copied from interface:HttpMessageReturn the headers of this message.- Specified by:
getHeadersin interfaceHttpMessage- Returns:
- a corresponding HttpHeaders object (never
null)
getPrincipal
public Principal getPrincipal()
Description copied from interface:ServerHttpRequestReturn aPrincipalinstance containing the name of the authenticated user.If the user has not been authenticated, the method returns
null.- Specified by:
getPrincipalin interfaceServerHttpRequest
getLocalAddress
public InetSocketAddress getLocalAddress()
Description copied from interface:ServerHttpRequestReturn the address on which the request was received.- Specified by:
getLocalAddressin interfaceServerHttpRequest
getRemoteAddress
public InetSocketAddress getRemoteAddress()
Description copied from interface:ServerHttpRequestReturn the address of the remote client.- Specified by:
getRemoteAddressin interfaceServerHttpRequest
getBody
public InputStream getBody() throws IOException
Description copied from interface:HttpInputMessageReturn the body of the message as an input stream.- Specified by:
getBodyin 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:ServerHttpRequestReturn 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:
getAsyncRequestControlin interfaceServerHttpRequest