public class DocumentableHttpServletRequest extends Object
HttpServletRequest
wrapper that provides a limited set of methods intended
to help in the documentation of the request.Constructor and Description |
---|
DocumentableHttpServletRequest(MockHttpServletRequest request)
Creates a new
DocumentableHttpServletRequest to document the given
request . |
Modifier and Type | Method and Description |
---|---|
String |
getContentAsString()
Returns a
String of the request's content |
long |
getContentLength()
Returns the length of the request's content
|
String |
getContextPath()
Returns the request's context path
|
HttpHeaders |
getHeaders()
Returns the request's headers.
|
String |
getHost()
Returns the name of the host to which the request was sent.
|
String |
getMethod()
Returns the request's method.
|
String |
getParameterMapAsQueryString()
Returns the request's parameter map formatted as a query string
|
int |
getPort()
Returns the port to which the request was sent.
|
String |
getRequestUriWithQueryString()
Returns the request's URI including its query string.
|
String |
getScheme()
Returns the request's scheme.
|
boolean |
isGetRequest()
Whether or not this request is a
GET request. |
boolean |
isPostRequest()
Whether or not this request is a
POST request. |
boolean |
isPutRequest()
Whether or not this request is a
PUT request. |
public DocumentableHttpServletRequest(MockHttpServletRequest request)
DocumentableHttpServletRequest
to document the given
request
.request
- the request that is to be documentedpublic boolean isGetRequest()
GET
request.true
if it is a GET
request, otherwise false
HttpServletRequest.getMethod()
public boolean isPostRequest()
POST
request.true
if it is a POST
request, otherwise false
HttpServletRequest.getMethod()
public boolean isPutRequest()
PUT
request.true
if it is a PUT
request, otherwise false
HttpServletRequest.getMethod()
public HttpHeaders getHeaders()
HttpServletRequest.getHeaderNames()
and
HttpServletRequest.getHeaders(String)
.HttpServletRequest.getHeaderNames()
,
HttpServletRequest.getHeaders(String)
public String getScheme()
ServletRequest.getScheme()
public String getHost()
ServletRequest.getServerName()
public int getPort()
ServletRequest.getServerPort()
public String getMethod()
HttpServletRequest.getMethod()
public long getContentLength()
ServletRequest.getContentLength()
public String getContentAsString() throws IOException
String
of the request's contentIOException
- if the content cannot be readpublic String getRequestUriWithQueryString()
HttpServletRequest.getQueryString()
. If it's
null
and it is a GET
request, the query string is then constructed
from the request's ServletRequest.getParameterMap()
parameter map.public String getParameterMapAsQueryString()
ServletRequest.getParameterMap()
public String getContextPath()
HttpServletRequest.getContextPath()