class OkHttpClientHttpRequest extends AbstractBufferingAsyncClientHttpRequest implements ClientHttpRequest
ClientHttpRequest
implementation that uses OkHttp to execute requests.
Created via the OkHttpClientHttpRequestFactory
.
Modifier and Type | Class and Description |
---|---|
private static class |
OkHttpClientHttpRequest.OkHttpListenableFuture |
Modifier and Type | Field and Description |
---|---|
private OkHttpClient |
client |
private HttpMethod |
method |
private java.net.URI |
uri |
Constructor and Description |
---|
OkHttpClientHttpRequest(OkHttpClient client,
java.net.URI uri,
HttpMethod method) |
Modifier and Type | Method and Description |
---|---|
ClientHttpResponse |
execute()
Execute this request, resulting in a
ClientHttpResponse that can be read. |
protected ListenableFuture<ClientHttpResponse> |
executeInternal(HttpHeaders headers,
byte[] content)
Abstract template method that writes the given headers and content to the HTTP request.
|
private MediaType |
getContentType(HttpHeaders headers) |
HttpMethod |
getMethod()
Return the HTTP method of the request.
|
java.net.URI |
getURI()
Return the URI of the request.
|
executeInternal, getBodyInternal
assertNotExecuted, executeAsync, getBody, getHeaders
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getBody
getHeaders
private final OkHttpClient client
private final java.net.URI uri
private final HttpMethod method
public OkHttpClientHttpRequest(OkHttpClient client, java.net.URI uri, HttpMethod method)
public HttpMethod getMethod()
HttpRequest
getMethod
in interface HttpRequest
public java.net.URI getURI()
HttpRequest
getURI
in interface HttpRequest
protected ListenableFuture<ClientHttpResponse> executeInternal(HttpHeaders headers, byte[] content) throws java.io.IOException
AbstractBufferingAsyncClientHttpRequest
executeInternal
in class AbstractBufferingAsyncClientHttpRequest
headers
- the HTTP headerscontent
- the body contentjava.io.IOException
private MediaType getContentType(HttpHeaders headers)
public ClientHttpResponse execute() throws java.io.IOException
ClientHttpRequest
ClientHttpResponse
that can be read.execute
in interface ClientHttpRequest
java.io.IOException
- in case of I/O errors