public ServerProcessing ProcessMessage(IServerChannelSinkStack sinkStack, IMessage requestMsg, ITransportHeaders requestHeaders, Stream requestStream, out IMessage responseMsg, out ITransportHeaders responseHeaders, out Stream responseStream) { bool isCompressed = false; // decompress the stream if necessary String xcompress = (String)requestHeaders["X-Compress"]; if (xcompress != null && xcompress == "yes") { requestStream = CompressionHelper.GetUncompressedStreamCopy(requestStream); isCompressed = true; } // Pushing onto stack and forwarding the call. // The state object contains true if the request has been compressed, // else false. sinkStack.Push(this, isCompressed); ServerProcessing srvProc = _nextSink.ProcessMessage(sinkStack, requestMsg, requestHeaders, requestStream, out responseMsg, out responseHeaders, out responseStream); if (srvProc == ServerProcessing.Complete) { // compressing the response if necessary if (isCompressed) { responseStream = CompressionHelper.GetCompressedStreamCopy(responseStream); responseHeaders["X-Compress"] = "yes"; } } // returning status information return(srvProc); }
public void AsyncProcessResponse(IClientResponseChannelSinkStack sinkStack, object state, ITransportHeaders headers, Stream stream) { // decompress the stream if necessary String xcompress = (String)headers["X-Compress"]; if (xcompress != null && xcompress == "yes") { stream = CompressionHelper.GetUncompressedStreamCopy(stream); } // forward the request sinkStack.AsyncProcessResponse(headers, stream); }
public void ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, out ITransportHeaders responseHeaders, out Stream responseStream) { requestStream = CompressionHelper.GetCompressedStreamCopy(requestStream); requestHeaders["X-Compress"] = "yes"; // forward the call to the next sink _nextSink.ProcessMessage(msg, requestHeaders, requestStream, out responseHeaders, out responseStream); // deflate the response if necessary String xcompress = (String)responseHeaders["X-Compress"]; if (xcompress != null && xcompress == "yes") { responseStream = CompressionHelper.GetUncompressedStreamCopy(responseStream); } }