http: 支持 Content-Encoding: gzip
来源:互联网 发布:csgo控制台优化 编辑:程序博客网 时间:2024/05/23 19:18
curl -v --compressed http://localhost:8080/upload/a.out -o a.out
请求:
Accept-Encoding: gzip, deflate
响应:
Content-Encoding: gzip
gzip -9c xx.txt > xx.gz
开头是标记0x1f,0x8b,然后0x08表示使用deflate,前10个字节通常为:
1f 8b 08 00 00 00 00 00 00 03
中间是deflate的raw data
最后的8个字节是crc32和原始长度。
deflate 开头两个字节是0x78,0x9c, 参考文件[1]就是这种格式,
我写成gzip, curl可以收,但是chrome报错。
调用zlib,生成数据的差异只是在deflateInit(inflate)和deflateInit2(gzip)[2],其他相同。这点害的我调试了好久。
调试发现chsum 的crc根本对不上,下面的/bin/crc32和*.gz对得上:
#!/usr/bin/perl -weval 'exec /usr/bin/perl -w -S $0 ${1+"$@"}' if 0; # not running under some shell# computes and prints to stdout the CRC-32 values of the given filesuse lib qw( blib/lib lib );use Archive::Zip;use FileHandle;my $totalFiles = scalar(@ARGV);foreach my $file (@ARGV) { if ( -d $file ) { warn "$0: ${file}: Is a directory\n"; next; } my $fh = FileHandle->new(); if ( !$fh->open( $file, 'r' ) ) { warn "$0: $!\n"; next; } binmode($fh); my $buffer; my $bytesRead; my $crc = 0; while ( $bytesRead = $fh->read( $buffer, 32768 ) ) { $crc = Archive::Zip::computeCRC32( $buffer, $crc ); } printf( "%08x", $crc ); print("\t$file") if ( $totalFiles > 1 ); print("\n");}
[1] http://www.zlib.net/zpipe.c
[2] http://lxr.free-electrons.com/source/include/linux/zlib.h
0 0
- http: 支持 Content-Encoding: gzip
- tomcat和nginx设置content-Encoding:gzip
- http协议content-encoding & transfer-encoding
- http协议content-encoding & transfer-encoding
- http协议content-encoding & transfer-encoding
- HTTP协议之Content-Encoding
- HTTP协议之Content-Encoding
- HTTP协议之Content-Encoding
- HTTP协议之Content-Encoding
- HTTP协议之Content-Encoding
- HTTP协议之Content-Encoding
- HTTP 协议中的 Content-Encoding
- HTTP协议之Content-Encoding
- 如何解析Content-Encoding: gzip服务器返回信息
- HTTP头中的Content-Transfer-Encoding
- Gzip 的HTTP支持(一)
- Gzip 的HTTP支持 (二)
- http accept-encoding详解 HTTP协议-压缩(gzip,deflate)
- Unix/Linux的内存管理
- 在macbook air配置android开发环境[eclipse篇]
- Lua学习笔记--函数初探
- SpringMVC返回JSON数据406错误处理
- Java模拟公司置办货物系统(一)
- http: 支持 Content-Encoding: gzip
- ARM裸机程序研究 - 编译和链接
- linux中文件描述符fd和文件指针flip的理解
- POJ 1836 Alignment(DP LIS)
- noip2001 求先序排列 (已知中序+后序,求解先序 ;分治)
- OutMan——Objective-C中分类、延展、非正式协议和协议
- python_学习笔记0824
- Linux 下的shell快捷键
- cookie 和session 的区别