private void CompresNowGZip() { Stream s = null; Stream aux = new MemoryStream(); try { s = new ICSharpCode.SharpZipLib.GZip.GZipOutputStream(aux); s.Write(this.m_byteinput, 0, (int)this.m_byteinput.Length); (s as ICSharpCode.SharpZipLib.GZip.GZipOutputStream).Finish(); s.Flush(); } catch (ZipException e) { this.m_byteoutput = null; this.m_streamoutput = null; Debug.WriteLine(e.Message); } finally { aux.Seek(0, SeekOrigin.Begin); this.m_byteoutput = null; this.m_byteoutput = new byte[aux.Length]; aux.Read(this.m_byteoutput, 0, (int)aux.Length); this.m_streamoutput = null; this.m_streamoutput = new MemoryStream(this.m_byteoutput); //s.Close(); } }
public ChunkedResponse() { Headers["Transfer-Encoding"] = "chunked"; Headers["Content-Encoding"] = "gzip"; ContentType = "text/html; charset=utf-8"; Contents = stream => { var gzip = new ICSharpCode.SharpZipLib.GZip.GZipOutputStream(stream); using (var streamWriter = new StreamWriter(gzip)) { while (true) { streamWriter.WriteLine("Hello"); gzip.Flush(); streamWriter.Flush(); Thread.Sleep(1000); } } }; }