示例http范围请求会话
有可能向我展示一个范围请求的示例http会话。 我的意思是什么是请求和响应头?
Chrome和静态网页服务器之间进行以下交换,检索MP4video。
初始请求 – video。 请注意Accept-Ranges
响应标头,以指示服务器有范围标头支持:
GET /BigBuckBunny_320x180.mp4 Cache-Control: max-age=0 Connection: keep-alive Accept-Language: en-GB,en-US,en Host: localhost:8080 Range: Accept: text/html,application/xhtml+xml,application/xml,*/* User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.7 ... Accept-Encoding: gzip,deflate,sdch Accept-Charset: ISO-8859-1,utf-8,* 200 OK Content-Type: video/mp4 Connection: keep-alive Last-Modified: Wed,14 Dec 2011 15:50:59 GMT ETag: A023EF02BD589BC472A2D6774EAE3C58 Transfer-Encoding: Content-Length: 64657027 Accept-Ranges: bytes Server: Brisket/1.0.1 Date: Wed,14 Dec 2011 16:11:24 GMT
在前一个响应中检测到范围标题 – 后续请求以开放式范围确认支持。 响应返回206状态和Content-Range
标头,以指示响应正文中的字节:
GET /BigBuckBunny_320x180.mp4 Connection: keep-alive Accept-Language: en-GB,en-US,en Host: localhost:8080 Range: bytes=0- Accept: */* User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.7 ... Referer: http://localhost:8080/BigBuckBunny_320x180.mp4 Accept-Encoding: identity Accept-Charset: ISO-8859-1,utf-8,* 206 Partial Content Content-Type: video/mp4 Connection: keep-alive Last-Modified: Wed,14 Dec 2011 15:50:59 GMT ETag: A023EF02BD589BC472A2D6774EAE3C58 Transfer-Encoding: Content-Length: 64657027 Accept-Ranges: bytes Server: Brisket/1.0.1 Date: Wed,14 Dec 2011 16:11:25 GMT Content-Range: bytes 0-64657026/64657027
后续的范围请求捕获文件的结尾(可能捕获尾随元数据):
GET /BigBuckBunny_320x180.mp4 Connection: keep-alive Accept-Language: en-GB,en-US,en Host: localhost:8080 Range: bytes=64312833-64657026 Accept: */* If-Range: A023EF02BD589BC472A2D6774EAE3C58 User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.7 ... Referer: http://localhost:8080/BigBuckBunny_320x180.mp4 Accept-Encoding: identity Accept-Charset: ISO-8859-1,utf-8,* 206 Partial Content Content-Type: video/mp4 Connection: keep-alive Last-Modified: Wed,14 Dec 2011 15:50:59 GMT ETag: A023EF02BD589BC472A2D6774EAE3C58 Transfer-Encoding: Content-Length: 344194 Accept-Ranges: bytes Server: Brisket/1.0.1 Date: Wed,14 Dec 2011 16:11:25 GMT Content-Range: bytes 64312833-64657026/64657027
用户点击下载范围之外的video进度条 – 发出范围请求以从所选位置开始播放:
GET /BigBuckBunny_320x180.mp4 Connection: keep-alive Accept-Language: en-GB,en-US,en Host: localhost:8080 Range: bytes=1073152-64313343 Accept: */* If-Range: A023EF02BD589BC472A2D6774EAE3C58 User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.7 ... Referer: http://localhost:8080/BigBuckBunny_320x180.mp4 Accept-Encoding: identity Accept-Charset: ISO-8859-1,utf-8,* 206 Partial Content Content-Type: video/mp4 Connection: keep-alive Last-Modified: Wed,14 Dec 2011 15:50:59 GMT ETag: A023EF02BD589BC472A2D6774EAE3C58 Transfer-Encoding: Content-Length: 63240192 Accept-Ranges: bytes Server: Brisket/1.0.1 Date: Wed,14 Dec 2011 16:11:25 GMT Content-Range: bytes 1073152-64313343/64657027