- java.lang.Object
-
- org.refcodes.web.AbstractHttpRequest
-
- org.refcodes.web.HttpServerRequest
-
- All Implemented Interfaces:
HeaderFieldsAccessor<RequestHeaderFields>
,HttpBodyAccessor
,HttpInputStreamAccessor
,HttpMethodAccessor
,HttpRequest
,UrlAccessor
public class HttpServerRequest extends AbstractHttpRequest implements HttpRequest, HttpBodyAccessor, HttpInputStreamAccessor
Defines aHttpServerRequest
being the request as consumed by the server.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.refcodes.web.HeaderFieldsAccessor
HeaderFieldsAccessor.HeaderFieldsBuilder<T extends HeaderFields<?,?>,B extends HeaderFieldsAccessor.HeaderFieldsBuilder<T,B>>, HeaderFieldsAccessor.HeaderFieldsMutator<T extends HeaderFields<?,?>>, HeaderFieldsAccessor.HeaderFieldsProperty<T extends HeaderFields<?,?>>
-
Nested classes/interfaces inherited from interface org.refcodes.web.HttpBodyAccessor
HttpBodyAccessor.HttpBodyBuilder<B extends HttpBodyAccessor.HttpBodyBuilder<B>>, HttpBodyAccessor.HttpBodyMutator, HttpBodyAccessor.HttpBodyProperty, HttpBodyAccessor.HttpBodyProvider<EXC extends Exception>
-
Nested classes/interfaces inherited from interface org.refcodes.web.HttpInputStreamAccessor
HttpInputStreamAccessor.HttpInputStreamBuilder<B extends HttpInputStreamAccessor.HttpInputStreamBuilder<B>>, HttpInputStreamAccessor.HttpInputStreamMutator, HttpInputStreamAccessor.HttpInputStreamProperty, HttpInputStreamAccessor.HttpInputStreamProvider<EXC extends Exception>
-
Nested classes/interfaces inherited from interface org.refcodes.web.HttpMethodAccessor
HttpMethodAccessor.HttpMethodBuilder<B extends HttpMethodAccessor.HttpMethodBuilder<B>>, HttpMethodAccessor.HttpMethodMutator, HttpMethodAccessor.HttpMethodProperty
-
Nested classes/interfaces inherited from interface org.refcodes.web.UrlAccessor
UrlAccessor.UrlBuilder, UrlAccessor.UrlMutator, UrlAccessor.UrlProperty
-
-
Field Summary
Fields Modifier and Type Field Description protected MediaTypeFactoryLookup
_mediaTypeFactoryLookup
-
Fields inherited from class org.refcodes.web.AbstractHttpRequest
_headerFields, _httpMethod, _url
-
-
Constructor Summary
Constructors Constructor Description HttpServerRequest(HttpMethod aHttpMethod, Url aUrl, RequestHeaderFields aHeaderFields, InputStream aHttpInputStream, MediaTypeFactoryLookup aMediaTypeFactoryLookup)
Constructs aHttpServerRequest
with all required attributes.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getHttpBody()
Retrieves the HTTP body from the HTTP body property.InputStream
getHttpInputStream()
Retrieves theInputStream
from the HTTPInputStream
property.HttpBodyMap
getRequest()
Retrieves theHttpBodyMap
representing the request body.<REQ> REQ
getRequest(Class<REQ> aRequestType)
This method's implementation supports theHttpBodyMap
to unmarshal an HTTP Request-Body into anHttpBodyMap
when providing theHttpBodyMap
as request type.String
toString()
-
Methods inherited from class org.refcodes.web.AbstractHttpRequest
getHeaderFields, getHttpMethod, getUrl
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.refcodes.web.HeaderFieldsAccessor
getHeaderFields
-
Methods inherited from interface org.refcodes.web.HttpMethodAccessor
getHttpMethod
-
Methods inherited from interface org.refcodes.web.UrlAccessor
getUrl
-
-
-
-
Field Detail
-
_mediaTypeFactoryLookup
protected MediaTypeFactoryLookup _mediaTypeFactoryLookup
-
-
Constructor Detail
-
HttpServerRequest
public HttpServerRequest(HttpMethod aHttpMethod, Url aUrl, RequestHeaderFields aHeaderFields, InputStream aHttpInputStream, MediaTypeFactoryLookup aMediaTypeFactoryLookup)
Constructs aHttpServerRequest
with all required attributes.- Parameters:
aHttpMethod
- TheHttpMethod
with which the request has been sent.aUrl
- TheUrl
from which to take the URL specific data.aHeaderFields
- TheRequestHeaderFields
sent by the request.aHttpInputStream
- TheInputStream
representing the request's HTTP body.aMediaTypeFactoryLookup
- The lookup factory for retrieving the requiredMediaType
factories.
-
-
Method Detail
-
getRequest
public HttpBodyMap getRequest() throws BadRequestException
Retrieves theHttpBodyMap
representing the request body.- Returns:
- An instance of the
HttpBodyMap
representing the request. - Throws:
BadRequestException
- thrown when unmarshaling / deserializing an object fails.
-
getRequest
public <REQ> REQ getRequest(Class<REQ> aRequestType) throws BadRequestException
This method's implementation supports theHttpBodyMap
to unmarshal an HTTP Request-Body into anHttpBodyMap
when providing theHttpBodyMap
as request type.- Type Parameters:
REQ
- the generic type- Parameters:
aRequestType
- the request type- Returns:
- the request
- Throws:
BadRequestException
- the bad request exception
-
getHttpInputStream
public InputStream getHttpInputStream()
Retrieves theInputStream
from the HTTPInputStream
property.- Specified by:
getHttpInputStream
in interfaceHttpInputStreamAccessor
- Returns:
- The
InputStream
stored by theInputStream
property.
-
getHttpBody
public String getHttpBody()
Retrieves the HTTP body from the HTTP body property.- Specified by:
getHttpBody
in interfaceHttpBodyAccessor
- Returns:
- The HTTP body stored by the HTTP body property.
-
-