接口 ExchangeCodec
- 所有已知实现类:
Http1ExchangeCodec,Http2ExchangeCodec
public interface ExchangeCodec
Encodes HTTP requests and decodes HTTP responses.
-
字段概要
字段修饰符和类型字段说明static final intThe timeout to use while discarding a stream of input data. -
方法概要
修饰符和类型方法说明voidcancel()Cancel this stream.Returns the connection that carries this codec.createRequestBody(Request request, long contentLength) Returns an output stream where the request body can be streamed.voidFlush the request to the underlying socket and signal no more bytes will be transmitted.voidFlush the request to the underlying socket.openResponseBodySource(Response response) readResponseHeaders(boolean expectContinue) Parses bytes of a response header from an HTTP transport.longreportedContentLength(Response response) trailers()Returns the trailers after the HTTP response.voidwriteRequestHeaders(Request request) This should update the HTTP engine's sentRequestMillis field.
-
字段详细资料
-
DISCARD_STREAM_TIMEOUT_MILLIS
static final int DISCARD_STREAM_TIMEOUT_MILLISThe timeout to use while discarding a stream of input data. Since this is used for connection reuse, this timeout should be significantly less than the time it takes to establish a new connection.- 另请参阅:
-
-
方法详细资料
-
connection
RealConnection connection()Returns the connection that carries this codec. -
createRequestBody
Returns an output stream where the request body can be streamed.- 抛出:
IOException
-
writeRequestHeaders
This should update the HTTP engine's sentRequestMillis field.- 抛出:
IOException
-
flushRequest
Flush the request to the underlying socket.- 抛出:
IOException
-
finishRequest
Flush the request to the underlying socket and signal no more bytes will be transmitted.- 抛出:
IOException
-
readResponseHeaders
Parses bytes of a response header from an HTTP transport.- 参数:
expectContinue- true to return null if this is an intermediate response with a "100" response code. Otherwise this method never returns null.- 抛出:
IOException
-
reportedContentLength
- 抛出:
IOException
-
openResponseBodySource
- 抛出:
IOException
-
trailers
Returns the trailers after the HTTP response. May be empty.- 抛出:
IOException
-
cancel
void cancel()Cancel this stream. Resources held by this stream will be cleaned up, though not synchronously. That may happen later by the connection pool thread.
-