public void SendZippedResponse(HttpListenerResponse response, ByteResponseData data) { response.AddHeader("Content-Encoding", "gzip"); response.ContentType = data.ContentType.GetValue(); byte[] buffer = data.Content; using (MemoryStream ms = new MemoryStream()) { using (GZipStream zip = new GZipStream(ms, CompressionMode.Compress)) { zip.Write(buffer, 0, buffer.Length); } buffer = ms.ToArray(); } WriteAndFlushResponse(response, buffer); }
public void SendResponse(HttpListenerResponse response, ByteResponseData data) { response.ContentType = data.ContentType.GetValue(); byte[] buffer = data.Content; WriteAndFlushResponse(response, buffer); }