Class CompressorMiddleware
- Namespace
- IceRpc.Compressor
- Assembly
- IceRpc.Compressor.dll
Represents a middleware that decompresses the payloads of incoming requests and compresses the payloads of outgoing responses.
public class CompressorMiddleware : IDispatcher
- Inheritance
-
CompressorMiddleware
- Implements
- Inherited Members
Remarks
This middleware decompresses the payload of an incoming request when the request carries a
CompressionFormat field with a supported compression format (currently
Brotli or Deflate).
This middleware compresses the payload of a response and sets the CompressionFormat
field when the request has the ICompressFeature feature set and the response's CompressionFormat
field is unset.
Constructors
CompressorMiddleware(IDispatcher, CompressionFormat, CompressionLevel)
Constructs a Compressor middleware.
public CompressorMiddleware(IDispatcher next, CompressionFormat compressionFormat, CompressionLevel compressionLevel = CompressionLevel.Fastest)
Parameters
next
IDispatcherThe next dispatcher in the dispatch pipeline.
compressionFormat
CompressionFormatThe compression format for the compress operation.
compressionLevel
CompressionLevelThe compression level for the compress operation.
Methods
DispatchAsync(IncomingRequest, CancellationToken)
Dispatches an incoming request and returns the corresponding outgoing response.
public ValueTask<OutgoingResponse> DispatchAsync(IncomingRequest request, CancellationToken cancellationToken = default)
Parameters
request
IncomingRequestThe incoming request being dispatched.
cancellationToken
CancellationTokenA cancellation token that receives the cancellation requests.
Returns
- ValueTask<OutgoingResponse>
The outgoing response.