HTTP / 1.1对多个范围的响应 [英] HTTP/1.1 response to multiple range
问题描述
在编写我的HTTP / 1.1服务器时,我遇到了处理多个范围请求的问题。
While writing my HTTP/1.1 server, I get stuck dealing multiple ranges request.
RFC 2616的第14.35.1节提到了一些示例,但没有说明服务器行为。
例如:
Section 14.35.1 of RFC 2616 refers some examples but doesn't clarify server behaviour. For instance:
GET /some/resource HTTP/1.1
...
Range: bytes=200-400,100-300,500-600
...
我应该退货吗这个确切的字节序列?
或者我应该合并所有范围,发送 100-400,500-600
?
或者之间全部发送, 100-600
?
Should I return this exact sequence of bytes?
Or should I merge all ranges, sending 100-400,500-600
?
Or sending all in between, 100-600
?
最差,当检查 Content-Range
响应头(第14.16节),只返回一个范围,所以我想知道服务器如何响应第14.35.1节中的示例 bytes = 0-0,-1
!!!
Worst, when checking Content-Range
response header (Section 14.16), only a single range may be returned, so I wonder how would a server response to example in Section 14.35.1 bytes=0-0,-1
!!!
我的服务器应如何处理此类请求?
How should my server handle such requests?
推荐答案
我刚才看看支持 Range
标头字段的其他服务器如何响应并快速执行 curl
到 example.com :
I just had a look at how other servers that support the Range
header field might respond and did a quick curl
to example.com:
~# curl -s -D - -H "Range: bytes=100-200, 300-400" http://www.example.com
HTTP/1.1 206 Partial Content
Accept-Ranges: bytes
Content-Type: multipart/byteranges; boundary=3d6b6a416f9b5
Content-Length: 385
Server: ECS (fll/0761)
--3d6b6a416f9b5
Content-Type: text/html
Content-Range: bytes 100-200/1270
eta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="vieport" content
--3d6b6a416f9b5
Content-Type: text/html
Content-Range: bytes 300-400/1270
-color: #f0f0f2;
margin: 0;
padding: 0;
font-family: "Open Sans", "Helvetica
--3d6b6a416f9b5--
显然,你要找的是 Content-Type:multipart / byteranges; boundary
响应标题。谷歌搜索完全出现带有RFC 2616附录的W3C文档
Apparently, what your looking for is the Content-Type: multipart/byteranges; boundary
response header. Googling exactly that turned up a W3C document with appendices to RFC 2616
当HTTP 206(部分内容)响应消息包含多个范围的内容(对多个非重叠范围的请求的响应)时,这些消息作为多部分消息发送-body。用于此目的的媒体类型称为
multipart / byteranges
。
multipart / byteranges
媒体类型包括两个或多个部分,每个部分都有自己的Content-Type
和Content-Range
字段。必需的边界参数指定用于分隔每个正文部分的边界字符串。
When an HTTP 206 (Partial Content) response message includes the content of multiple ranges (a response to a request for multiple non-overlapping ranges), these are transmitted as a multipart message-body. The media type for this purpose is called "
multipart/byteranges
".
Themultipart/byteranges
media type includes two or more parts, each with its ownContent-Type
andContent-Range
fields. The required boundary parameter specifies the boundary string used to separate each body-part.
所以你去。
顺便说一句,服务器位于 example.com 不会检查重叠的字节范围,并向您发送您所请求的范围......
By the way, the server at example.com does not check for overlapping byte ranges and sends you exactly the ranges that you requested...
这篇关于HTTP / 1.1对多个范围的响应的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!