org.springframework.http.server
Class ServletServerHttpRequest

java.lang.Object
  extended by org.springframework.http.server.ServletServerHttpRequest
All Implemented Interfaces:
HttpInputMessage, HttpMessage, HttpRequest, ServerHttpRequest
Direct Known Subclasses:
RequestPartServletServerHttpRequest

public class ServletServerHttpRequest
extends java.lang.Object
implements ServerHttpRequest

ServerHttpRequest implementation that is based on a HttpServletRequest.

Since:
3.0
Author:
Arjen Poutsma

Field Summary
protected static java.lang.String FORM_CHARSET
           
protected static java.lang.String FORM_CONTENT_TYPE
           
private  HttpHeaders headers
           
private static java.lang.String METHOD_POST
           
private  HttpServletRequest servletRequest
           
 
Constructor Summary
ServletServerHttpRequest(HttpServletRequest servletRequest)
          Construct a new instance of the ServletServerHttpRequest based on the given HttpServletRequest.
 
Method Summary
 java.io.InputStream getBody()
          Return the body of the message as an input stream.
private  java.io.InputStream getBodyFromServletRequestParameters(HttpServletRequest request)
          Use 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 ServletRequest to access a parameter thus causing the input stream to be "consumed".
 HttpHeaders getHeaders()
          Return the headers of this message.
 HttpMethod getMethod()
          Return the HTTP method of the request.
 HttpServletRequest getServletRequest()
          Returns the HttpServletRequest this object is based on.
 java.net.URI getURI()
          Return the URI of the request.
private  boolean isFormPost(HttpServletRequest request)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FORM_CONTENT_TYPE

protected static final java.lang.String FORM_CONTENT_TYPE
See Also:
Constant Field Values

FORM_CHARSET

protected static final java.lang.String FORM_CHARSET
See Also:
Constant Field Values

METHOD_POST

private static final java.lang.String METHOD_POST
See Also:
Constant Field Values

servletRequest

private final HttpServletRequest servletRequest

headers

private HttpHeaders headers
Constructor Detail

ServletServerHttpRequest

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

Parameters:
servletRequest - the servlet request
Method Detail

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 enum value

getURI

public java.net.URI getURI()
Description copied from interface: HttpRequest
Return the URI of the request.

Specified by:
getURI in interface HttpRequest
Returns:
the URI of the request

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

getBody

public java.io.InputStream getBody()
                            throws java.io.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
Throws:
java.io.IOException - in case of I/O Errors

isFormPost

private boolean isFormPost(HttpServletRequest request)

getBodyFromServletRequestParameters

private java.io.InputStream getBodyFromServletRequestParameters(HttpServletRequest request)
                                                         throws java.io.IOException
Use 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 ServletRequest to access a parameter thus causing the input stream to be "consumed".

Throws:
java.io.IOException