类 Http1ExchangeCodec

java.lang.Object
com.lark.oapi.okhttp.internal.http1.Http1ExchangeCodec
所有已实现的接口:
ExchangeCodec

public final class Http1ExchangeCodec extends Object implements ExchangeCodec
A socket connection that can be used to send HTTP/1.1 messages. This class strictly enforces the following lifecycle:
  1. Send request headers.
  2. Open a sink to write the request body. Either known length or chunked.
  3. Write to and then close that sink.
  4. Read response headers.
  5. Open a source to read the response body. Either fixed-length, chunked or unknown length.
  6. 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.

  • 构造器详细资料

  • 方法详细资料

    • connection

      public RealConnection connection()
      从接口复制的说明: ExchangeCodec
      Returns the connection that carries this codec.
      指定者:
      connection 在接口中 ExchangeCodec
    • createRequestBody

      public Sink createRequestBody(Request request, long contentLength) throws IOException
      从接口复制的说明: ExchangeCodec
      Returns an output stream where the request body can be streamed.
      指定者:
      createRequestBody 在接口中 ExchangeCodec
      抛出:
      IOException
    • cancel

      public void cancel()
      从接口复制的说明: ExchangeCodec
      Cancel 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

      public void writeRequestHeaders(Request request) throws IOException
      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-Length header field receives the proper value.

      指定者:
      writeRequestHeaders 在接口中 ExchangeCodec
      抛出:
      IOException
    • reportedContentLength

      public long reportedContentLength(Response response)
      指定者:
      reportedContentLength 在接口中 ExchangeCodec
    • openResponseBodySource

      public Source openResponseBodySource(Response response)
      指定者:
      openResponseBodySource 在接口中 ExchangeCodec
    • trailers

      public Headers trailers()
      从接口复制的说明: ExchangeCodec
      Returns the trailers after the HTTP response. May be empty.
      指定者:
      trailers 在接口中 ExchangeCodec
    • isClosed

      public boolean isClosed()
      Returns true if this connection is closed.
    • flushRequest

      public void flushRequest() throws IOException
      从接口复制的说明: ExchangeCodec
      Flush the request to the underlying socket.
      指定者:
      flushRequest 在接口中 ExchangeCodec
      抛出:
      IOException
    • finishRequest

      public void finishRequest() throws IOException
      从接口复制的说明: ExchangeCodec
      Flush the request to the underlying socket and signal no more bytes will be transmitted.
      指定者:
      finishRequest 在接口中 ExchangeCodec
      抛出:
      IOException
    • writeRequest

      public void writeRequest(Headers headers, String requestLine) throws IOException
      Returns bytes of a request header for sending on an HTTP transport.
      抛出:
      IOException
    • readResponseHeaders

      public Response.Builder readResponseHeaders(boolean expectContinue) throws IOException
      从接口复制的说明: ExchangeCodec
      Parses 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

      public void skipConnectBody(Response response) throws IOException
      The response body from a CONNECT should be empty, but if it is not then we should consume it before proceeding.
      抛出:
      IOException