Class CompressorInterceptor
- Namespace
- IceRpc.Compressor
- Assembly
- IceRpc.Compressor.dll
Represents an interceptor that compresses the payloads of outgoing requests and decompresses the payloads of incoming responses.
public class CompressorInterceptor : IInvoker
- Inheritance
-
CompressorInterceptor
- Implements
- Inherited Members
- Extension Methods
Remarks
This interceptor compresses the payload of a request and sets the
CompressionFormat field when this request has the ICompressFeature
feature set and the CompressionFormat field is unset.
This interceptor decompresses the payload of a response when this response's status code is
Ok and the response carries a CompressionFormat field
with a supported compression format (currently Brotli or
Deflate).
Constructors
CompressorInterceptor(IInvoker, CompressionFormat, CompressionLevel)
Constructs a Compressor interceptor.
public CompressorInterceptor(IInvoker next, CompressionFormat compressionFormat, CompressionLevel compressionLevel = CompressionLevel.Fastest)
Parameters
next
IInvokerThe next invoker in the invocation pipeline.
compressionFormat
CompressionFormatThe compression format for the compress operation.
compressionLevel
CompressionLevelThe compression level for the compress operation.
Methods
InvokeAsync(OutgoingRequest, CancellationToken)
Sends an outgoing request and returns the corresponding incoming response.
public Task<IncomingResponse> InvokeAsync(OutgoingRequest request, CancellationToken cancellationToken)
Parameters
request
OutgoingRequestThe outgoing request being sent.
cancellationToken
CancellationTokenA cancellation token that receives the cancellation requests.
Returns
- Task<IncomingResponse>
The corresponding IncomingResponse.
Remarks
When request
is a two-way request, the returned task will not complete successfully
until after the request's Payload is fully sent and the response is received from
the peer. When the request is a one-way request, the returned task completes successfully with an empty response
when the request's Payload is fully sent. For all requests (one-way and two-way),
the sending of the request's PayloadContinuation can continue in a background task
after the returned task has completed successfully.