- java.lang.Object
-
- org.refcodes.web.HttpRequestImpl
-
- org.refcodes.web.HttpClientRequestImpl
-
- All Implemented Interfaces:
HeaderFieldsAccessor<RequestHeaderFields>
,HttpBodyAccessor.HttpBodyProvider<BadRequestException>
,HttpClientRequest
,HttpMethodAccessor
,HttpRequest
,RedirectDepthAccessor
,RedirectDepthAccessor.RedirectDepthMutator
,RedirectDepthAccessor.RedirectDepthProperty
,UrlAccessor
public class HttpClientRequestImpl extends HttpRequestImpl implements HttpClientRequest
Implementation of theHttpClientRequest
interface.
-
-
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.HttpClientRequest
HttpClientRequest.HttpClientRequestBuilder
-
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 Modifier and Type Field Description protected MediaTypeFactoryLookup
_mediaTypeFactoryLookup
-
Fields inherited from class org.refcodes.web.HttpRequestImpl
_headerFields, _httpMethod, _url
-
Fields inherited from interface org.refcodes.web.HttpClientRequest
DEFAULT_REDIRECT_DEPTH
-
-
Constructor Summary
Constructors Constructor Description HttpClientRequestImpl(HttpMethod aHttpMethod, Url aUrl, int aRedirectDepth, MediaTypeFactoryLookup aMediaTypeFactoryLookup)
Instantiates a new http client request impl.HttpClientRequestImpl(HttpMethod aHttpMethod, Url aUrl, Object aRequest, int aRedirectDepth, MediaTypeFactoryLookup aMediaTypeFactoryLookup)
Instantiates a new http client request impl.HttpClientRequestImpl(HttpMethod aHttpMethod, Url aUrl, Object aRequest, MediaTypeFactoryLookup aMediaTypeFactoryLookup)
Instantiates a new http client request impl.HttpClientRequestImpl(HttpMethod aHttpMethod, Url aUrl, MediaTypeFactoryLookup aMediaTypeFactoryLookup)
Instantiates a new http client request impl.HttpClientRequestImpl(HttpMethod aHttpMethod, Url aUrl, RequestHeaderFields aHeaderFields, Object aRequest, int aRedirectDepth, MediaTypeFactoryLookup aMediaTypeFactoryLookup)
Instantiates a new http client request impl.HttpClientRequestImpl(HttpMethod aHttpMethod, Url aUrl, RequestHeaderFields aHeaderFields, Object aRequest, MediaTypeFactoryLookup aMediaTypeFactoryLookup)
Instantiates a new http client request impl.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getRedirectDepth()
Retrieves the redirect depth from the redirect depth property.<REQ> REQ
getRequest()
Gets the request.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.String
toHttpBody()
Automatically sets theContentType
to theRequestHeaderFields
retrieved fromHeaderFieldsAccessor.getHeaderFields()
.String
toString()
-
Methods inherited from class org.refcodes.web.HttpRequestImpl
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 Detail
-
_mediaTypeFactoryLookup
protected MediaTypeFactoryLookup _mediaTypeFactoryLookup
-
-
Constructor Detail
-
HttpClientRequestImpl
public HttpClientRequestImpl(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
-
HttpClientRequestImpl
public HttpClientRequestImpl(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
-
HttpClientRequestImpl
public HttpClientRequestImpl(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
-
HttpClientRequestImpl
public HttpClientRequestImpl(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
-
HttpClientRequestImpl
public HttpClientRequestImpl(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
-
HttpClientRequestImpl
public HttpClientRequestImpl(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 Detail
-
getRequest
public <REQ> REQ getRequest()
Gets the request.- Specified by:
getRequest
in interfaceHttpClientRequest
- Type Parameters:
REQ
- the generic type- Returns:
- the request
-
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.- Specified by:
setRequest
in interfaceHttpClientRequest
- Type Parameters:
REQ
- the generic type- Parameters:
aRequest
- The request to be stored by the request property.
-
toHttpBody
public String toHttpBody() throws BadRequestException
Automatically sets theContentType
to theRequestHeaderFields
retrieved fromHeaderFieldsAccessor.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>
- Specified by:
toHttpBody
in interfaceHttpClientRequest
- Returns:
- The converted
String
instance represented by the according object. - Throws:
BadRequestException
-
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.
-
-