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
nextIDispatcherThe next dispatcher in the dispatch pipeline.
compressionFormatCompressionFormatThe compression format for the compress operation.
compressionLevelCompressionLevelThe 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
requestIncomingRequestThe incoming request being dispatched.
cancellationTokenCancellationTokenA cancellation token that receives the cancellation requests.
Returns
- ValueTask<OutgoingResponse>
The outgoing response.