Modifier and Type | Class and Description |
---|---|
(package private) class |
RealCall.AsyncCall |
Call.Factory
Modifier and Type | Field and Description |
---|---|
(package private) OkHttpClient |
client |
private boolean |
executed |
(package private) boolean |
forWebSocket |
(package private) Request |
originalRequest
The application's original request unadulterated by redirects or auth headers.
|
private Transmitter |
transmitter
There is a cycle between the
Call and Transmitter that makes this awkward. |
Modifier | Constructor and Description |
---|---|
private |
RealCall(OkHttpClient client,
Request originalRequest,
boolean forWebSocket) |
Modifier and Type | Method and Description |
---|---|
void |
cancel()
Cancels the request, if possible.
|
RealCall |
clone()
Create a new, identical call to this one which can be enqueued or executed even if this call
has already been.
|
void |
enqueue(Callback responseCallback)
Schedules the request to be executed at some point in the future.
|
Response |
execute()
Invokes the request immediately, and blocks until the response can be processed or is in
error.
|
(package private) Response |
getResponseWithInterceptorChain() |
boolean |
isCanceled() |
boolean |
isExecuted()
|
(package private) static RealCall |
newRealCall(OkHttpClient client,
Request originalRequest,
boolean forWebSocket) |
(package private) java.lang.String |
redactedUrl() |
Request |
request()
Returns the original request that initiated this call.
|
okio.Timeout |
timeout()
Returns a timeout that spans the entire call: resolving DNS, connecting, writing the request
body, server processing, and reading the response body.
|
(package private) java.lang.String |
toLoggableString()
Returns a string that describes this call.
|
final OkHttpClient client
private Transmitter transmitter
Call
and Transmitter
that makes this awkward.
This is set after immediately after creating the call instance.final Request originalRequest
final boolean forWebSocket
private boolean executed
private RealCall(OkHttpClient client, Request originalRequest, boolean forWebSocket)
static RealCall newRealCall(OkHttpClient client, Request originalRequest, boolean forWebSocket)
public Request request()
Call
public Response execute() throws java.io.IOException
Call
To avoid leaking resources callers should close the Response
which in turn will
close the underlying ResponseBody
.
// ensure the response (and underlying response body) is closed
try (Response response = client.newCall(request).execute()) {
...
}
The caller may read the response body with the response's Response.body
method. To
avoid leaking resources callers must close the response body or the
Response.
Note that transport-layer success (receiving a HTTP response code, headers and body) does
not necessarily indicate application-layer success: response
may still indicate an
unhappy HTTP response code like 404 or 500.
public void enqueue(Callback responseCallback)
Call
The dispatcher
defines when the request will run: usually
immediately unless there are several other requests currently being executed.
This client will later call back responseCallback
with either an HTTP response or a
failure exception.
public void cancel()
Call
public okio.Timeout timeout()
Call
Configure the client's default timeout with OkHttpClient.Builder.callTimeout
.
public boolean isExecuted()
Call
isExecuted
in interface Call
public boolean isCanceled()
isCanceled
in interface Call
public RealCall clone()
Call
java.lang.String toLoggableString()
java.lang.String redactedUrl()
Response getResponseWithInterceptorChain() throws java.io.IOException
java.io.IOException