- 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 aHttpClientRequestbeing 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 Modifier and Type Field Description protected MediaTypeFactoryLookup_mediaTypeFactoryLookupstatic intDEFAULT_REDIRECT_DEPTH-
Fields inherited from class org.refcodes.web.AbstractHttpRequest
_headerFields, _httpMethod, _url
-
-
Constructor Summary
Constructors Constructor Description HttpClientRequest(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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetRedirectDepth()Retrieves the redirect depth from the redirect depth property.<REQ> REQgetRequest()Retrieves the request from the request property.voidsetRedirectDepth(int aRedirectDepth)Sets the redirect depth for the redirect depth property.<REQ> voidsetRequest(REQ aRequest)Sets the request for the request property.StringtoHttpBody()Automatically sets theContentTypeto theRequestHeaderFieldsretrieved fromAbstractHttpRequest.getHeaderFields().StringtoString()-
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 Detail
-
DEFAULT_REDIRECT_DEPTH
public static final int DEFAULT_REDIRECT_DEPTH
- See Also:
- Constant Field Values
-
_mediaTypeFactoryLookup
protected MediaTypeFactoryLookup _mediaTypeFactoryLookup
-
-
Constructor Detail
-
HttpClientRequest
public HttpClientRequest(HttpMethod aHttpMethod, Url aUrl, MediaTypeFactoryLookup aMediaTypeFactoryLookup)
Instantiates a new http client request impl.- Parameters:
aHttpMethod- the http methodaUrl- TheUrlfrom 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- TheUrlfrom 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- TheUrlfrom 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- TheUrlfrom 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- TheUrlfrom 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- TheUrlfrom 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()
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 theHttpBodyMapto marshal anHttpBodyMapinto an HTTP Request-Body.- 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 theContentTypeto theRequestHeaderFieldsretrieved fromAbstractHttpRequest.getHeaderFields(). (seeHeaderFields.putContentType(org.refcodes.web.HttpMediaType)) Converts an object representing the HTTP body to aStringinstance. Automatically determines theContentTypefrom any headers when applicable.- Specified by:
toHttpBodyin interfaceHttpBodyAccessor.HttpBodyProvider<BadRequestException>- Returns:
- The converted
Stringinstance represented by the according object. - Throws:
BadRequestException
-
getRedirectDepth
public int getRedirectDepth()
Retrieves the redirect depth from the redirect depth property.- Specified by:
getRedirectDepthin 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:
setRedirectDepthin interfaceRedirectDepthAccessor.RedirectDepthMutator- Parameters:
aRedirectDepth- The redirect depth to be stored by the redirect depth property.
-
-