一个库放气,GZIP,并在.NET ZLIB并在、放气、ZLIB、GZIP

2023-09-04 02:46:01 作者:cαō性闖兲涯~↘

首先,让我们来定义一些经常混淆的术语:

First, let's define some commonly confused terms:

deflate = compression_algorithm;
zlib = header + deflate + trailer;
gzip = header + deflate + trailer;

我在寻找,这将基本上让我做以下的库:

I'm looking for a library that will basically let me do the following:

if(method == "gzip"){
    Response.Filter = new CompressionLibrary.OutputStream(Response.Filter, CompressionLibrary.Formats.GZIP);
}
else if(method == "deflate"){
    Response.Filter = new CompressionLibrary.OutputStream(Response.Filter, CompressionLibrary.Formats.DEFLATE);
}
else if(method == "zlib"){
    Response.Filter = new CompressionLibrary.OutputStream(Response.Filter, CompressionLibrary.Formats.ZLIB);
}

我在寻找一种方式来同等测试3 COM pression格式在Web上使用。我想在放气融为一体pression algorthims每种格式是完全相同的实施。我已经离开砍死在zlib.net然而,(通过无证功能),以迫使它给我生放气的命令,将gzip的头和尾是小我的联赛。

I'm looking for a way to comparably test the 3 compression formats for use on the web. I would like for the deflate compression algorthims for each format to be the same exact implementation. I've already hacked away at zlib.net to force it to give me raw deflate on command (via an "undocumented feature")...however, adding the gzip header and trailer are little out of my league.

任何人都知道的.NET库这样做吗?

Anyone know of a .net library that does this?

澄清:

HTTP 1.1的放气 COM pression的格式的居然是的zlib 的COM pression格式。 ZLIB是围绕放气的包装;它有一个2字节的头和一个4字节的预告片,总是(当COM pression方法和水平是相同的)。

HTTP 1.1's deflate compression format is actually the zlib compression format. Zlib is a wrapper around the deflate; it has a 2 byte header and a 4 byte trailer, always (when the compression methods and levels are identical).

Gzip已使用相同的COM pressed内部数据作为zlib的格式...这是放气(原放气,不是HTTP 1.1 DEFLATE [这是zlib的])。从我自己的preliminary测试,gzip压缩的数据是11的12倍,比zlib的大。

Gzip uses the same compressed data format internally as zlib...which is deflate (raw deflate, not HTTP 1.1 deflate [which is zlib]). From my own preliminary testing, gzipped data is 11 out of 12 times larger than zlib.

放气是用于COM preSS数据的COM pression算法。当没有包装方法周围泄了气的数据(例如,标题或拖车),我把它称为放气 - 也许我应该把它叫做原始放气而不是

deflate is a compression algorithm that is used to compress data. When there are no wrapper methods (e.g., headers or trailers) around deflated data, I call it "deflate" - perhaps I should have called it "raw deflate" instead.

我做的这些COM pression方法,并在Web浏览器的支持进行分析,并需要使用一个COM pression方法对所有三种类型。

I am doing an analysis of these compression methods and their support within web browsers and need to use a single compression method for all three types.

推荐答案

DotNetZip 做的 RFC 1950年(ZLIB),的 RFC 1951年(DEFLATE)和 RFC 1952年(GZIP)。 它使用相同的基础COM pression引擎这三种。

DotNetZip does RFC 1950 (ZLIB), RFC 1951 (DEFLATE), and RFC 1952 (GZIP). It uses the same underlying compression engine for all three.

DotNetZip也做ZIP文件。

DotNetZip also does ZIP files.