How can I view html page from Server: Microsoft-IIS/10.0 with header: "Accept-Encoding: deflate"
I want to uncompress page from Server: Microsoft-IIS/10.0 with header:
"Accept-Encoding: deflate".
X-Frame-Options: SAMEORIGIN
X-UA-Compatible: IE=Edge
X-AspNet-Version: 4.0.30319
X-Powered-By: ASP.NET
I'm looking for a command line wrapper for the DEFLATE algorithm. Unfortunately: zlib-flate -uncompress < deflate.dat > page.html flate: inflate: data: incorrect header check
unpigz -c deflate.dat
unpigz: skipping: deflate.dat is not compressed
openssl zlib -d < deflate.dat > page.html
140264494790544:error:29065064:lib(41):BIO_ZLIB_READ:zlib inflate error:c_zlib.c:548:zlib error:data error
Microsoft and their IIS server is what ruined the deflate
HTTP content encoding for everyone. The HTTP standard in RFC 2616 clearly states:
deflate
The "zlib" format defined in RFC 1950 [31] in combination with
the "deflate" compression mechanism described in RFC 1951 [29].
However the authors at Microsoft of IIS did not read the standard, and instead decided on their own that deflate
meant raw deflate, just RFC 1951, without the zlib wrapper. Then browsers either didn't work with deflate
encoding, or they had to try decoding it both ways, with and without the zlib wrapper. Now the recommendation is to simply not use the deflate
encoding, and use gzip
instead.
I am not aware of a stock command line tool to decompress raw deflate data. You can compile this with zlib to create such a tool:
// Decompress raw deflate data from stdin to stdout. Return with an exit code
// of 1 if there is an error.
#include <stdio.h>
#include "zlib.h"
#ifdef _WIN32
# include <fcntl.h>
# include <io.h>
# define BINARY() (_setmode(0, _O_BINARY), _setmode(1, _O_BINARY))
#else
# define BINARY()
#endif
int main(void) {
BINARY();
z_stream strm = {0};
int ret = inflateInit2(&strm, -15);
if (ret != Z_OK)
return 1;
unsigned char in[32768], out[32768];
do {
if (strm.avail_in == 0) {
strm.avail_in = fread(in, 1, sizeof(in), stdin);
strm.next_in = in;
}
strm.avail_out = sizeof(out);
strm.next_out = out;
ret = inflate(&strm, Z_NO_FLUSH);
fwrite(out, 1, sizeof(out) - strm.avail_out, stdout);
} while (ret == Z_OK);
inflateEnd(&strm);
return ret != Z_STREAM_END;
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.