类 Http1ExchangeCodec
java.lang.Object
com.lark.oapi.okhttp.internal.http1.Http1ExchangeCodec
- 所有已实现的接口:
ExchangeCodec
A socket connection that can be used to send HTTP/1.1 messages. This class strictly enforces the
following lifecycle:
- Send request headers.
- Open a sink to write the request body. Either known
length or
chunked. - Write to and then close that sink.
- Read response headers.
- Open a source to read the response body. Either fixed-length, chunked or unknown length.
- Read from and close that source.
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.
-
字段概要
从接口继承的字段 com.lark.oapi.okhttp.internal.http.ExchangeCodec
DISCARD_STREAM_TIMEOUT_MILLIS -
构造器概要
构造器构造器说明Http1ExchangeCodec(OkHttpClient client, RealConnection realConnection, BufferedSource source, BufferedSink sink) -
方法概要
修饰符和类型方法说明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.booleanisClosed()Returns true if this connection is closed.openResponseBodySource(Response response) readResponseHeaders(boolean expectContinue) Parses bytes of a response header from an HTTP transport.longreportedContentLength(Response response) voidskipConnectBody(Response response) The response body from a CONNECT should be empty, but if it is not then we should consume it before proceeding.trailers()Returns the trailers after the HTTP response.voidwriteRequest(Headers headers, String requestLine) Returns bytes of a request header for sending on an HTTP transport.voidwriteRequestHeaders(Request request) Prepares the HTTP headers and sends them to the server.
-
构造器详细资料
-
Http1ExchangeCodec
public Http1ExchangeCodec(OkHttpClient client, RealConnection realConnection, BufferedSource source, BufferedSink sink)
-
-
方法详细资料
-
connection
从接口复制的说明:ExchangeCodecReturns the connection that carries this codec.- 指定者:
connection在接口中ExchangeCodec
-
createRequestBody
从接口复制的说明:ExchangeCodecReturns an output stream where the request body can be streamed.- 指定者:
createRequestBody在接口中ExchangeCodec- 抛出:
IOException
-
cancel
public void cancel()从接口复制的说明:ExchangeCodecCancel this stream. Resources held by this stream will be cleaned up, though not synchronously. That may happen later by the connection pool thread.- 指定者:
cancel在接口中ExchangeCodec
-
writeRequestHeaders
Prepares the HTTP headers and sends them to the server.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-Lengthheader field receives the proper value.- 指定者:
writeRequestHeaders在接口中ExchangeCodec- 抛出:
IOException
-
reportedContentLength
- 指定者:
reportedContentLength在接口中ExchangeCodec
-
openResponseBodySource
- 指定者:
openResponseBodySource在接口中ExchangeCodec
-
trailers
从接口复制的说明:ExchangeCodecReturns the trailers after the HTTP response. May be empty.- 指定者:
trailers在接口中ExchangeCodec
-
isClosed
public boolean isClosed()Returns true if this connection is closed. -
flushRequest
从接口复制的说明:ExchangeCodecFlush the request to the underlying socket.- 指定者:
flushRequest在接口中ExchangeCodec- 抛出:
IOException
-
finishRequest
从接口复制的说明:ExchangeCodecFlush the request to the underlying socket and signal no more bytes will be transmitted.- 指定者:
finishRequest在接口中ExchangeCodec- 抛出:
IOException
-
writeRequest
Returns bytes of a request header for sending on an HTTP transport.- 抛出:
IOException
-
readResponseHeaders
从接口复制的说明:ExchangeCodecParses bytes of a response header from an HTTP transport.- 指定者:
readResponseHeaders在接口中ExchangeCodec- 参数:
expectContinue- true to return null if this is an intermediate response with a "100" response code. Otherwise this method never returns null.- 抛出:
IOException
-
skipConnectBody
The response body from a CONNECT should be empty, but if it is not then we should consume it before proceeding.- 抛出:
IOException
-