接口 ExchangeCodec

所有已知实现类:
Http1ExchangeCodec, Http2ExchangeCodec

public interface ExchangeCodec
Encodes HTTP requests and decodes HTTP responses.
  • 字段详细资料

    • DISCARD_STREAM_TIMEOUT_MILLIS

      static final int DISCARD_STREAM_TIMEOUT_MILLIS
      The 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

      Sink createRequestBody(Request request, long contentLength) throws IOException
      Returns an output stream where the request body can be streamed.
      抛出:
      IOException
    • writeRequestHeaders

      void writeRequestHeaders(Request request) throws IOException
      This should update the HTTP engine's sentRequestMillis field.
      抛出:
      IOException
    • flushRequest

      void flushRequest() throws IOException
      Flush the request to the underlying socket.
      抛出:
      IOException
    • finishRequest

      void finishRequest() throws IOException
      Flush the request to the underlying socket and signal no more bytes will be transmitted.
      抛出:
      IOException
    • readResponseHeaders

      @Nullable Response.Builder readResponseHeaders(boolean expectContinue) throws IOException
      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

      long reportedContentLength(Response response) throws IOException
      抛出:
      IOException
    • openResponseBodySource

      Source openResponseBodySource(Response response) throws IOException
      抛出:
      IOException
    • trailers

      Headers trailers() throws IOException
      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.