java.lang.Object
org.refcodes.web.AbstractHttpRequest
org.refcodes.web.HttpClientRequest
- All Implemented Interfaces:
HeaderFieldsAccessor<RequestHeaderFields>
,HttpBodyAccessor.HttpBodyProvider<BadRequestException>
,HttpMethodAccessor
,HttpRequest
,RedirectDepthAccessor
,RedirectDepthAccessor.RedirectDepthMutator
,RedirectDepthAccessor.RedirectDepthProperty
,UrlAccessor
public class HttpClientRequest
extends AbstractHttpRequest
implements HttpRequest, HttpBodyAccessor.HttpBodyProvider<BadRequestException>, RedirectDepthAccessor.RedirectDepthProperty
Defines a
HttpClientRequest
being the request as produced by the
client.-
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.HttpMethodAccessor
HttpMethodAccessor.HttpMethodBuilder<B extends HttpMethodAccessor.HttpMethodBuilder<B>>, HttpMethodAccessor.HttpMethodMutator, HttpMethodAccessor.HttpMethodProperty
Nested classes/interfaces inherited from interface org.refcodes.web.RedirectDepthAccessor
RedirectDepthAccessor.RedirectDepthBuilder<B extends RedirectDepthAccessor.RedirectDepthBuilder<B>>, RedirectDepthAccessor.RedirectDepthMutator, RedirectDepthAccessor.RedirectDepthProperty
Nested classes/interfaces inherited from interface org.refcodes.web.UrlAccessor
UrlAccessor.UrlBuilder, UrlAccessor.UrlMutator, UrlAccessor.UrlProperty
-
Field Summary
Fields inherited from class org.refcodes.web.AbstractHttpRequest
_headerFields, _httpMethod, _url
-
Constructor Summary
ConstructorDescriptionHttpClientRequest
(HttpMethod aHttpMethod, Url aUrl, int aRedirectDepth, MediaTypeFactoryLookup aMediaTypeFactoryLookup) Instantiates a new http client request impl.HttpClientRequest
(HttpMethod aHttpMethod, Url aUrl, Object aRequest, int aRedirectDepth, MediaTypeFactoryLookup aMediaTypeFactoryLookup) Instantiates a new http client request impl.HttpClientRequest
(HttpMethod aHttpMethod, Url aUrl, Object aRequest, MediaTypeFactoryLookup aMediaTypeFactoryLookup) Instantiates a new http client request impl.HttpClientRequest
(HttpMethod aHttpMethod, Url aUrl, MediaTypeFactoryLookup aMediaTypeFactoryLookup) Instantiates a new http client request impl.HttpClientRequest
(HttpMethod aHttpMethod, Url aUrl, RequestHeaderFields aHeaderFields, Object aRequest, int aRedirectDepth, MediaTypeFactoryLookup aMediaTypeFactoryLookup) Instantiates a new http client request impl.HttpClientRequest
(HttpMethod aHttpMethod, Url aUrl, RequestHeaderFields aHeaderFields, Object aRequest, MediaTypeFactoryLookup aMediaTypeFactoryLookup) Instantiates a new http client request impl. -
Method Summary
Modifier and TypeMethodDescriptionint
Retrieves the redirect depth from the redirect depth property.<REQ> REQ
Retrieves the request from the request property.void
setRedirectDepth
(int aRedirectDepth) Sets the redirect depth for the redirect depth property.<REQ> void
setRequest
(REQ aRequest) Sets the request for the request property.Automatically sets theContentType
to theRequestHeaderFields
retrieved fromAbstractHttpRequest.getHeaderFields()
.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.RedirectDepthAccessor.RedirectDepthProperty
letRedirectDepth
Methods inherited from interface org.refcodes.web.UrlAccessor
getUrl
-
Field Details
-
DEFAULT_REDIRECT_DEPTH
public static final int DEFAULT_REDIRECT_DEPTH- See Also:
-
_mediaTypeFactoryLookup
-
-
Constructor Details
-
HttpClientRequest
public HttpClientRequest(HttpMethod aHttpMethod, Url aUrl, MediaTypeFactoryLookup aMediaTypeFactoryLookup) Instantiates a new http client request impl.- Parameters:
aHttpMethod
- the http methodaUrl
- TheUrl
from which to take the URL specific data.aMediaTypeFactoryLookup
- the media type factory lookup
-
HttpClientRequest
public HttpClientRequest(HttpMethod aHttpMethod, Url aUrl, Object aRequest, MediaTypeFactoryLookup aMediaTypeFactoryLookup) Instantiates a new http client request impl.- Parameters:
aHttpMethod
- the http methodaUrl
- TheUrl
from which to take the URL specific data.aRequest
- the requestaMediaTypeFactoryLookup
- the media type factory lookup
-
HttpClientRequest
public HttpClientRequest(HttpMethod aHttpMethod, Url aUrl, RequestHeaderFields aHeaderFields, Object aRequest, MediaTypeFactoryLookup aMediaTypeFactoryLookup) Instantiates a new http client request impl.- Parameters:
aHttpMethod
- the http methodaUrl
- TheUrl
from which to take the URL specific data.aHeaderFields
- the Header-FieldsaRequest
- the requestaMediaTypeFactoryLookup
- the media type factory lookup
-
HttpClientRequest
public HttpClientRequest(HttpMethod aHttpMethod, Url aUrl, int aRedirectDepth, MediaTypeFactoryLookup aMediaTypeFactoryLookup) Instantiates a new http client request impl.- Parameters:
aHttpMethod
- the http methodaUrl
- TheUrl
from which to take the URL specific data.aRedirectDepth
- The redirect depth provides the count of HTTP-Request and HTTP-Response cycles where the response represents a redirect as ofHttpStatusCode.isRedirectStatus()
. A value of -1 represents a nearly infinite HTTP-Request and HTTP-Response cycle (infinite might mean a maximum of 256 cycle).aMediaTypeFactoryLookup
- the media type factory lookup
-
HttpClientRequest
public HttpClientRequest(HttpMethod aHttpMethod, Url aUrl, Object aRequest, int aRedirectDepth, MediaTypeFactoryLookup aMediaTypeFactoryLookup) Instantiates a new http client request impl.- Parameters:
aHttpMethod
- the http methodaUrl
- TheUrl
from which to take the URL specific data.aRequest
- the requestaRedirectDepth
- The redirect depth provides the count of HTTP-Request and HTTP-Response cycles where the response represents a redirect as ofHttpStatusCode.isRedirectStatus()
. A value of -1 represents a nearly infinite HTTP-Request and HTTP-Response cycle (infinite might mean a maximum of 256 cycle).aMediaTypeFactoryLookup
- the media type factory lookup
-
HttpClientRequest
public HttpClientRequest(HttpMethod aHttpMethod, Url aUrl, RequestHeaderFields aHeaderFields, Object aRequest, int aRedirectDepth, MediaTypeFactoryLookup aMediaTypeFactoryLookup) Instantiates a new http client request impl.- Parameters:
aHttpMethod
- the http methodaUrl
- TheUrl
from which to take the URL specific data.aHeaderFields
- the Header-FieldsaRequest
- the requestaRedirectDepth
- The redirect depth provides the count of HTTP-Request and HTTP-Response cycles where the response represents a redirect as ofHttpStatusCode.isRedirectStatus()
. A value of -1 keeps a redirect depth as used by default by underlying implementations.aMediaTypeFactoryLookup
- the media type factory lookup
-
-
Method Details
-
getRequest
public <REQ> REQ getRequest()Retrieves the request from the request property.- Type Parameters:
REQ
- the generic type- Returns:
- The request stored by the request property.
-
setRequest
public <REQ> void setRequest(REQ aRequest) Sets the request for the request property. ThesetRequest(Object)
supports theHttpBodyMap
to marshal anHttpBodyMap
into an HTTP Request-Body.- Type Parameters:
REQ
- the generic type- Parameters:
aRequest
- The request to be stored by the request property.
-
toHttpBody
Automatically sets theContentType
to theRequestHeaderFields
retrieved fromAbstractHttpRequest.getHeaderFields()
. (seeHeaderFields.putContentType(org.refcodes.web.HttpMediaType)
) Converts an object representing the HTTP body to aString
instance. Automatically determines theContentType
from any headers when applicable.- Specified by:
toHttpBody
in interfaceHttpBodyAccessor.HttpBodyProvider<BadRequestException>
- Returns:
- The converted
String
instance represented by the according object. - Throws:
BadRequestException
-
toString
-
getRedirectDepth
public int getRedirectDepth()Retrieves the redirect depth from the redirect depth property.- Specified by:
getRedirectDepth
in interfaceRedirectDepthAccessor
- Returns:
- The redirect depth stored by the redirect depth property.
-
setRedirectDepth
public void setRedirectDepth(int aRedirectDepth) Sets the redirect depth for the redirect depth property.- Specified by:
setRedirectDepth
in interfaceRedirectDepthAccessor.RedirectDepthMutator
- Parameters:
aRedirectDepth
- The redirect depth to be stored by the redirect depth property.
-