Class RestRequest
- All Implemented Interfaces:
AutoCloseable,Configurable,HttpUriRequest,HttpMessage,HttpRequest
- Direct Known Subclasses:
MockRestRequest
Instances of this class are created by the various creator methods on the RestClient class.
Example:
The close() method will automatically close any associated RestResponse if one was created via run().
Notes:
- This class is not thread safe.
- This class implements
AutoCloseableand can be used in try-with-resources blocks. Theclose()method allows unchecked exceptions to propagate for debuggability, while catching and logging checked exceptions to follow AutoCloseable best practices.
See Also:
-
Nested Class Summary
Nested classes/interfaces inherited from class org.apache.juneau.BeanSession
BeanSession.Builder -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedRestRequest(RestClient client, URI uri, String method, boolean hasBody) Constructs a REST call with the specified method name. -
Method Summary
Modifier and TypeMethodDescriptionvoidabort()Aborts this http request.Sets the value for theAccept request header.acceptCharset(String value) Sets the value for theAccept-Charset request header.voidAdds a header to this message.voidAdds a header to this message.cancellable(Cancellable cancellable) SetsCancellablefor the ongoing operation.voidclose()Closes this request and its associated response (if one was created).complete()Same asrun()but immediately callsRestResponse.consume()to clean up the response.Deprecated.Same ascomplete()but allows you to run the call asynchronously.config(RequestConfig value) Sets the actual request configuration.booleancontainsHeader(String name) Checks if a certain header is present in this message.Sets the body of this request.content(Object input, HttpPartSchema schema) Sets the body of this request.contentString(Object input) Sets the body of this request as straight text bypassing the serializer.contentType(String value) Sets the value for theContent-Type request header.context(HttpContext context) Override the context to use for the execution.protected HeadercreateHeader(String name, Object value, HttpPartSerializer serializer, HttpPartSchema schema, Boolean skipIfEmpty) Creates a new header.protected HttpRequestBasecreateInnerRequest(String method, URI uri, boolean hasBody) Constructs theHttpRequestBaseobject that ends up being passed to the client execute method.protected NameValuePaircreatePart(String name, Object value, HttpPartType type, HttpPartSerializer serializer, HttpPartSchema schema, Boolean skipIfEmpty) Creates a new query/form-data/path part.debug()SetsDebug: value header on this request.errorCodes(Predicate<Integer> value) Allows you to override what status codes are considered error codes that would result in aRestCallException.Adds a form-data parameter to the request body.formData(NameValuePair... parts) Appends multiple form-data parameters to the request.formDataBean(Object value) Appends multiple form-data parameters to the request from properties defined on a Java bean.formDataCustom(Object value) Adds form-data parameters as the entire body of the request.formDataPairs(String... pairs) Adds form-data parameters to the request body using free-form key/value pairs.Header[]Returns all the headers of this message.Returns the actual request configuration.getFirstHeader(String name) Returns the first header with a specified name of this message.Returns the form data for the request.Returns the header data for the request.Header[]getHeaders(String name) Returns all the headers with a specified name of this message.Returns the body of this request.getLastHeader(String name) Returns the last header with a specified name of this message.Returns the HTTP method this request uses, such as GET, PUT, POST, or other.Deprecated.Use constructor parameters of configuration API provided by HttpClient.Returns the path data for the request.Returns the protocol version this message is compatible with.Returns the query data for the request.Returns the request line of this request.<T> TgetResponse(Class<T> type) A shortcut for callingrun().getContent().as( .type )<T> TgetResponse(Type type, Type... args) A shortcut for callingrun().getContent().as( .type ,args )A shortcut for callingrun().getContent().asString() .getURI()Returns the original request URI.booleanReturnstrue if this request has a body.Appends a header to the request.Appends a header to the request.Returns an iterator of all the headers.headerIterator(String name) Returns an iterator of the headers with a given name.headerPairs(String... pairs) Appends multiple headers to the request using freeform key/value pairs.Appends multiple headers to the request.headersBean(Object value) Appends multiple headers to the request from properties defined on a Java bean.html()Convenience method for specifying HTML as the marshalling transmission media type for this request only.htmlDoc()Convenience method for specifying HTML DOC as the marshalling transmission media type for this request only.Convenience method for specifying Stripped HTML DOC as the marshalling transmission media type for this request only.PreventRestCallExceptionsfrom being thrown when HTTP status 400+ is encountered.interceptors(RestCallInterceptor... interceptors) Add one or more interceptors for this call only.booleanbooleanisDebug()Returnstrue if debug mode is currently enabled.json()Convenience method for specifying JSON as the marshalling transmission media type for this request only.json5()Convenience method for specifying Simplified JSON as the marshalling transmission media type for this request only.Logs a message.Logs a message.Shortcut for setting theAccept andContent-Type headers on a request.msgPack()Convenience method for specifying MessagePack as the marshalling transmission media type for this request only.noTrace()When called,No-Trace: true is added to requests.openApi()Convenience method for specifying OpenAPI as the marshalling transmission media type for this request only.Specifies the parser to use on the response body.Specifies the parser to use on the response body.Sets or replaces a path parameter of the form"{name}" in the URI.pathData(NameValuePair... parts) Sets or replaces multiple path parameters on the request.pathDataBean(Object value) Sets multiple path parameters to the request from properties defined on a Java bean.pathDataPairs(String... pairs) Replaces path parameters of the form"{name}" in the URI using free-form key/value pairs.Convenience method for specifying Plain Text as the marshalling transmission media type for this request only.Returns the properties on this bean as a map for debugging.protocolVersion(ProtocolVersion version) Sets the protocol version for this request.queryCustom(Object value) Adds a free-form custom query.Appends a query parameter to the URI of the request.queryData(NameValuePair... parts) Appends multiple query parameters to the request.queryDataBean(Object value) Appends multiple query parameters to the request from properties defined on a Java bean.queryDataPairs(String... pairs) Adds query parameters to the URI query using free-form key/value pairs..voidremoveHeader(Header header) Removes a header from this message.voidremoveHeaders(String name) Removes all headers with a certain name from this message.Rethrow any of the specified exception types if a matchingException-Name header is found.run()Runs this request and returns the resulting response object.Same asrun()but allows you to run the call asynchronously.serializer(Class<? extends Serializer> serializer) Specifies the serializer to use on the request body.serializer(Serializer serializer) Specifies the serializer to use on the request body.voidOverwrites the first header with the same name.voidOverwrites the first header with the same name.voidsetHeaders(Header[] headers) Overwrites all the headers in the message.voidsetParams(HttpParams params) Deprecated.Use constructor parameters of configuration API provided by HttpClient.Causes logging to be suppressed for the duration of this request.Specifies the target host for the request.uon()Convenience method for specifying UON as the marshalling transmission media type for this request only.Sets the URI for this request.uriFragment(String fragment) Sets the URI fragment.Sets the URI host.uriPort(int port) Sets the URI port.Sets the URI scheme.uriUserInfo(String userInfo) Sets the URI user info.uriUserInfo(String username, String password) Sets the URI user info.urlEnc()Convenience method for specifying URL-Encoding as the marshalling transmission media type for this request only.xml()Convenience method for specifying XML as the marshalling transmission media type for this request only.Methods inherited from class org.apache.juneau.BeanSession
addWarning, convertToMemberType, convertToMemberType, convertToType, convertToType, convertToType, create, getAnnotationProvider, getArgsClassMeta, getBeanClassVisibility, getBeanConstructorVisibility, getBeanDictionary, getBeanFieldVisibility, getBeanMeta, getBeanMethodVisibility, getBeanRegistry, getBeanTypePropertyName, getBeanTypePropertyName, getClassMeta, getClassMeta, getClassMetaForObject, getClassMetaForObject, getLocale, getMediaType, getNamePropertyName, getNotBeanClasses, getNotBeanPackagesNames, getPropertyNamer, getSwaps, getTimeZone, getTimeZoneId, isBean, isBean, isBeanMapPutReturnsOldValue, isBeansRequireDefaultConstructor, isBeansRequireSerializable, isBeansRequireSettersForGetters, isBeansRequireSomeProperties, isFindFluentSetters, isIgnoreInvocationExceptionsOnGetters, isIgnoreInvocationExceptionsOnSetters, isIgnoreMissingSetters, isIgnoreUnknownBeanProperties, isIgnoreUnknownNullBeanProperties, isSortProperties, isUseEnumNames, isUseInterfaceProxies, isUseJavaBeanIntrospector, newBean, newBean, newBeanMap, newBeanMap, newGenericMap, object, string, toArray, toBeanMap, toBeanMap, toBeanMapMethods inherited from class org.apache.juneau.ContextSession
checkForWarnings, getContext, getSessionProperties, getWarnings, toString
-
Constructor Details
-
RestRequest
protected RestRequest(RestClient client, URI uri, String method, boolean hasBody) throws RestCallException Constructs a REST call with the specified method name.- Parameters:
client- The client that created this request.
Cannot benull .uri- The target URI.
Cannot benull .method- The HTTP method name (uppercase).
Cannot benull .hasBody- Whether this method has a body.- Throws:
RestCallException- If an exception or non-200 response code occurred during the connection attempt.
-
-
Method Details
-
abort
Aborts this http request. Any active execution of this method should return immediately. If the request has not started, it will abort after the next execution.
Aborting this request will cause all subsequent executions with this request to fail.- Specified by:
abortin interfaceHttpUriRequest- Throws:
UnsupportedOperationException
-
accept
Sets the value for theAccept request header.This overrides the media type specified on the parser, but is overridden by calling
header("Accept" , value);- Parameters:
value- The new header value.
Can benull (header will not be set).- Returns:
- This object.
- Throws:
RestCallException- Invalid input.
-
acceptCharset
Sets the value for theAccept-Charset request header.This is a shortcut for calling
header("Accept-Charset" , value);- Parameters:
value- The new header value.
Can benull (header will not be set).- Returns:
- This object.
- Throws:
RestCallException- Invalid input.
-
addHeader
Adds a header to this message. The header will be appended to the end of the list.Notes:
header(Header)is an equivalent method and the preferred method for fluent-style coding.
- Specified by:
addHeaderin interfaceHttpMessage- Parameters:
header- The header to append.
Can benull (ignored).
-
addHeader
Adds a header to this message. The header will be appended to the end of the list.Notes:
header(String,Object)is an equivalent method and the preferred method for fluent-style coding.
- Specified by:
addHeaderin interfaceHttpMessage- Parameters:
name- The name of the header.
Cannot benull or empty (header will not be created).value- The value of the header.
Can benull .
-
cancellable
SetsCancellablefor the ongoing operation.- Parameters:
cancellable- The cancellable object.
Can benull (no cancellation will be available).- Returns:
- This object.
-
close
Closes this request and its associated response (if one was created).This method is idempotent and can be called multiple times without side effects.
Implementation Notes:
This implementation represents a compromise between strict AutoCloseable compliance and debuggability:
- Unchecked exceptions (
RuntimeExceptionandError) from the response close are allowed to propagate. This ensures programming errors and serious issues are visible during development and testing. - Checked exceptions (including
RestCallException) are caught and logged but not thrown. This follows AutoCloseable best practices and prevents close exceptions from interfering with try-with-resources cleanup or masking the original exception.
- Specified by:
closein interfaceAutoCloseable
- Unchecked exceptions (
-
complete
Same asrun()but immediately callsRestResponse.consume()to clean up the response.Use this method if you're only interested in the status line of the response and not the response entity. Attempts to call any of the methods on the response object that retrieve the body (e.g.
ResponseContent.asReader()will cause aRestCallExceptionto be thrown.Notes:
- You do not need to execute
InputStream.close()on the response body to consume the response.
Example:
// Get the response code. // No need to call close() on the RestResponse object. int rc =client .get(URI ).complete().getResponseCode();- Returns:
- The response object.
- Throws:
RestCallException- If an exception or non-200 response code occurred during the connection attempt.
- You do not need to execute
-
completed
Deprecated.Used in combination withcancellable(Cancellable).- Returns:
- This object.
-
completeFuture
Same ascomplete()but allows you to run the call asynchronously.Example:
Future<RestResponse>
future =client .get(URI ).completeFuture();// Do some other stuff int rc =future .get().getResponseStatus();Notes:
- Use the
RestClient.Builder.executorService(ExecutorService, boolean)method to customize the executor service used for creatingFutures. - You do not need to execute
InputStream.close()on the response body to consume the response.
- Returns:
- The HTTP status code.
- Throws:
RestCallException- If the executor service was not defined.
- Use the
-
config
Sets the actual request configuration.- Parameters:
value- The new value.
Can benull (default configuration will be used).- Returns:
- This object.
-
containsHeader
Checks if a certain header is present in this message. Header values are ignored.- Specified by:
containsHeaderin interfaceHttpMessage- Parameters:
name- The header name to check for.
Cannot benull .- Returns:
true if at least one header with this name is present.
-
content
Sets the body of this request.- Parameters:
value- The input to be sent to the REST resource (only valid for PUT/POST/PATCH) requests.
Can be of the following types:-
Reader- Raw contents ofReaderwill be serialized to remote resource. -
InputStream- Raw contents ofInputStreamwill be serialized to remote resource. -
HttpResource- Raw contents will be serialized to remote resource. Additional headers and media type will be set on request. -
HttpEntity/BasicHttpEntity- Bypass Juneau serialization and pass HttpEntity directly to HttpClient. -
Object- POJO to be converted to text using theSerializerregistered with theRestClient. -
PartList- Converted to a URL-encoded FORM post. -
A
Supplierof anything on this list.
Can benull (no body will be sent).-
- Returns:
- This object.
-
content
Sets the body of this request.- Parameters:
input- The input to be sent to the REST resource (only valid for PUT/POST/PATCH) requests.
Can be of the following types:-
Reader- Raw contents ofReaderwill be serialized to remote resource. -
InputStream- Raw contents ofInputStreamwill be serialized to remote resource. -
HttpResource- Raw contents will be serialized to remote resource. Additional headers and media type will be set on request. -
HttpEntity/BasicHttpEntity- Bypass Juneau serialization and pass HttpEntity directly to HttpClient. -
Object- POJO to be converted to text using theSerializerregistered with theRestClient. -
PartList- Converted to a URL-encoded FORM post. -
A
Supplierof anything on this list.
-
schema- The schema object that defines the format of the output.- If
null , defaults toHttpPartSchema.DEFAULT. - Only used if serializer is schema-aware (e.g.
OpenApiSerializer).
- If
- Returns:
- This object.
-
contentString
Sets the body of this request as straight text bypassing the serializer.client .put("/foo" ) .content(new StringReader("foo" )) .contentType("text/foo" ) .run();client .put("/foo" ) .bodyString("foo" ) .run();Note that this is different than the following which will serialize
foo as a JSON string"foo" .client .put("/foo" ) .json() .content("foo" ) .run();- Parameters:
input- The input to be sent to the REST resource (only valid for PUT/POST/PATCH) requests.- Returns:
- This object.
- Throws:
RestCallException- If a retry was attempted, but the entity was not repeatable.
-
contentType
Sets the value for theContent-Type request header.This overrides the media type specified on the serializer, but is overridden by calling
header("Content-Type" , value);- Parameters:
value- The new header value.
Can benull (header will not be set).- Returns:
- This object.
- Throws:
RestCallException- Invalid input.
-
context
Override the context to use for the execution.- Parameters:
context- The context to use for the execution, ornull to use the default context.- Returns:
- This object.
-
debug
SetsDebug: value header on this request.- Returns:
- This object.
- Throws:
RestCallException- Invalid input.
-
errorCodes
Allows you to override what status codes are considered error codes that would result in aRestCallException.The default error code predicate is:
x -> x >= 400.- Parameters:
value- The new predicate for calculating error codes.
Cannot benull .- Returns:
- This object.
-
formData
Appends multiple form-data parameters to the request.Example:
// Appends two form-data parameters to the request. client .get(URI ) .formData( BasicStringPart.of ("foo" ,"bar" ), BasicBooleanPart.of ("baz" ,true ) ) .run();- Parameters:
parts- The parameters to set.null values are ignored.- Returns:
- This object.
-
formData
Adds a form-data parameter to the request body.Example:
// Adds form data parameter "foo=bar". client .formPost(URI ) .formData("foo" ,"bar" ) .run();- Parameters:
name- The parameter name.
Cannot benull or empty (parameter will not be created).value- The parameter value.
Non-string values are converted to strings using theHttpPartSerializerdefined on the client.
Can benull .- Returns:
- This object.
-
formDataBean
Appends multiple form-data parameters to the request from properties defined on a Java bean.Example:
public class MyFormData {public String getFooBar() {return "baz" ; }public Integer getQux() {return 123; } }// Appends form data "fooBar=baz&qux=123". client .get(URI ) .formDataBean(new MyFormData()) .run();- Parameters:
value- The bean containing the properties to set as form-data parameter values.
Cannot benull .- Returns:
- This object.
-
formDataCustom
Adds form-data parameters as the entire body of the request.Example:
// Creates form data "foo=bar&baz=qux". client .formPost(URI ) .formDataCustom("foo=bar&baz=qux" ) .run();// Creates form data "foo=bar&baz=qux" using StringEntity. client .formPost(URI ) .formDataCustom(new StringEntity("foo=bar&baz=qux" ,"application/x-www-form-urlencoded" )) .run();// Creates form data "foo=bar&baz=qux" using StringEntity and body(). client .formPost(URI ) .content(new StringEntity("foo=bar&baz=qux" ,"application/x-www-form-urlencoded" )) .run();- Parameters:
value- The parameter value.
Can be any of the following types:-
CharSequence -
Reader- Raw contents ofReaderwill be serialized to remote resource. -
InputStream- Raw contents ofInputStreamwill be serialized to remote resource. -
HttpResource- Raw contents will be serialized to remote resource. Additional headers and media type will be set on request. -
HttpEntity/BasicHttpEntity- Bypass Juneau serialization and pass HttpEntity directly to HttpClient. -
Object- POJO to be converted to text using theSerializerregistered with theRestClient. -
PartList- Converted to a URL-encoded FORM post.
Can benull (no body will be sent).-
- Returns:
- This object.
-
formDataPairs
Adds form-data parameters to the request body using free-form key/value pairs.Example:
// Creates form data "key1=val1&key2=val2". client .formPost(URI ) .formDataPairs("key1" ,"val1" ,"key2" ,"val2" ) .run();- Parameters:
pairs- The form-data key/value pairs.- Values can be any POJO.
- Values converted to a string using the configured part serializer.
Cannot benull .
Must have an even number of elements (key/value pairs).
Null keys are ignored (parameter will not be created).
Null values are allowed.- Returns:
- This object.
- Throws:
RestCallException- Invalid input.
-
getAllHeaders
Returns all the headers of this message. Headers are ordered in the sequence they will be sent over a connection.- Specified by:
getAllHeadersin interfaceHttpMessage- Returns:
- All the headers of this message
-
getConfig
Returns the actual request configuration.- Specified by:
getConfigin interfaceConfigurable- Returns:
- The actual request configuration.
-
getFirstHeader
Returns the first header with a specified name of this message. Header values are ignored.
If there is more than one matching header in the message the first element ofgetHeaders(String)is returned.
If there is no matching header in the messagenull is returned.- Specified by:
getFirstHeaderin interfaceHttpMessage- Parameters:
name- The name of the header to return.
Cannot benull .- Returns:
- The first header whose name property equals name or
null if no such header could be found.
-
getFormData
Returns the form data for the request.- Returns:
- An immutable list of form data to send on the request.
-
getHeaders
Returns the header data for the request.- Returns:
- An immutable list of headers to send on the request.
-
getHeaders
Returns all the headers with a specified name of this message. Header values are ignored.
Headers are ordered in the sequence they will be sent over a connection.- Specified by:
getHeadersin interfaceHttpMessage- Parameters:
name- The name of the headers to return.
Cannot benull .- Returns:
- The headers whose name property equals name.
-
getHttpEntity
Returns the body of this request.- Returns:
- The body of this request, or
null if it doesn't have a body.
-
getLastHeader
Returns the last header with a specified name of this message. Header values are ignored.
If there is more than one matching header in the message the last element ofgetHeaders(String)is returned.
If there is no matching header in the message null is returned.- Specified by:
getLastHeaderin interfaceHttpMessage- Parameters:
name- The name of the header to return.
Cannot benull .- Returns:
- The last header whose name property equals name or
null if no such header could be found.
-
getMethod
Returns the HTTP method this request uses, such as GET, PUT, POST, or other.- Specified by:
getMethodin interfaceHttpUriRequest- Returns:
- The HTTP method this request uses, such as GET, PUT, POST, or other.
-
getParams
Deprecated.Use constructor parameters of configuration API provided by HttpClient.Returns the parameters effective for this message as set bysetParams(HttpParams).- Specified by:
getParamsin interfaceHttpMessage- Returns:
- The parameters effective for this message as set by
setParams(HttpParams).
-
getPathData
Returns the path data for the request.- Returns:
- An immutable list of path data to send on the request.
-
getProtocolVersion
Returns the protocol version this message is compatible with.- Specified by:
getProtocolVersionin interfaceHttpMessage- Returns:
- The protocol version.
-
getQueryData
Returns the query data for the request.- Returns:
- An immutable list of query data to send on the request.
-
getRequestLine
Returns the request line of this request.- Specified by:
getRequestLinein interfaceHttpRequest- Returns:
- The request line.
-
getResponse
A shortcut for callingrun().getContent().as( .type )- Type Parameters:
T- The object type to create.- Parameters:
type- The object type to create.
Cannot benull .- Returns:
- The response content as a simple string.
- Throws:
RestCallException- If an exception or non-200 response code occurred during the connection attempt.- See Also:
-
getResponse
A shortcut for callingrun().getContent().as( .type ,args )- Type Parameters:
T- The object type to create.- Parameters:
type- The object type to create.
Can be any of the following:ClassMeta,Class,ParameterizedType,GenericArrayType
Cannot benull .args- The type arguments of the class if it's a collection or map.
Can be any of the following:ClassMeta,Class,ParameterizedType,GenericArrayType
Ignored if the main type is not a map or collection.
Can containnull values (ignored).- Returns:
- The response content as a simple string.
- Throws:
RestCallException- If an exception or non-200 response code occurred during the connection attempt.- See Also:
-
getResponseAsString
A shortcut for callingrun().getContent().asString() .- Returns:
- The response content as a simple string.
- Throws:
RestCallException- If an exception or non-200 response code occurred during the connection attempt.
-
getURI
Returns the original request URI.Notes:
- URI remains unchanged in the course of request execution and is not updated if the request is redirected to another location.
- Specified by:
getURIin interfaceHttpUriRequest- Returns:
- The original request URI.
-
hasHttpEntity
Returnstrue if this request has a body.- Returns:
true if this request has a body.
-
header
Appends a header to the request.Example:
// Adds header "Foo: bar". client .get(URI ) .header(Accept.TEXT_XML ) .run();- Parameters:
part- The parameter to set.null values are ignored.- Returns:
- This object.
-
header
Appends a header to the request.Example:
// Adds header "Foo: bar". client .get(URI ) .header("Foo" ,"bar" ) .run();- Parameters:
name- The parameter name.value- The parameter value.
Non-string values are converted to strings using theHttpPartSerializerdefined on the client.- Returns:
- This object.
-
headerIterator
Returns an iterator of all the headers.- Specified by:
headerIteratorin interfaceHttpMessage- Returns:
- Iterator that returns
Headerobjects in the sequence they are sent over a connection.
-
headerIterator
Returns an iterator of the headers with a given name.- Specified by:
headerIteratorin interfaceHttpMessage- Parameters:
name- the name of the headers over which to iterate, ornull for all headers.- Returns:
- Iterator that returns
Headerobjects with the argument name in the sequence they are sent over a connection.
-
headerPairs
Appends multiple headers to the request using freeform key/value pairs.Example:
// Adds headers "Foo: bar" and "Baz: qux". client .get(URI ) .headerPairs("Foo" ,"bar" ,"Baz" ,"qux" ) .run();- Parameters:
pairs- The header key/value pairs.
Cannot benull .
Must have an even number of elements (key/value pairs).
Null keys are ignored (header will not be created).
Null values are allowed.- Returns:
- This object.
-
headers
Appends multiple headers to the request.Example:
// Appends two headers to the request. client .get(URI ) .headers( BasicHeader.of ("Foo" ,"bar" ), Accept.TEXT_XML ) .run();- Parameters:
parts- The parameters to set.null values are ignored.- Returns:
- This object.
-
headersBean
Appends multiple headers to the request from properties defined on a Java bean.Uses
PropertyNamerDUCSfor resolving the header names from property names.Example:
@Bean public class MyHeaders {public String getFooBar() {return "baz" ; }public Integer getQux() {return 123; } }// Appends headers "Foo-Bar: baz" and "Qux: 123". client .get(URI ) .headersBean(new MyHeaders()) .run();- Parameters:
value- The bean containing the properties to set as header values.
Cannot benull .- Returns:
- This object.
-
html
Convenience method for specifying HTML as the marshalling transmission media type for this request only.POJOs are converted to HTML without any sort of doc wrappers.
HtmlSerializerwill be used to serialize POJOs to request bodies unless overridden per request viaserializer(Serializer).- The serializer can be configured using any of the serializer property setters (e.g.
RestClient.Builder.sortCollections()) or bean context property setters (e.g.RestClient.Builder.swaps(Class...)) defined on this builder class.
HtmlParserwill be used to parse POJOs from response bodies unless overridden per request viaparser(Parser).- The parser can be configured using any of the parser property setters (e.g.
RestClient.Builder.strict()) or bean context property setters (e.g.RestClient.Builder.swaps(Class...)) defined on this builder class.
Accept request header will be set to"text/html" unless overridden byheader(String,Object)oraccept(String).Content-Type request header will be set to"text/html" unless overridden byheader(String,Object)orcontentType(String).Identical to calling
serializer(HtmlSerializer. .class ).parser(HtmlParser.class )- Returns:
- This object.
- The serializer can be configured using any of the serializer property setters (e.g.
-
htmlDoc
Convenience method for specifying HTML DOC as the marshalling transmission media type for this request only.POJOs are converted to fully renderable HTML pages.
HtmlDocSerializerwill be used to serialize POJOs to request bodies unless overridden per request viaserializer(Serializer).- The serializer can be configured using any of the serializer property setters (e.g.
RestClient.Builder.sortCollections()) or bean context property setters (e.g.RestClient.Builder.swaps(Class...)) defined on this builder class.
HtmlParserwill be used to parse POJOs from response bodies unless overridden per request viaparser(Parser).- The parser can be configured using any of the parser property setters (e.g.
RestClient.Builder.strict()) or bean context property setters (e.g.RestClient.Builder.swaps(Class...)) defined on this builder class.
Accept request header will be set to"text/html" unless overridden byheader(String,Object)oraccept(String).Content-Type request header will be set to"text/html" unless overridden byheader(String,Object)orcontentType(String).Identical to calling
serializer(HtmlDocSerializer. .class ).parser(HtmlParser.class )- Returns:
- This object.
- The serializer can be configured using any of the serializer property setters (e.g.
-
htmlStrippedDoc
Convenience method for specifying Stripped HTML DOC as the marshalling transmission media type for this request only.Same as
htmlDoc()but without the header and body tags and page title and description.HtmlStrippedDocSerializerwill be used to serialize POJOs to request bodies unless overridden per request viaserializer(Serializer).- The serializer can be configured using any of the serializer property setters (e.g.
RestClient.Builder.sortCollections()) or bean context property setters (e.g.RestClient.Builder.swaps(Class...)) defined on this builder class.
HtmlParserwill be used to parse POJOs from response bodies unless overridden per request viaparser(Parser).- The parser can be configured using any of the parser property setters (e.g.
RestClient.Builder.strict()) or bean context property setters (e.g.RestClient.Builder.swaps(Class...)) defined on this builder class.
Accept request header will be set to"text/html+stripped" unless overridden byheader(String,Object)oraccept(String).Content-Type request header will be set to"text/html+stripped" unless overridden byheader(String,Object)orcontentType(String).Identical to calling
serializer(HtmlStrippedDocSerializer. .class ).parser(HtmlParser.class )- Returns:
- This object.
- The serializer can be configured using any of the serializer property setters (e.g.
-
ignoreErrors
PreventRestCallExceptionsfrom being thrown when HTTP status 400+ is encountered.This overrides the
ignoreErrors property on the client.- Returns:
- This object.
-
interceptors
Add one or more interceptors for this call only.- Parameters:
interceptors- The interceptors to add to this call.
Cannot containnull values.- Returns:
- This object.
- Throws:
RestCallException- If init method on interceptor threw an exception.
-
isAborted
- Specified by:
isAbortedin interfaceHttpUriRequest
-
isDebug
Returnstrue if debug mode is currently enabled.- Overrides:
isDebugin classContextSession- Returns:
true if debug mode is enabled.- See Also:
-
json
Convenience method for specifying JSON as the marshalling transmission media type for this request only.JsonSerializerwill be used to serialize POJOs to request bodies unless overridden per request viaserializer(Serializer).- The serializer can be configured using any of the serializer property setters (e.g.
RestClient.Builder.sortCollections()) or bean context property setters (e.g.RestClient.Builder.swaps(Class...)) defined on this builder class.
JsonParserwill be used to parse POJOs from response bodies unless overridden per request viaparser(Parser).- The parser can be configured using any of the parser property setters (e.g.
RestClient.Builder.strict()) or bean context property setters (e.g.RestClient.Builder.swaps(Class...)) defined on this builder class.
Accept request header will be set to"application/json" unless overridden byheader(String,Object)oraccept(String).Content-Type request header will be set to"application/json" unless overriddenheader(String,Object)orcontentType(String).Identical to calling
serializer(JsonSerializer. .class ).parser(JsonParser.class )- Returns:
- This object.
- The serializer can be configured using any of the serializer property setters (e.g.
-
json5
Convenience method for specifying Simplified JSON as the marshalling transmission media type for this request only.Simplified JSON is typically useful for automated tests because you can do simple string comparison of results without having to escape lots of quotes.
Json5Serializerwill be used to serialize POJOs to request bodies unless overridden per request viaserializer(Serializer).- The serializer can be configured using any of the serializer property setters (e.g.
RestClient.Builder.sortCollections()) or bean context property setters (e.g.RestClient.Builder.swaps(Class...)) defined on this builder class.
Json5Parserwill be used to parse POJOs from response bodies unless overridden per request viaparser(Parser).- The parser can be configured using any of the parser property setters (e.g.
RestClient.Builder.strict()) or bean context property setters (e.g.RestClient.Builder.swaps(Class...)) defined on this builder class.
Accept request header will be set to"application/json" unless overridden byheader(String,Object)oraccept(String), or per-request viaheader(String,Object)oraccept(String).Content-Type request header will be set to"application/json+simple" unless overridden byheader(String,Object)orcontentType(String), or per-request viaheader(String,Object)orcontentType(String).Can be combined with other marshaller setters such as
xml()to provide support for multiple languages.- When multiple languages are supported, the
Accept andContent-Type headers control which marshallers are used, or uses the last-enabled language if the headers are not set.
Identical to calling
serializer(Json5Serializer. .class ).parser(Json5Parser.class )- Returns:
- This object.
- The serializer can be configured using any of the serializer property setters (e.g.
-
log
Logs a message.- Parameters:
level- The log level.
Cannot benull .msg- The message withMessageFormat-style arguments.
Cannot benull .args- The arguments.
Can containnull values.- Returns:
- This object.
-
log
Logs a message.- Parameters:
level- The log level.
Cannot benull .t- The throwable cause.
Can benull .msg- The message withMessageFormat-style arguments.
Cannot benull .args- The arguments.
Can containnull values.- Returns:
- This object.
-
mediaType
Shortcut for setting theAccept andContent-Type headers on a request.- Parameters:
value- The new header values.
Can benull (headers will not be set).- Returns:
- This object.
- Throws:
RestCallException- Invalid input.
-
msgPack
Convenience method for specifying MessagePack as the marshalling transmission media type for this request only.MessagePack is a binary equivalent to JSON that takes up considerably less space than JSON.
MsgPackSerializerwill be used to serialize POJOs to request bodies unless overridden per request viaserializer(Serializer).- The serializer can be configured using any of the serializer property setters (e.g.
RestClient.Builder.sortCollections()) or bean context property setters (e.g.RestClient.Builder.swaps(Class...)) defined on this builder class.
MsgPackParserwill be used to parse POJOs from response bodies unless overridden per request viaparser(Parser).- The parser can be configured using any of the parser property setters (e.g.
RestClient.Builder.strict()) or bean context property setters (e.g.RestClient.Builder.swaps(Class...)) defined on this builder class.
Accept request header will be set to"octal/msgpack" unless overridden byheader(String,Object)oraccept(String).Content-Type request header will be set to"octal/msgpack" unless overridden byheader(String,Object)orcontentType(String).Identical to calling
serializer(MsgPackSerializer. .class ).parser(MsgPackParser.class )- Returns:
- This object.
- The serializer can be configured using any of the serializer property setters (e.g.
-
noTrace
When called,No-Trace: true is added to requests.This gives the opportunity for the servlet to not log errors on invalid requests. This is useful for testing purposes when you don't want your log file to show lots of errors that are simply the results of testing.
- Returns:
- This object.
- Throws:
RestCallException- Invalid input.
-
openApi
Convenience method for specifying OpenAPI as the marshalling transmission media type for this request only.OpenAPI is a language that allows serialization to formats that use
HttpPartSchemaobjects to describe their structure.OpenApiSerializerwill be used to serialize POJOs to request bodies unless overridden per request viaserializer(Serializer).- The serializer can be configured using any of the serializer property setters (e.g.
RestClient.Builder.sortCollections()) or bean context property setters (e.g.RestClient.Builder.swaps(Class...)) defined on this builder class. - Typically the
content(Object, HttpPartSchema)method will be used to specify the body of the request with the schema describing it's structure.
OpenApiParserwill be used to parse POJOs from response bodies unless overridden per request viaparser(Parser).- The parser can be configured using any of the parser property setters (e.g.
RestClient.Builder.strict()) or bean context property setters (e.g.RestClient.Builder.swaps(Class...)) defined on this builder class. - Typically the
ResponseContent.schema(HttpPartSchema)method will be used to specify the structure of the response body.
Accept request header will be set to"text/openapi" unless overridden byheader(String,Object)oraccept(String).Content-Type request header will be set to"text/openapi" unless overridden byheader(String,Object)orcontentType(String).Identical to calling
serializer(OpenApiSerializer. .class ).parser(OpenApiParser.class )- Returns:
- This object.
- The serializer can be configured using any of the serializer property setters (e.g.
-
parser
Specifies the parser to use on the response body.Overrides the parsers specified on the
RestClient.The parser can be configured using any of the parser property setters (e.g.
RestClient.Builder.strict()) or bean context property setters (e.g.RestClient.Builder.swaps(Class...)) defined on this builder class.If the
Accept header is not set on the request, it will be set to the media type of this parser.- Parameters:
parser- The parser used to parse POJOs from the body of the HTTP response.
Cannot benull .- Returns:
- This object.
-
parser
Specifies the parser to use on the response body.Overrides the parsers specified on the
RestClient.The parser is not modified by any of the parser property setters (e.g.
RestClient.Builder.strict()) or bean context property setters (e.g.RestClient.Builder.swaps(Class...)) defined on this builder class.If the
Accept header is not set on the request, it will be set to the media type of this parser.- Parameters:
parser- The parser used to parse POJOs from the body of the HTTP response.
Cannot benull .- Returns:
- This object.
-
pathData
Sets or replaces multiple path parameters on the request.Example:
// Appends two path parameters to the request. client .get(URI ) .pathData( BasicStringPart.of ("foo" ,"bar" ), BasicBooleanPart.of ("baz" ,true ) ) .run();- Parameters:
parts- The parameters to set.null values are ignored.- Returns:
- This object.
-
pathData
Sets or replaces a path parameter of the form"{name}" in the URI.Example:
// Sets path to "/bar". client .get("/{foo}" ) .pathData("foo" ,"bar" ) .run();- Parameters:
name- The parameter name.
Cannot benull or empty (parameter will not be created).value- The parameter value.
Non-string values are converted to strings using theHttpPartSerializerdefined on the client.
Can benull .- Returns:
- This object.
-
pathDataBean
Sets multiple path parameters to the request from properties defined on a Java bean.Example:
public class MyPathVars {public String getFooBar() {return "baz" ; }public Integer getQux() {return 123; } }// Given path "/{fooBar}/{qux}/", gets converted to "/baz/123/". client .get(URI ) .pathDataBean(new MyPathVars()) .run();- Parameters:
value- The bean containing the properties to set as path parameter values.
Cannot benull .- Returns:
- This object.
-
pathDataPairs
Replaces path parameters of the form"{name}" in the URI using free-form key/value pairs.Example:
// Sets path to "/baz/qux". client .get("/{foo}/{bar}" ) .pathDataPairs("foo" ,"baz" ,"bar" ,"qux" ) .run();- Parameters:
pairs- The path key/value pairs.- Values can be any POJO.
- Values converted to a string using the configured part serializer.
Cannot benull .
Must have an even number of elements (key/value pairs).
Null keys are ignored (parameter will not be created).
Null values are allowed.- Returns:
- This object.
-
plainText
Convenience method for specifying Plain Text as the marshalling transmission media type for this request only.Plain text marshalling typically only works on simple POJOs that can be converted to and from strings using swaps, swap methods, etc...
PlainTextSerializerwill be used to serialize POJOs to request bodies unless overridden per request viaserializer(Serializer).- The serializer can be configured using any of the serializer property setters (e.g.
RestClient.Builder.sortCollections()) or bean context property setters (e.g.RestClient.Builder.swaps(Class...)) defined on this builder class.
PlainTextParserwill be used to parse POJOs from response bodies unless overridden per request viaparser(Parser).- The parser can be configured using any of the parser property setters (e.g.
RestClient.Builder.strict()) or bean context property setters (e.g.RestClient.Builder.swaps(Class...)) defined on this builder class.
Accept request header will be set to"text/plain" unless overridden byheader(String,Object)oraccept(String).Content-Type request header will be set to"text/plain" unless overridden byheader(String,Object)orcontentType(String).Identical to calling
serializer(PlainTextSerializer. .class ).parser(PlainTextParser.class )- Returns:
- This object.
- The serializer can be configured using any of the serializer property setters (e.g.
-
protocolVersion
Sets the protocol version for this request.- Parameters:
version- The protocol version for this request.
Can benull (default protocol version will be used).- Returns:
- This object.
-
queryCustom
Adds a free-form custom query.Example:
// Adds query parameter "foo=bar&baz=qux". client .get(URI ) .queryCustom("foo=bar&baz=qux" ) .run();- Parameters:
value- The parameter value.
Can be any of the following types:-
CharSequence -
Reader- Raw contents ofReaderwill be serialized to remote resource. -
InputStream- Raw contents ofInputStreamwill be serialized to remote resource. -
PartList- Converted to a URL-encoded query.
Can benull (no custom query will be set).-
- Returns:
- This object.
-
queryData
Appends multiple query parameters to the request.Example:
// Appends two query parameters to the request. client .get(URI ) .queryData( BasicStringPart.of ("foo" ,"bar" ), BasicBooleanPart.of ("baz" ,true ) ) .run();- Parameters:
parts- The parameters to set.null values are ignored.- Returns:
- This object.
-
queryData
Appends a query parameter to the URI of the request.Example:
// Adds query parameter "foo=bar". client .get(URI ) .queryData("foo" ,"bar" ) .run();- Parameters:
name- The parameter name.
Cannot benull or empty (parameter will not be created).value- The parameter value.
Non-string values are converted to strings using theHttpPartSerializerdefined on the client.
Can benull .- Returns:
- This object.
-
queryDataBean
Appends multiple query parameters to the request from properties defined on a Java bean.Example:
public class MyQuery {public String getFooBar() {return "baz" ; }public Integer getQux() {return 123; } }// Appends query "fooBar=baz&qux=123". client .get(URI ) .queryDataBean(new MyQuery()) .run();- Parameters:
value- The bean containing the properties to set as query parameter values.
Cannot benull .- Returns:
- This object.
-
queryDataPairs
Adds query parameters to the URI query using free-form key/value pairs..Example:
// Adds query parameters "foo=bar&baz=qux". client .get(URI ) .queryDataPairs("foo" ,"bar" ,"baz" ,"qux" ) .run();- Parameters:
pairs- The query key/value pairs.- Values can be any POJO.
- Values converted to a string using the configured part serializer.
Cannot benull .
Must have an even number of elements (key/value pairs).
Null keys are ignored (parameter will not be created).
Null values are allowed.- Returns:
- This object.
- Throws:
RestCallException- Invalid input.
-
removeHeader
Removes a header from this message.- Specified by:
removeHeaderin interfaceHttpMessage- Parameters:
header- The header to remove.
Can benull (no-op).
-
removeHeaders
Removes all headers with a certain name from this message.- Specified by:
removeHeadersin interfaceHttpMessage- Parameters:
name- The name of the headers to remove.
Cannot benull .
-
rethrow
Rethrow any of the specified exception types if a matchingException-Name header is found.Rethrown exceptions will be set on the caused-by exception of
RestCallExceptionwhen thrown from therun()method.Can be called multiple times to append multiple rethrows.
- Parameters:
values- The classes to rethrow.
Cannot benull .
Null elements are ignored (only non-null classes that extendThrowableare added).- Returns:
- This object.
-
run
Runs this request and returns the resulting response object.Example:
try {int rc =client .get(URI ).execute().getResponseStatus();// Succeeded! }catch (RestCallExceptione ) {// Failed! }Notes:
- Calling this method multiple times will return the same original response object.
- You must close the returned object if you do not consume the response or execute a method that consumes the response.
- If you are only interested in the response code, use the
complete()method which will automatically consume the response so that you don't need to callInputStream.close()on the response body.
- Returns:
- The response object.
- Throws:
RestCallException- If an exception or non-200 response code occurred during the connection attempt.
-
runFuture
Same asrun()but allows you to run the call asynchronously.Example:
Future<RestResponse>
future =client .get(URI ).runFuture();// Do some other stuff try { Stringbody =future .get().getContent().asString();// Succeeded! }catch (RestCallExceptione ) {// Failed! }Notes:
- Use the
RestClient.Builder.executorService(ExecutorService, boolean)method to customize the executor service used for creatingFutures.
- Returns:
- The HTTP status code.
- Throws:
RestCallException- If the executor service was not defined.
- Use the
-
serializer
Specifies the serializer to use on the request body.Overrides the serializers specified on the
RestClient.The serializer can be configured using any of the serializer property setters (e.g.
RestClient.Builder.sortCollections()) or bean context property setters (e.g.RestClient.Builder.swaps(Class...)) defined on this builder class.If the
Content-Type header is not set on the request, it will be set to the media type of this serializer.- Parameters:
serializer- The serializer used to serialize POJOs to the body of the HTTP request.
Can benull (will use default serializer matching Content-Type).- Returns:
- This object.
-
serializer
Specifies the serializer to use on the request body.Overrides the serializers specified on the
RestClient.The serializer is not modified by an of the serializer property setters (e.g.
RestClient.Builder.sortCollections()) or bean context property setters (e.g.RestClient.Builder.swaps(Class...)) defined on this builder class.If the
Content-Type header is not set on the request, it will be set to the media type of this serializer.- Parameters:
serializer- The serializer used to serialize POJOs to the body of the HTTP request.
Can benull (will use default serializer matching Content-Type).- Returns:
- This object.
-
setHeader
Overwrites the first header with the same name. The new header will be appended to the end of the list, if no header with the given name can be found.- Specified by:
setHeaderin interfaceHttpMessage- Parameters:
header- The header to set.
Can benull (ignored).
-
setHeader
Overwrites the first header with the same name. The new header will be appended to the end of the list, if no header with the given name can be found.- Specified by:
setHeaderin interfaceHttpMessage- Parameters:
name- The name of the header.
Cannot benull or empty (header will not be created).value- The value of the header.
Can benull .
-
setHeaders
Overwrites all the headers in the message.- Specified by:
setHeadersin interfaceHttpMessage- Parameters:
headers- The array of headers to set.
Can benull (all headers will be cleared).
Can containnull values (ignored).
-
setParams
Deprecated.Use constructor parameters of configuration API provided by HttpClient.Provides parameters to be used for the processing of this message.- Specified by:
setParamsin interfaceHttpMessage- Parameters:
params- The parameters.
Can benull (default parameters will be used).
-
suppressLogging
Causes logging to be suppressed for the duration of this request.Overrides the
debug()setting on this request or client.- Returns:
- This object.
-
target
Specifies the target host for the request.- Parameters:
target- The target host for the request. Implementations may acceptnull if they can still determine a route, for example to a default target or by inspecting the request.- Returns:
- This object.
-
uon
Convenience method for specifying UON as the marshalling transmission media type for this request only.UON is Url-Encoding Object notation that is equivalent to JSON but suitable for transmission as URL-encoded query and form post values.
UonSerializerwill be used to serialize POJOs to request bodies unless overridden per request viaserializer(Serializer).- The serializer can be configured using any of the serializer property setters (e.g.
RestClient.Builder.sortCollections()) or bean context property setters (e.g.RestClient.Builder.swaps(Class...)) defined on this builder class.
UonParserwill be used to parse POJOs from response bodies unless overridden per request viaparser(Parser).- The parser can be configured using any of the parser property setters (e.g.
RestClient.Builder.strict()) or bean context property setters (e.g.RestClient.Builder.swaps(Class...)) defined on this builder class.
Accept request header will be set to"text/uon" unless overridden byheader(String,Object)oraccept(String).Content-Type request header will be set to"text/uon" unless overridden byheader(String,Object)orcontentType(String).Identical to calling
serializer(UonSerializer. .class ).parser(UonParser.class )- Returns:
- This object.
- The serializer can be configured using any of the serializer property setters (e.g.
-
uri
Sets the URI for this request.Can be any of the following types:
URIURLURIBuilder- Anything else converted to a string using
Object.toString().
Relative URI strings will be interpreted as relative to the root URI defined on the client.
- Parameters:
uri- The URI of the remote REST resource.
This overrides the URI passed in from the client.
Can be any of the following types:URIBuilderURIURLStringObject- Converted toString usingtoString()
Cannot benull .- Returns:
- This object.
- Throws:
RestCallException- Invalid URI syntax detected.
-
uriFragment
Sets the URI fragment.- Parameters:
fragment- The URI fragment. The value is expected to be unescaped and may contain non ASCII characters.
Can benull (fragment will be cleared).- Returns:
- This object.
-
uriHost
Sets the URI host.- Parameters:
host- The new URI host.
Can benull (host will be cleared).- Returns:
- This object.
-
uriPort
Sets the URI port.- Parameters:
port- The new URI port.- Returns:
- This object.
-
uriScheme
Sets the URI scheme.- Parameters:
scheme- The new URI scheme.
Can benull (scheme will be cleared).- Returns:
- This object.
-
uriUserInfo
Sets the URI user info.- Parameters:
userInfo- The new URI user info.
Can benull (user info will be cleared).- Returns:
- This object.
-
uriUserInfo
Sets the URI user info.- Parameters:
username- The new URI username.
Can benull .password- The new URI password.
Can benull .- Returns:
- This object.
-
urlEnc
Convenience method for specifying URL-Encoding as the marshalling transmission media type for this request only.UrlEncodingSerializerwill be used to serialize POJOs to request bodies unless overridden per request viaserializer(Serializer).- The serializer can be configured using any of the serializer property setters (e.g.
RestClient.Builder.sortCollections()) or bean context property setters (e.g.RestClient.Builder.swaps(Class...)) defined on this builder class. - This serializer is NOT used when using the
formData(String, Object)(and related) methods for constructing the request body. Instead, the part serializer specified viaRestClient.Builder.partSerializer(Class)is used.
UrlEncodingParserwill be used to parse POJOs from response bodies unless overridden per request viaparser(Parser).- The parser can be configured using any of the parser property setters (e.g.
RestClient.Builder.strict()) or bean context property setters (e.g.RestClient.Builder.swaps(Class...)) defined on this builder class.
Accept request header will be set to"application/x-www-form-urlencoded" unless overridden byheader(String,Object)oraccept(String).Content-Type request header will be set to"application/x-www-form-urlencoded" unless overridden byheader(String,Object)orcontentType(String).Identical to calling
serializer(UrlEncodingSerializer. .class ).parser(UrlEncodingParser.class )- Returns:
- This object.
- The serializer can be configured using any of the serializer property setters (e.g.
-
xml
Convenience method for specifying XML as the marshalling transmission media type for this request only.XmlSerializerwill be used to serialize POJOs to request bodies unless overridden per request viaserializer(Serializer).- The serializer can be configured using any of the serializer property setters (e.g.
RestClient.Builder.sortCollections()) or bean context property setters (e.g.RestClient.Builder.swaps(Class...)) defined on this builder class.
XmlParserwill be used to parse POJOs from response bodies unless overridden per request viaparser(Parser).- The parser can be configured using any of the parser property setters (e.g.
RestClient.Builder.strict()) or bean context property setters (e.g.RestClient.Builder.swaps(Class...)) defined on this builder class.
Accept request header will be set to"text/xml" unless overridden byheader(String,Object)oraccept(String).Content-Type request header will be set to"text/xml" unless overridden byheader(String,Object)orcontentType(String).Identical to calling
serializer(XmlSerializer. .class ).parser(XmlParser.class )- Returns:
- This object.
- The serializer can be configured using any of the serializer property setters (e.g.
-
createHeader
protected Header createHeader(String name, Object value, HttpPartSerializer serializer, HttpPartSchema schema, Boolean skipIfEmpty) Creates a new header.- Parameters:
name- The header name.value- The header value.serializer- The part serializer to use, ornull to use the part serializer defined on the client.schema- Optional HTTP part schema to provide to the part serializer.skipIfEmpty- Iftrue , empty string values will be ignored on the request.- Returns:
- A new header.
-
createInnerRequest
Constructs theHttpRequestBaseobject that ends up being passed to the client execute method.Subclasses can override this method to create their own request base objects.
- Parameters:
method- The HTTP method.uri- The HTTP URI.hasBody- Whether the HTTP request has a body.- Returns:
- A new
HttpRequestBaseobject.
-
createPart
protected NameValuePair createPart(String name, Object value, HttpPartType type, HttpPartSerializer serializer, HttpPartSchema schema, Boolean skipIfEmpty) Creates a new query/form-data/path part.- Parameters:
name- The part name.value- The part value.type- The HTTP part type.serializer- The part serializer to use, ornull to use the part serializer defined on the client.schema- Optional HTTP part schema to provide to the part serializer.skipIfEmpty- Iftrue , empty string values will be ignored on the request.- Returns:
- A new part.
-
properties
Description copied from class:ContextSessionReturns the properties on this bean as a map for debugging.- Overrides:
propertiesin classBeanSession- Returns:
- The properties on this bean as a map for debugging.
-