public final class HttpTransport extends Object
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_CHUNK_LENGTH |
| Constructor and Description |
|---|
HttpTransport(HttpEngine httpEngine,
OutputStream outputStream,
InputStream inputStream) |
| Modifier and Type | Method and Description |
|---|---|
OutputStream |
createRequestBody()
Returns an output stream where the request body can be written.
|
void |
flushRequest()
Flush the request body to the underlying socket.
|
InputStream |
getTransferStream(CacheRequest cacheRequest) |
boolean |
makeReusable(boolean streamCanceled,
OutputStream requestBodyOut,
InputStream responseBodyIn)
Returns true if the underlying connection can be recycled.
|
ResponseHeaders |
readResponseHeaders()
Read response headers and update the cookie manager.
|
void |
writeRequestBody(com.squareup.okhttp.internal.http.RetryableOutputStream requestBody)
Sends the request body returned by
createRequestBody() to the
remote peer. |
void |
writeRequestHeaders()
Prepares the HTTP headers and sends them to the server.
|
public static final int DEFAULT_CHUNK_LENGTH
public HttpTransport(HttpEngine httpEngine, OutputStream outputStream, InputStream inputStream)
public OutputStream createRequestBody() throws IOException
flushRequest() before reading the response.writeRequestBody(com.squareup.okhttp.internal.http.RetryableOutputStream). This allows HTTP authorization (401, 407)
responses to be retransmitted transparently.IOExceptionpublic void flushRequest()
throws IOException
IOExceptionpublic void writeRequestBody(com.squareup.okhttp.internal.http.RetryableOutputStream requestBody)
throws IOException
createRequestBody() to the
remote peer.IOExceptionpublic void writeRequestHeaders()
throws IOException
For streaming requests with a body, headers must be prepared before the output stream has been written to. Otherwise the body would need to be buffered!
For non-streaming requests with a body, headers must be prepared
after the output stream has been written to and closed.
This ensures that the Content-Length header field receives the
proper value.
IOExceptionpublic ResponseHeaders readResponseHeaders() throws IOException
IOExceptionpublic boolean makeReusable(boolean streamCanceled,
OutputStream requestBodyOut,
InputStream responseBodyIn)
public InputStream getTransferStream(CacheRequest cacheRequest) throws IOException
IOExceptionCopyright © 2014. All rights reserved.