public final class HttpConnection extends Object
Send request headers
.
fixed-length
or chunked
.
Read response headers
.
fixed-length
, chunked
or unknown length
.
Exchanges that do not have a request body may skip creating and closing
the request body. Exchanges that do not have a response body must call emptyResponseBody()
.
Constructor and Description |
---|
HttpConnection(ConnectionPool pool,
Connection connection,
Socket socket) |
Modifier and Type | Method and Description |
---|---|
long |
bufferSize()
Returns the number of buffered bytes immediately readable.
|
void |
closeIfOwnedBy(Object owner) |
void |
closeOnIdle()
Configure this connection to close itself when the HTTP response body is
exhausted.
|
void |
emptyResponseBody()
Call this to advance past a response body for HTTP responses that do not
have a response body.
|
void |
flush() |
boolean |
isClosed()
Returns true if this connection is closed.
|
boolean |
isReadable()
Test for a stale socket.
|
okio.Sink |
newChunkedSink() |
okio.Source |
newChunkedSource(HttpEngine httpEngine) |
okio.Sink |
newFixedLengthSink(long contentLength) |
okio.Source |
newFixedLengthSource(long length) |
okio.Source |
newUnknownLengthSource() |
void |
poolOnIdle()
Configure this connection to put itself back into the connection pool when
the HTTP response body is exhausted.
|
void |
readHeaders(Headers.Builder builder)
Reads headers or trailers into
builder . |
Response.Builder |
readResponse()
Parses bytes of a response header from an HTTP transport.
|
void |
setTimeouts(int readTimeoutMillis,
int writeTimeoutMillis) |
void |
writeRequest(Headers headers,
String requestLine)
Returns bytes of a request header for sending on an HTTP transport.
|
void |
writeRequestBody(RetryableSink requestBody) |
public HttpConnection(ConnectionPool pool, Connection connection, Socket socket) throws IOException
IOException
public void setTimeouts(int readTimeoutMillis, int writeTimeoutMillis)
public void poolOnIdle()
public void closeOnIdle() throws IOException
IOException
public boolean isClosed()
public void closeIfOwnedBy(Object owner) throws IOException
IOException
public void flush() throws IOException
IOException
public long bufferSize()
public boolean isReadable()
public void writeRequest(Headers headers, String requestLine) throws IOException
IOException
public Response.Builder readResponse() throws IOException
IOException
public void readHeaders(Headers.Builder builder) throws IOException
builder
.IOException
public okio.Sink newChunkedSink()
public okio.Sink newFixedLengthSink(long contentLength)
public void writeRequestBody(RetryableSink requestBody) throws IOException
IOException
public okio.Source newFixedLengthSource(long length) throws IOException
IOException
public void emptyResponseBody() throws IOException
IOException
public okio.Source newChunkedSource(HttpEngine httpEngine) throws IOException
IOException
public okio.Source newUnknownLengthSource() throws IOException
IOException
Copyright © 2015. All rights reserved.