public final class Http1xStream extends Objectimplements HttpStream
chunked. Exchanges that do not have a request body may skip creating and closing the request body. Exchanges that do not have a response body can call newFixedLengthSource(0) and may skip reading and closing that source.
DISCARD_STREAM_TIMEOUT_MILLIS| Constructor and Description |
|---|
Http1xStream(StreamAllocation
|
| Modifier and Type | Method and Description |
|---|---|
void |
cancel()
Cancel this stream.
|
okio |
createRequestBody(Request
Returns an output stream where the request body can be streamed.
|
void |
finishRequest()
Flush the request to the underlying socket.
|
boolean |
isClosed()
Returns true if this connection is closed.
|
okio |
newChunkedSink()
|
okio |
newChunkedSource(HttpEngine
|
okio |
newFixedLengthSink(long contentLength)
|
okio |
newFixedLengthSource(long length)
|
okio |
newUnknownLengthSource()
|
ResponseBody |
openResponseBody(Response
Returns a stream that reads the response body.
|
Headers |
readHeaders()
Reads headers or trailers.
|
Response |
readResponse()
Parses bytes of a response header from an HTTP transport.
|
Response |
readResponseHeaders()
Read and return response headers.
|
void |
setHttpEngine(HttpEngine
|
void |
writeRequest(Headers
Returns bytes of a request header for sending on an HTTP transport.
|
void |
writeRequestBody(RetryableSink
Sends the request body returned by
HttpStream to the remote peer.
|
void |
writeRequestHeaders(Request
Prepares the HTTP headers and sends them to the server.
|
public Http1xStream(StreamAllocationstreamAllocation, okio .BufferedSource source, okio .BufferedSink sink)
public void setHttpEngine(HttpEnginehttpEngine)
public okio.Sink createRequestBody(Request request, long contentLength) throws IOException
HttpStream
createRequestBody in interface
HttpStream
IOException
public void cancel()
HttpStream
public void writeRequestHeaders(Requestrequest) 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.
writeRequestHeaders in interface
HttpStream
IOException
public Response.Builder readResponseHeaders() throws IOException
HttpStream
readResponseHeaders in interface
HttpStream
IOException
public ResponseBodyopenResponseBody(Response response) throws IOException
HttpStream
openResponseBody in interface
HttpStream
IOException
public boolean isClosed()
public void finishRequest()
throws IOException
HttpStream
finishRequest in interface
HttpStream
IOException
public void writeRequest(Headersheaders, String requestLine) throws IOException
IOException
public Response.Builder readResponse() throws IOException
IOException
public HeadersreadHeaders() throws IOException
IOException
public okio.Sink newChunkedSink()
public okio.Sink newFixedLengthSink(long contentLength)
public void writeRequestBody(RetryableSinkrequestBody) throws IOException
HttpStream
HttpStream.createRequestBody(okhttp3.Request, long) to the remote peer.
writeRequestBody in interface
HttpStream
IOException
public okio.Source newFixedLengthSource(long length) throws IOException
IOException
public okio.Source newChunkedSource(HttpEngine httpEngine) throws IOException
IOException
public okio.Source newUnknownLengthSource() throws IOException
IOException