public final class Http1xStream extends Object implements HttpStream
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 can call newFixedLengthSource(0) and may skip reading and
closing that source.
DISCARD_STREAM_TIMEOUT_MILLIS| Constructor and Description |
|---|
Http1xStream(StreamAllocation streamAllocation,
okio.BufferedSource source,
okio.BufferedSink sink) |
| Modifier and Type | Method and Description |
|---|---|
void |
cancel()
Cancel this stream.
|
okio.Sink |
createRequestBody(Request request,
long contentLength)
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.Sink |
newChunkedSink() |
okio.Source |
newChunkedSource(HttpEngine httpEngine) |
okio.Sink |
newFixedLengthSink(long contentLength) |
okio.Source |
newFixedLengthSource(long length) |
okio.Source |
newUnknownLengthSource() |
ResponseBody |
openResponseBody(Response response)
Returns a stream that reads the response body.
|
Headers |
readHeaders()
Reads headers or trailers.
|
Response.Builder |
readResponse()
Parses bytes of a response header from an HTTP transport.
|
Response.Builder |
readResponseHeaders()
Read and return response headers.
|
void |
setHttpEngine(HttpEngine httpEngine) |
void |
writeRequest(Headers headers,
String requestLine)
Returns bytes of a request header for sending on an HTTP transport.
|
void |
writeRequestBody(RetryableSink requestBody)
Sends the request body returned by
HttpStream.createRequestBody(com.squareup.okhttp.Request, long) to the
remote peer. |
void |
writeRequestHeaders(Request request)
Prepares the HTTP headers and sends them to the server.
|
public Http1xStream(StreamAllocation streamAllocation, okio.BufferedSource source, okio.BufferedSink sink)
public void setHttpEngine(HttpEngine httpEngine)
setHttpEngine in interface HttpStreampublic okio.Sink createRequestBody(Request request, long contentLength) throws IOException
HttpStreamcreateRequestBody in interface HttpStreamIOExceptionpublic void cancel()
HttpStreamcancel in interface HttpStreampublic void writeRequestHeaders(Request request) 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 HttpStreamIOExceptionpublic Response.Builder readResponseHeaders() throws IOException
HttpStreamreadResponseHeaders in interface HttpStreamIOExceptionpublic ResponseBody openResponseBody(Response response) throws IOException
HttpStreamopenResponseBody in interface HttpStreamIOExceptionpublic boolean isClosed()
public void finishRequest()
throws IOException
HttpStreamfinishRequest in interface HttpStreamIOExceptionpublic void writeRequest(Headers headers, String requestLine) throws IOException
IOExceptionpublic Response.Builder readResponse() throws IOException
IOExceptionpublic Headers readHeaders() throws IOException
IOExceptionpublic okio.Sink newChunkedSink()
public okio.Sink newFixedLengthSink(long contentLength)
public void writeRequestBody(RetryableSink requestBody) throws IOException
HttpStreamHttpStream.createRequestBody(com.squareup.okhttp.Request, long) to the
remote peer.writeRequestBody in interface HttpStreamIOExceptionpublic okio.Source newFixedLengthSource(long length)
throws IOException
IOExceptionpublic okio.Source newChunkedSource(HttpEngine httpEngine) throws IOException
IOExceptionpublic okio.Source newUnknownLengthSource()
throws IOException
IOExceptionCopyright © 2017. All Rights Reserved.