http协议之chunk编码
来源:互联网 发布:nginx搭建静态网站 编辑:程序博客网 时间:2024/04/29 12:40
在有时服务器生成HTTP回应是无法确定消息大小的,这时用Content-Length就无法事先写入长度,而需要实时生成消息长度,这时服务器一般采用Chunked编码。
在进行Chunked编码传输时,在回复消息的头部有transfer-coding并定为Chunked,表示将用Chunked编码传输内容。采用以下方式编码:
Chunked-Body=*chunk
"0"CRLF
footer
CRLF
chunk=chunk-size[chunk-ext]CRLF
chunk-dataCRLF
hex-no-zero=<HEXexcluding"0">
chunk-size=hex-no-zero*HEX
chunk-ext=*(";"chunk-ext-name["="chunk-ext-value])
chunk-ext-name=token
chunk-ext-val=token|quoted-string
chunk-data=chunk-size(OCTET)
footer=*entity-header
编码使用若干个Chunk组成,由一个标明长度为0的chunk结束,每个Chunk有两部分组成,第一部分是该Chunk的长度和长度单位(一般不写),第二部分就是指定长度的内容,每个部分用CRLF隔开。在最后一个长度为0的Chunk中的内容是称为footer的内容,是一些没有写的头部内容。
下面给出一个Chunked的解码过程(RFC文档中有)
length:=0
readchunk-size,chunk-ext(ifany)andCRLF
while(chunk-size>0){
readchunk-dataandCRLF
appendchunk-datatoentity-body
length:=length+chunk-size
readchunk-sizeandCRLF
}
readentity-header
while(entity-headernotempty){
appendentity-headertoexistingheaderfields
readentity-header
}
Content-Length:=length
Remove"chunked"fromTransfer-Encoding
- http协议之chunk编码
- http协议之chunk编码
- http协议之chunk编码
- HTTP协议之chunk编码
- http协议chunk 编码
- http协议之chunk(分块传输编码)
- HTTP协议之chunk编码(分块传输编码)
- HTTP协议之chunk编码(分块传输编码)
- HTTP协议中的chunk编码
- HTTP协议之chunk介绍
- http chunk编码 C++
- HTTP协议之Chunked编码
- chunk 编码
- http chunk
- http chunk
- Http协议中关于Content-Length和Chunk
- Http协议的编码
- IOS网络篇13之Http chunk分析wireshark
- sssss
- 用EXCEL制作打印摸板
- 第一篇哈
- Struts2权威指南(完整版)含源码[Zone Yan.]-调试19.4示例笔记
- 餐桌文化
- http协议之chunk编码
- Plone Cook Book
- Fiddler:Web调试代理
- 开心一刻 (大学时代的趣事)
- Compile Live555 using VS2005
- [全程建模]2009年全程建模方法论与Trufun科技合作推出第二次培训(上海)
- live555源代码简介
- oracle创建表空间
- Oracle左连接,右连接