Class MockRestClient
- All Implemented Interfaces:
Closeable
,AutoCloseable
,HttpClient
,HttpClientConnection
,HttpConnection
,AnnotationProvider
RestClient
.
This class is used for performing serverless unit testing of @Rest
-annotated and @Remote
-annotated classes.
The class itself extends from RestClient
providing it with the rich feature set of that API and combines
it with the Apache HttpClient HttpClientConnection
interface for processing requests.
The class converts HttpRequest
objects to instances of MockServletRequest
and MockServletResponse
which are passed directly
to the call handler on the resource class RestContext.execute(Object,HttpServletRequest,HttpServletResponse)
.
In effect, you're fully testing your REST API as if it were running in a live servlet container, yet not
actually having to run in a servlet container.
All aspects of the client and server side code are tested, yet no servlet container is required. The actual
over-the-wire transmission is the only aspect being bypassed.
The following shows a simple example of invoking a PUT method on a simple REST interface and asserting the correct status code and response body:
Example:
Breaking apart the fluent method call above will help you understand how this works.
The
The MockRestRequest
object has convenience methods provided to allow you to set any properties
directly on the underlying HttpServletRequest
object. The following example shows how
this can be used to directly set roles on the request object to perform security testing.
Example:
Debug mode is provided that will cause your HTTP requests and responses to be sent to the console:
Example:
MockRestClient
The class can also be used for testing of @Remote
-annotated interfaces against @Rest
-annotated resources.
Example:
Notes:
- This class is thread safe and reusable.
See Also:
-
Nested Class Summary
-
Field Summary
Fields inherited from class org.apache.juneau.Context
CONTEXT_APPLY_FILTER
Fields inherited from interface org.apache.juneau.AnnotationProvider
DEFAULT, DISABLE_ANNOTATION_CACHING
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic MockRestClient
Creates a newRestClient
with no registered serializer or parser.static MockRestClient
Creates a newRestClient
with JSON marshalling support.static MockRestClient
buildJson5
(Object impl) Creates a newRestClient
with Simplified-JSON marshalling support.static MockRestClient
buildJson5Lax
(Object impl) Creates a newRestClient
with Simplified-JSON marshalling support.static MockRestClient
buildJsonLax
(Object impl) Creates a newRestClient
with JSON marshalling support.static MockRestClient
Creates a newRestClient
with no registered serializer or parser.Performs a REST call where the entire call is specified in a simple string.void
close()
CallsCloseable.close()
on the underlyingCloseableHttpClient
.static MockRestClient.Builder
Creates a newRestClient.Builder
configured with the specified REST implementation bean or bean class.static MockRestClient.Builder
Creates a newRestClient.Builder
configured with the specified REST implementation bean or bean class.protected MockRestRequest
createRequest
(URI uri, String method, boolean hasBody) Creates aRestRequest
object from the specifiedHttpRequest
object.protected MockRestResponse
createResponse
(RestRequest req, HttpResponse httpResponse, Parser parser) Creates aRestResponse
object from the specifiedHttpResponse
object.Perform aDELETE request against the specified URI.void
flush()
Same asRestClient.formPost(Object, Object)
but doesn't specify the input yet.Perform aPOST request with a content type ofapplication/x-www-form-urlencoded against the specified URI.formPostPairs
(Object url, String... parameters) Perform aPOST request with a content type ofapplication/x-www-form-urlencoded against the specified URI.get()
Perform aGET request against the root URI.Perform aGET request against the specified URI.Returns the current client-side REST request.Returns the current client-side REST response.Returns the current server-side REST request.Returns the current server-side REST response.int
Perform aHEAD request against the specified URI.boolean
isOpen()
boolean
isResponseAvailable
(int timeout) boolean
isStale()
Perform anOPTIONS request against the specified URI.Same asRestClient.patch(Object, Object)
but don't specify the input yet.Perform aPATCH request against the specified URI.patch
(Object url, String body, ContentType contentType) Perform aPATCH request against the specified URI as a plain text body bypassing the serializer.Same asRestClient.post(Object, Object)
but don't specify the input yet.Perform aPOST request against the specified URI.post
(Object url, String body, ContentType contentType) Perform aPOST request against the specified URI as a plain text body bypassing the serializer.Same asRestClient.put(Object, Object)
but don't specify the input yet.Perform aPUT request against the specified URI.put
(Object url, String body, ContentType contentType) Perform aPUT request against the specified URI using a plain text body bypassing the serializer.void
receiveResponseEntity
(HttpResponse response) Perform a generic REST call.Perform a generic REST call.Perform a generic REST call.request
(RestOperation op) Perform an arbitrary request against the specified URI.void
void
sendRequestHeader
(HttpRequest request) void
setSocketTimeout
(int timeout) void
shutdown()
Methods inherited from class org.apache.juneau.rest.client.RestClient
closeQuietly, copy, create, createFormData, createHeaderData, createPathData, createQueryData, execute, execute, execute, execute, execute, execute, execute, execute, finalize, getConnectionManager, getHttpClientConnectionManager, getParams, getPartParser, getPartParser, getPartSerializer, getPartSerializer, getRemote, getRemote, getRemote, getRrpcInterface, getRrpcInterface, getRrpcInterface, init, init, isSkipEmptyFormData, isSkipEmptyHeaderData, isSkipEmptyQueryData, log, log, onCallClose, onCallConnect, onCallInit, properties, run
Methods inherited from class org.apache.juneau.BeanContextable
getBeanContext
Methods inherited from class org.apache.juneau.Context
createBuilder, createSession, firstAnnotation, firstAnnotation, firstAnnotation, firstAnnotation, firstDeclaredAnnotation, forEachAnnotation, forEachAnnotation, forEachAnnotation, forEachAnnotation, forEachDeclaredAnnotation, getSession, hasAnnotation, hasAnnotation, hasAnnotation, hasAnnotation, init, isDebug, lastAnnotation, lastAnnotation, lastAnnotation, lastAnnotation, lastDeclaredAnnotation, toString
-
Constructor Details
-
MockRestClient
Constructor.- Parameters:
builder
- The builder for this object.
-
-
Method Details
-
create
Creates a newRestClient.Builder
configured with the specified REST implementation bean or bean class.- Parameters:
impl
- The REST bean or bean class annotated with@Rest
.
If a class, it must have a no-arg constructor.- Returns:
- A new builder.
-
createLax
Creates a newRestClient.Builder
configured with the specified REST implementation bean or bean class.Same as
create(Object)
but HTTP 400+ codes don't triggerRestCallExceptions
.- Parameters:
impl
- The REST bean or bean class annotated with@Rest
.
If a class, it must have a no-arg constructor.- Returns:
- A new builder.
-
build
Creates a newRestClient
with no registered serializer or parser.Equivalent to calling:
MockRestClient.
create (impl ).build();- Parameters:
impl
- The REST bean or bean class annotated with@Rest
.
If a class, it must have a no-arg constructor.- Returns:
- A new builder.
-
buildLax
Creates a newRestClient
with no registered serializer or parser.Same as
build(Object)
but HTTP 400+ codes don't triggerRestCallExceptions
.Equivalent to calling:
MockRestClient.
create (impl ).ignoreErrors().noTrace().build();- Parameters:
impl
- The REST bean or bean class annotated with@Rest
.
If a class, it must have a no-arg constructor.- Returns:
- A new builder.
-
buildJson
Creates a newRestClient
with JSON marshalling support.Equivalent to calling:
MockRestClient.
create (impl ).json().build();- Parameters:
impl
- The REST bean or bean class annotated with@Rest
.
If a class, it must have a no-arg constructor.- Returns:
- A new builder.
-
buildJsonLax
Creates a newRestClient
with JSON marshalling support.Same as
buildJson(Object)
but HTTP 400+ codes don't triggerRestCallExceptions
.Equivalent to calling:
MockRestClient.
create (impl ).json().ignoreErrors().build();- Parameters:
impl
- The REST bean or bean class annotated with@Rest
.
If a class, it must have a no-arg constructor.- Returns:
- A new builder.
-
buildJson5
Creates a newRestClient
with Simplified-JSON marshalling support.Equivalent to calling:
MockRestClient.
create (impl ).json().build();- Parameters:
impl
- The REST bean or bean class annotated with@Rest
.
If a class, it must have a no-arg constructor.- Returns:
- A new builder.
-
buildJson5Lax
Creates a newRestClient
with Simplified-JSON marshalling support.Same as
buildJson5(Object)
but HTTP 400+ codes don't triggerRestCallExceptions
.Equivalent to calling:
MockRestClient.
create (impl ).json().ignoreErrors().build();- Parameters:
impl
- The REST bean or bean class annotated with@Rest
.
If a class, it must have a no-arg constructor.- Returns:
- A new builder.
-
request
Description copied from class:RestClient
Perform an arbitrary request against the specified URI.All requests feed through this method so it can be used to intercept request creations and make modifications (such as add headers).
- Overrides:
request
in classRestClient
- Parameters:
op
- The operation that identifies the HTTP method, URL, and optional payload.- Returns:
- A
RestRequest
object that can be further tailored before executing the request and getting the response as a parsed object. - Throws:
RestCallException
- If any authentication errors occurred.
-
get
Description copied from class:RestClient
Perform aGET request against the specified URI.- Overrides:
get
in classRestClient
- Parameters:
url
- The URI of the remote REST resource.
Can be any of the following types:URIBuilder
URI
URL
String
Object
- Converted toString usingtoString()
- Returns:
- A
RestRequest
object that can be further tailored before executing the request and getting the response as a parsed object. - Throws:
RestCallException
- If any authentication errors occurred.
-
get
Description copied from class:RestClient
Perform aGET request against the root URI.- Overrides:
get
in classRestClient
- Returns:
- A
RestRequest
object that can be further tailored before executing the request and getting the response as a parsed object. - Throws:
RestCallException
- If any authentication errors occurred.
-
put
Description copied from class:RestClient
Perform aPUT request against the specified URI.- Overrides:
put
in classRestClient
- Parameters:
url
- The URI of the remote REST resource.
Can be any of the following types:URIBuilder
URI
URL
String
Object
- Converted toString usingtoString()
body
- The object to serialize and transmit to the URI as the body of the request. Can be of the following types:-
Reader
- Raw contents ofReader
will be serialized to remote resource. -
InputStream
- Raw contents ofInputStream
will be serialized to remote resource. -
Object
- POJO to be converted to text using theSerializer
registered with theRestClient
. -
HttpEntity
/HttpResource
- Bypass Juneau serialization and pass HttpEntity directly to HttpClient. -
PartList
- Converted to a URL-encoded FORM post. -
Supplier
- A supplier of anything on this list.
-
- Returns:
- A
RestRequest
object that can be further tailored before executing the request and getting the response as a parsed object. - Throws:
RestCallException
- If any authentication errors occurred.
-
put
public MockRestRequest put(Object url, String body, ContentType contentType) throws RestCallException Description copied from class:RestClient
Perform aPUT request against the specified URI using a plain text body bypassing the serializer.- Overrides:
put
in classRestClient
- Parameters:
url
- The URI of the remote REST resource.
Can be any of the following types:URIBuilder
URI
URL
String
Object
- Converted toString usingtoString()
body
- The object to serialize and transmit to the URI as the body of the request bypassing the serializer.contentType
- The content type of the request.- Returns:
- A
RestRequest
object that can be further tailored before executing the request and getting the response as a parsed object. - Throws:
RestCallException
- If any authentication errors occurred.
-
put
Description copied from class:RestClient
Same asRestClient.put(Object, Object)
but don't specify the input yet.You must call either
RestRequest.content(Object)
orRestRequest.formData(String, Object)
to set the contents on the result object.- Overrides:
put
in classRestClient
- Parameters:
url
- The URI of the remote REST resource.
Can be any of the following types:URIBuilder
URI
URL
String
Object
- Converted toString usingtoString()
- Returns:
- A
RestRequest
object that can be further tailored before executing the request and getting the response as a parsed object. - Throws:
RestCallException
- REST call failed.
-
post
Description copied from class:RestClient
Perform aPOST request against the specified URI.Notes:
- Use
RestClient.formPost(Object, Object)
forapplication/x-www-form-urlencoded form posts.
- Overrides:
post
in classRestClient
- Parameters:
url
- The URI of the remote REST resource.
Can be any of the following types:URIBuilder
URI
URL
String
Object
- Converted toString usingtoString()
body
- The object to serialize and transmit to the URI as the body of the request. Can be of the following types:-
Reader
- Raw contents ofReader
will be serialized to remote resource. -
InputStream
- Raw contents ofInputStream
will be serialized to remote resource. -
Object
- POJO to be converted to text using theSerializer
registered with theRestClient
. -
HttpEntity
/HttpResource
- Bypass Juneau serialization and pass HttpEntity directly to HttpClient. -
PartList
- Converted to a URL-encoded FORM post. -
Supplier
- A supplier of anything on this list.
-
- Returns:
- A
RestRequest
object that can be further tailored before executing the request and getting the response as a parsed object. - Throws:
RestCallException
- If any authentication errors occurred.
- Use
-
post
public MockRestRequest post(Object url, String body, ContentType contentType) throws RestCallException Description copied from class:RestClient
Perform aPOST request against the specified URI as a plain text body bypassing the serializer.- Overrides:
post
in classRestClient
- Parameters:
url
- The URI of the remote REST resource.
Can be any of the following types:URIBuilder
URI
URL
String
Object
- Converted toString usingtoString()
body
- The object to serialize and transmit to the URI as the body of the request bypassing the serializer.contentType
- The content type of the request.- Returns:
- A
RestRequest
object that can be further tailored before executing the request and getting the response as a parsed object. - Throws:
RestCallException
- If any authentication errors occurred.
-
post
Description copied from class:RestClient
Same asRestClient.post(Object, Object)
but don't specify the input yet.You must call either
RestRequest.content(Object)
orRestRequest.formData(String, Object)
to set the contents on the result object.Notes:
- Use
RestClient.formPost(Object, Object)
forapplication/x-www-form-urlencoded form posts.
- Overrides:
post
in classRestClient
- Parameters:
url
- The URI of the remote REST resource.
Can be any of the following types:URIBuilder
URI
URL
String
Object
- Converted toString usingtoString()
- Returns:
- A
RestRequest
object that can be further tailored before executing the request and getting the response as a parsed object. - Throws:
RestCallException
- REST call failed.
- Use
-
delete
Description copied from class:RestClient
Perform aDELETE request against the specified URI.- Overrides:
delete
in classRestClient
- Parameters:
url
- The URI of the remote REST resource.
Can be any of the following types:URIBuilder
URI
URL
String
Object
- Converted toString usingtoString()
- Returns:
- A
RestRequest
object that can be further tailored before executing the request and getting the response as a parsed object. - Throws:
RestCallException
- If any authentication errors occurred.
-
options
Description copied from class:RestClient
Perform anOPTIONS request against the specified URI.- Overrides:
options
in classRestClient
- Parameters:
url
- The URI of the remote REST resource.
Can be any of the following types:URIBuilder
URI
URL
String
Object
- Converted toString usingtoString()
- Returns:
- A
RestRequest
object that can be further tailored before executing the request and getting the response as a parsed object. - Throws:
RestCallException
- If any authentication errors occurred.
-
head
Description copied from class:RestClient
Perform aHEAD request against the specified URI.- Overrides:
head
in classRestClient
- Parameters:
url
- The URI of the remote REST resource.
Can be any of the following types:URIBuilder
URI
URL
String
Object
- Converted toString usingtoString()
- Returns:
- A
RestRequest
object that can be further tailored before executing the request and getting the response as a parsed object. - Throws:
RestCallException
- If any authentication errors occurred.
-
formPost
Description copied from class:RestClient
Perform aPOST request with a content type ofapplication/x-www-form-urlencoded against the specified URI.- Overrides:
formPost
in classRestClient
- Parameters:
url
- The URI of the remote REST resource.
Can be any of the following types:URIBuilder
URI
URL
String
Object
- Converted toString usingtoString()
body
- The object to serialize and transmit to the URI as the body of the request.NameValuePair
- URL-encoded as a single name-value pair.NameValuePair
array - URL-encoded as name value pairs.PartList
- URL-encoded as name value pairs.Reader
/InputStream
- Streamed directly andContent-Type set to"application/x-www-form-urlencoded" HttpResource
- Raw contents will be serialized to remote resource. Additional headers and media type will be set on request.HttpEntity
- Bypass Juneau serialization and pass HttpEntity directly to HttpClient.Object
- Converted to aSerializedEntity
usingUrlEncodingSerializer
to serialize.Supplier
- A supplier of anything on this list.
- Returns:
- A
RestRequest
object that can be further tailored before executing the request and getting the response as a parsed object. - Throws:
RestCallException
- If any authentication errors occurred.
-
formPost
Description copied from class:RestClient
Same asRestClient.formPost(Object, Object)
but doesn't specify the input yet.- Overrides:
formPost
in classRestClient
- Parameters:
url
- The URI of the remote REST resource.
Can be any of the following types:URIBuilder
URI
URL
String
Object
- Converted toString usingtoString()
- Returns:
- A
RestRequest
object that can be further tailored before executing the request and getting the response as a parsed object. - Throws:
RestCallException
- If any authentication errors occurred.
-
formPostPairs
Description copied from class:RestClient
Perform aPOST request with a content type ofapplication/x-www-form-urlencoded against the specified URI.- Overrides:
formPostPairs
in classRestClient
- Parameters:
url
- The URI of the remote REST resource.
Can be any of the following types:URIBuilder
URI
URL
String
Object
- Converted toString usingtoString()
parameters
- The parameters of the form post.
The parameters represent name/value pairs and must be an even number of arguments.
Parameters are converted toBasicPart
objects.- Returns:
- A
RestRequest
object that can be further tailored before executing the request and getting the response as a parsed object. - Throws:
RestCallException
- If any authentication errors occurred.
-
patch
Description copied from class:RestClient
Perform aPATCH request against the specified URI.- Overrides:
patch
in classRestClient
- Parameters:
url
- The URI of the remote REST resource.
Can be any of the following types:URIBuilder
URI
URL
String
Object
- Converted toString usingtoString()
body
- The object to serialize and transmit to the URI as the body of the request. Can be of the following types:-
Reader
- Raw contents ofReader
will be serialized to remote resource. -
InputStream
- Raw contents ofInputStream
will 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
- Bypass Juneau serialization and pass HttpEntity directly to HttpClient. -
Object
- POJO to be converted to text using theSerializer
registered with theRestClient
. -
PartList
- Converted to a URL-encoded FORM post. -
Supplier
- A supplier of anything on this list.
-
- Returns:
- A
RestRequest
object that can be further tailored before executing the request and getting the response as a parsed object. - Throws:
RestCallException
- If any authentication errors occurred.
-
patch
public MockRestRequest patch(Object url, String body, ContentType contentType) throws RestCallException Description copied from class:RestClient
Perform aPATCH request against the specified URI as a plain text body bypassing the serializer.- Overrides:
patch
in classRestClient
- Parameters:
url
- The URI of the remote REST resource.
Can be any of the following types:URIBuilder
URI
URL
String
Object
- Converted toString usingtoString()
body
- The object to serialize and transmit to the URI as the body of the request bypassing the serializer.contentType
- The content type of the request.- Returns:
- A
RestRequest
object that can be further tailored before executing the request and getting the response as a parsed object. - Throws:
RestCallException
- If any authentication errors occurred.
-
patch
Description copied from class:RestClient
Same asRestClient.patch(Object, Object)
but don't specify the input yet.You must call
RestRequest.content(Object)
to set the contents on the result object.- Overrides:
patch
in classRestClient
- Parameters:
url
- The URI of the remote REST resource.
Can be any of the following types:URIBuilder
URI
URL
String
Object
- Converted toString usingtoString()
- Returns:
- A
RestRequest
object that can be further tailored before executing the request and getting the response as a parsed object. - Throws:
RestCallException
- REST call failed.
-
callback
Description copied from class:RestClient
Performs a REST call where the entire call is specified in a simple string.This method is useful for performing callbacks when the target of a callback is passed in on an initial request, for example to signal when a long-running process has completed.
The call string can be any of the following formats:
-
"[method] [uri]" - e.g."GET http://localhost/callback" -
"[method] [uri] [payload]" - e.g."POST http://localhost/callback some text payload" -
"[method] [headers] [uri] [payload]" - e.g."POST {'Content-Type':'text/json'} http://localhost/callback {'some':'json'}"
The payload will always be sent using a simple
StringEntity
.- Overrides:
callback
in classRestClient
- Parameters:
callString
- The call string.- Returns:
- A
RestRequest
object that can be further tailored before executing the request and getting the response as a parsed object. - Throws:
RestCallException
- REST call failed.
-
-
request
Description copied from class:RestClient
Perform a generic REST call.- Overrides:
request
in classRestClient
- Parameters:
method
- The HTTP method.url
- The URI of the remote REST resource.
Can be any of the following types:URIBuilder
URI
URL
String
Object
- Converted toString usingtoString()
body
- The HTTP body content. Can be of the following types:-
Reader
- Raw contents ofReader
will be serialized to remote resource. -
InputStream
- Raw contents ofInputStream
will 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
- Bypass Juneau serialization and pass HttpEntity directly to HttpClient. -
Object
- POJO to be converted to text using theSerializer
registered with theRestClient
. -
PartList
- Converted to a URL-encoded FORM post. -
Supplier
- A supplier of anything on this list.
-
- Returns:
- A
RestRequest
object that can be further tailored before executing the request and getting the response as a parsed object. - Throws:
RestCallException
- If any authentication errors occurred.
-
request
Description copied from class:RestClient
Perform a generic REST call.- Overrides:
request
in classRestClient
- Parameters:
method
- The HTTP method.url
- The URI of the remote REST resource.
Can be any of the following types:URIBuilder
URI
URL
String
Object
- Converted toString usingtoString()
- Returns:
- A
RestRequest
object that can be further tailored before executing the request and getting the response as a parsed object. - Throws:
RestCallException
- If any authentication errors occurred.
-
request
Description copied from class:RestClient
Perform a generic REST call.Typically you're going to use
RestClient.request(String, Object)
orRestClient.request(String, Object, Object)
, but this method is provided to allow you to perform non-standard HTTP methods (e.g. HTTP FOO).- Overrides:
request
in classRestClient
- Parameters:
method
- The method name (e.g."GET" ,"OPTIONS" ).url
- The URI of the remote REST resource.
Can be any of the following types:URIBuilder
URI
URL
String
Object
- Converted toString usingtoString()
hasBody
- Boolean flag indicating if the specified request has content associated with it.- Returns:
- A
RestRequest
object that can be further tailored before executing the request and getting the response as a parsed object. - Throws:
RestCallException
- If any authentication errors occurred.
-
getCurrentClientRequest
Returns the current client-side REST request.Note that this uses a
ThreadLocal
object for storage and so will not work on requests executed in separate threads such as when usingFutures
.- Returns:
- The current client-side REST request, or
null if not set.
-
getCurrentClientResponse
Returns the current client-side REST response.Note that this uses a
ThreadLocal
object for storage and so will not work on requests executed in separate threads such as when usingFutures
.- Returns:
- The current client-side REST response, or
null if not set.
-
getCurrentServerRequest
Returns the current server-side REST request.Note that this uses a
ThreadLocal
object for storage and so will not work on requests executed in separate threads such as when usingFutures
.- Returns:
- The current server-side REST request, or
null if not set.
-
getCurrentServerResponse
Returns the current server-side REST response.Note that this uses a
ThreadLocal
object for storage and so will not work on requests executed in separate threads such as when usingFutures
.- Returns:
- The current server-side REST response, or
null if not set.
-
createRequest
protected MockRestRequest createRequest(URI uri, String method, boolean hasBody) throws RestCallException Description copied from class:RestClient
Creates aRestRequest
object from the specifiedHttpRequest
object.Subclasses can override this method to provide their own specialized
RestRequest
objects.- Overrides:
createRequest
in classRestClient
- Parameters:
uri
- The target.method
- The HTTP method (uppercase).hasBody
- Whether this method has a request entity.- Returns:
- A new
RestRequest
object. - Throws:
RestCallException
- If an exception or non-200 response code occurred during the connection attempt.
-
createResponse
protected MockRestResponse createResponse(RestRequest req, HttpResponse httpResponse, Parser parser) throws RestCallException Description copied from class:RestClient
Creates aRestResponse
object from the specifiedHttpResponse
object.Subclasses can override this method to provide their own specialized
RestResponse
objects.- Overrides:
createResponse
in classRestClient
- Parameters:
req
- The request creating this response.httpResponse
- The response object to wrap.parser
- The parser to use to parse the response.- Returns:
- A new
RestResponse
object. - Throws:
RestCallException
- If an exception or non-200 response code occurred during the connection attempt.
-
close
Description copied from class:RestClient
CallsCloseable.close()
on the underlyingCloseableHttpClient
.It's good practice to call this method after the client is no longer used.
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Specified by:
close
in interfaceHttpConnection
- Overrides:
close
in classRestClient
- Throws:
IOException
- Thrown by underlying stream.
-
isOpen
- Specified by:
isOpen
in interfaceHttpConnection
-
isStale
- Specified by:
isStale
in interfaceHttpConnection
-
setSocketTimeout
- Specified by:
setSocketTimeout
in interfaceHttpConnection
-
getSocketTimeout
- Specified by:
getSocketTimeout
in interfaceHttpConnection
-
shutdown
- Specified by:
shutdown
in interfaceHttpConnection
- Throws:
IOException
-
getMetrics
- Specified by:
getMetrics
in interfaceHttpConnection
-
isResponseAvailable
- Specified by:
isResponseAvailable
in interfaceHttpClientConnection
- Throws:
IOException
-
sendRequestHeader
- Specified by:
sendRequestHeader
in interfaceHttpClientConnection
- Throws:
HttpException
IOException
-
sendRequestEntity
- Specified by:
sendRequestEntity
in interfaceHttpClientConnection
- Throws:
HttpException
IOException
-
receiveResponseHeader
- Specified by:
receiveResponseHeader
in interfaceHttpClientConnection
- Throws:
HttpException
IOException
-
receiveResponseEntity
- Specified by:
receiveResponseEntity
in interfaceHttpClientConnection
- Throws:
HttpException
IOException
-
flush
- Specified by:
flush
in interfaceHttpClientConnection
- Throws:
IOException
-