source: draft-ietf-httpbis/latest/p5-range.xml @ 29

Last change on this file since 29 was 29, checked in by fielding@…, 12 years ago

Partition RFC 2616 into seven (mostly) independent documents.
No semantic changes. Some meaningless crossreferences to prior
editorial decisions have been removed from appendices.

Structural changes minimized to simplify diff versus rfc2616.
This was a lot harder than it looks.

Part 8 (Cookies) is for future specification based on RFC 2965.

  • Property svn:eol-style set to native
File size: 33.4 KB
Line 
1<?xml version="1.0" encoding="utf-8"?>
2<!DOCTYPE rfc [
3  <!ENTITY MAY "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>MAY</bcp14>">
4  <!ENTITY MUST "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>MUST</bcp14>">
5  <!ENTITY MUST-NOT "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>MUST NOT</bcp14>">
6  <!ENTITY OPTIONAL "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>OPTIONAL</bcp14>">
7  <!ENTITY RECOMMENDED "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>RECOMMENDED</bcp14>">
8  <!ENTITY REQUIRED "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>REQUIRED</bcp14>">
9  <!ENTITY SHALL "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>SHALL</bcp14>">
10  <!ENTITY SHALL-NOT "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>SHALL NOT</bcp14>">
11  <!ENTITY SHOULD "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>SHOULD</bcp14>">
12  <!ENTITY SHOULD-NOT "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>SHOULD NOT</bcp14>">
13  <!ENTITY ID-VERSION "latest">
14  <!ENTITY messaging                  "[Part 1]">
15  <!ENTITY weak-and-strong-validators "[Part 4]">
16]>
17<?rfc toc="yes" ?>
18<?rfc symrefs="yes" ?>
19<?rfc sortrefs="yes" ?>
20<?rfc compact="yes"?>
21<?rfc subcompact="no" ?>
22<?rfc linkmailto="no" ?>
23<?rfc editing="no" ?>
24<?rfc-ext allow-markup-in-artwork="yes" ?>
25<?rfc-ext include-references-in-index="yes" ?>
26<rfc obsoletes="2068, 2616, 2617" category="std"
27     ipr="full3978" docName="draft-ietf-httpbis-p5-range-&ID-VERSION;"
28     xmlns:x='http://purl.org/net/xml2rfc/ext' xmlns:ed="http://greenbytes.de/2002/rfcedit">
29<front>
30
31  <title abbrev="HTTP/1.1">HTTP/1.1, part 5: Range Requests and Partial Responses</title>
32
33  <author initials="R." surname="Fielding" fullname="Roy T. Fielding" role="editor">
34    <organization abbrev="Day Software">Day Software</organization>
35    <address>
36      <postal>
37        <street>23 Corporate Plaza DR, Suite 280</street>
38        <city>Newport Beach</city>
39        <region>CA</region>
40        <code>92660</code>
41        <country>USA</country>
42      </postal>
43      <phone>+1-949-706-5300</phone>
44      <facsimile>+1-949-706-5305</facsimile>
45      <email>fielding@gbiv.com</email>
46      <uri>http://roy.gbiv.com/</uri>
47    </address>
48  </author>
49
50  <author initials="J." surname="Gettys" fullname="Jim Gettys">
51    <organization>One Laptop per Child</organization>
52    <address>
53      <postal>
54        <street>21 Oak Knoll Road</street>
55        <city>Carlisle</city>
56        <region>MA</region>
57        <code>01741</code>
58        <country>USA</country>
59      </postal>
60      <email>jg@laptop.org</email>
61      <uri>http://www.laptop.org/</uri>
62    </address>
63  </author>
64 
65  <author initials="J." surname="Mogul" fullname="Jeffrey C. Mogul">
66    <organization abbrev="HP">Hewlett-Packard Company</organization>
67    <address>
68      <postal>
69        <street>HP Labs, Large Scale Systems Group</street>
70        <street>1501 Page Mill Road, MS 1177</street>
71        <city>Palo Alto</city>
72        <region>CA</region>
73        <code>94304</code>
74        <country>USA</country>
75      </postal>
76      <email>JeffMogul@acm.org</email>
77    </address>
78  </author>
79
80  <author initials="H." surname="Frystyk" fullname="Henrik Frystyk Nielsen">
81    <organization abbrev="Microsoft">Microsoft Corporation</organization>
82    <address>
83      <postal>
84        <street>1 Microsoft Way</street>
85        <city>Redmond</city>
86        <region>WA</region>
87        <code>98052</code>
88        <country>USA</country>
89      </postal>
90      <email>henrikn@microsoft.com</email>
91    </address>
92  </author>
93
94  <author initials="L." surname="Masinter" fullname="Larry Masinter">
95    <organization abbrev="Adobe Systems">Adobe Systems, Incorporated</organization>
96    <address>
97      <postal>
98        <street>345 Park Ave</street>
99        <city>San Jose</city>
100        <region>CA</region>
101        <code>95110</code>
102        <country>USA</country>
103      </postal>
104      <email>LMM@acm.org</email>
105      <uri>http://larry.masinter.net/</uri>
106    </address>
107  </author>
108 
109  <author initials="P." surname="Leach" fullname="Paul J. Leach">
110    <organization abbrev="Microsoft">Microsoft Corporation</organization>
111    <address>
112      <postal>
113        <street>1 Microsoft Way</street>
114        <city>Redmond</city>
115        <region>WA</region>
116        <code>98052</code>
117      </postal>
118      <email>paulle@microsoft.com</email>
119    </address>
120  </author>
121   
122  <author initials="T." surname="Berners-Lee" fullname="Tim Berners-Lee">
123    <organization abbrev="W3C/MIT">World Wide Web Consortium</organization>
124    <address>
125      <postal>
126        <street>MIT Laboratory for Computer Science</street>
127        <street>545 Technology Square</street>
128        <city>Cambridge</city>
129        <region>MA</region>
130        <code>02139</code>
131        <country>USA</country>
132      </postal>
133      <facsimile>+1 (617) 258 8682</facsimile>
134      <email>timbl@w3.org</email>
135    </address>
136  </author>
137
138  <date month="December" year="2007"/>
139
140<abstract>
141<t>
142   The Hypertext Transfer Protocol (HTTP) is an application-level
143   protocol for distributed, collaborative, hypermedia information
144   systems. HTTP has been in use by the World Wide Web global information
145   initiative since 1990. This document is Part 5 of the eight-part specification
146   that defines the protocol referred to as "HTTP/1.1" and, taken together,
147   updates RFC 2616 and RFC 2617.  Part 5 defines range-specific requests and
148   the rules for constructing and combining responses to those requests.
149</t>
150</abstract>
151</front>
152<middle>
153<section title="Introduction" anchor="introduction">
154<t>
155   This document will define aspects of HTTP related to range requests,
156   partial responses, and the multipart/byteranges media type.  Right now
157   it only includes the extracted relevant sections of
158   <xref target="RFC2616">RFC 2616</xref> without edit.
159</t>
160</section>
161
162<section title="Range Units" anchor="range.units">
163<t>
164   HTTP/1.1 allows a client to request that only part (a range of) the
165   response entity be included within the response. HTTP/1.1 uses range
166   units in the Range (<xref target="header.range"/>) and Content-Range (<xref target="header.content-range"/>)
167   header fields. An entity can be broken down into subranges according
168   to various structural units.
169</t>
170<figure><artwork type="abnf2616"><iref primary="true" item="Grammar" subitem="range-unit"/><iref primary="true" item="Grammar" subitem="bytes-unit"/><iref primary="true" item="Grammar" subitem="other-range-unit"/>
171   range-unit       = bytes-unit | other-range-unit
172   bytes-unit       = "bytes"
173   other-range-unit = token
174</artwork></figure>
175<t>
176   The only range unit defined by HTTP/1.1 is "bytes". HTTP/1.1
177   implementations &MAY; ignore ranges specified using other units.
178</t>
179<t>
180   HTTP/1.1 has been designed to allow implementations of applications
181   that do not depend on knowledge of ranges.
182</t>
183</section>
184
185<section title="206 Partial Content" anchor="status.206">
186  <iref primary="true" item="206 Partial Content (status code)" x:for-anchor=""/>
187  <iref primary="true" item="Status Codes" subitem="206 Partial Content" x:for-anchor=""/>
188<t>
189   The server has fulfilled the partial GET request for the resource.
190   The request &MUST; have included a Range header field (<xref target="header.range"/>)
191   indicating the desired range, and &MAY; have included an If-Range
192   header field (<xref target="header.if-range"/>) to make the request conditional.
193</t>
194<t>
195   The response &MUST; include the following header fields:
196  <list style="symbols">
197    <t>
198        Either a Content-Range header field (<xref target="header.content-range"/>) indicating
199        the range included with this response, or a multipart/byteranges
200        Content-Type including Content-Range fields for each part. If a
201        Content-Length header field is present in the response, its
202        value &MUST; match the actual number of OCTETs transmitted in the
203        message-body.
204    </t>
205    <t>
206        Date
207    </t>
208    <t>
209        ETag and/or Content-Location, if the header would have been sent
210        in a 200 response to the same request
211    </t>
212    <t>
213        Expires, Cache-Control, and/or Vary, if the field-value might
214        differ from that sent in any previous response for the same
215        variant
216    </t>
217  </list>
218</t>
219<t>
220   If the 206 response is the result of an If-Range request that used a
221   strong cache validator (see &weak-and-strong-validators;), the response &SHOULD-NOT; 
222   include other entity-headers. If the response is the result of an
223   If-Range request that used a weak validator, the response &MUST-NOT;
224   include other entity-headers; this prevents inconsistencies between
225   cached entity-bodies and updated headers. Otherwise, the response
226   &MUST; include all of the entity-headers that would have been returned
227   with a 200 (OK) response to the same request.
228</t>
229<t>
230   A cache &MUST-NOT; combine a 206 response with other previously cached
231   content if the ETag or Last-Modified headers do not match exactly,
232   see <xref target="combining.byte.ranges" format="counter"/>.
233</t>
234<t>
235   A cache that does not support the Range and Content-Range headers
236   &MUST-NOT; cache 206 (Partial) responses.
237</t>
238</section>
239
240<section title="416 Requested Range Not Satisfiable" anchor="status.416">
241  <iref primary="true" item="416 Requested Range Not Satisfiable (status code)" x:for-anchor=""/>
242  <iref primary="true" item="Status Codes" subitem="416 Requested Range Not Satisfiable" x:for-anchor=""/>
243<t>
244   A server &SHOULD; return a response with this status code if a request
245   included a Range request-header field (<xref target="header.range"/>), and none of
246   the range-specifier values in this field overlap the current extent
247   of the selected resource, and the request did not include an If-Range
248   request-header field. (For byte-ranges, this means that the first-byte-pos
249   of all of the byte-range-spec values were greater than the
250   current length of the selected resource.)
251</t>
252<t>
253   When this status code is returned for a byte-range request, the
254   response &SHOULD; include a Content-Range entity-header field
255   specifying the current length of the selected resource (see <xref target="header.content-range"/>).
256   This response &MUST-NOT; use the multipart/byteranges content-type.
257</t>
258</section>
259
260<section title="Combining Byte Ranges" anchor="combining.byte.ranges">
261<t>
262   A response might transfer only a subrange of the bytes of an entity-body,
263   either because the request included one or more Range
264   specifications, or because a connection was broken prematurely. After
265   several such transfers, a cache might have received several ranges of
266   the same entity-body.
267</t>
268<t>
269   If a cache has a stored non-empty set of subranges for an entity, and
270   an incoming response transfers another subrange, the cache &MAY;
271   combine the new subrange with the existing set if both the following
272   conditions are met:
273  <list style="symbols">
274    <t>Both the incoming response and the cache entry have a cache
275        validator.</t>
276    <t>The two cache validators match using the strong comparison
277        function (see &weak-and-strong-validators;).</t>
278  </list>
279</t>
280<t>
281   If either requirement is not met, the cache &MUST; use only the most
282   recent partial response (based on the Date values transmitted with
283   every response, and using the incoming response if these values are
284   equal or missing), and &MUST; discard the other partial information.
285</t>
286</section>
287
288<section title="Header Field Definitions" anchor="header.fields">
289<t>
290   This section defines the syntax and semantics of all standard
291   HTTP/1.1 header fields. For entity-header fields, both sender and
292   recipient refer to either the client or the server, depending on who
293   sends and who receives the entity.
294</t>
295<section title="Accept-Ranges" anchor="header.accept-ranges">
296  <iref primary="true" item="Accept-Ranges header" x:for-anchor=""/>
297  <iref primary="true" item="Headers" subitem="Accept-Ranges" x:for-anchor=""/>
298<t>
299      The Accept-Ranges response-header field allows the server to
300      indicate its acceptance of range requests for a resource:
301</t>
302<figure><artwork type="abnf2616"><iref primary="true" item="Grammar" subitem="Accept-Ranges"/><iref primary="true" item="Grammar" subitem="acceptable-ranges"/>
303       Accept-Ranges     = "Accept-Ranges" ":" acceptable-ranges
304       acceptable-ranges = 1#range-unit | "none"
305</artwork></figure>
306<t>
307      Origin servers that accept byte-range requests &MAY; send
308</t>
309<figure><artwork type="example">
310       Accept-Ranges: bytes
311</artwork></figure>
312<t>
313      but are not required to do so. Clients &MAY; generate byte-range
314      requests without having received this header for the resource
315      involved. Range units are defined in <xref target="range.units"/>.
316</t>
317<t>
318      Servers that do not accept any kind of range request for a
319      resource &MAY; send
320</t>
321<figure><artwork type="example">
322       Accept-Ranges: none
323</artwork></figure>
324<t>
325      to advise the client not to attempt a range request.
326</t>
327</section>
328
329<section title="Content-Range" anchor="header.content-range">
330  <iref primary="true" item="Content-Range header" x:for-anchor=""/>
331  <iref primary="true" item="Headers" subitem="Content-Range" x:for-anchor=""/>
332<t>
333   The Content-Range entity-header is sent with a partial entity-body to
334   specify where in the full entity-body the partial body should be
335   applied. Range units are defined in <xref target="range.units"/>.
336</t>
337<figure><artwork type="abnf2616"><iref primary="true" item="Grammar" subitem="Content-Range"/><iref primary="true" item="Grammar" subitem="content-range-spec"/><iref primary="true" item="Grammar" subitem="byte-content-range-spec"/><iref primary="true" item="Grammar" subitem="byte-range-resp-spec"/><iref primary="true" item="Grammar" subitem="instance-length"/>
338    Content-Range = "Content-Range" ":" content-range-spec
339
340    content-range-spec      = byte-content-range-spec
341    byte-content-range-spec = bytes-unit SP
342                              byte-range-resp-spec "/"
343                              ( instance-length | "*" )
344
345    byte-range-resp-spec = (first-byte-pos "-" last-byte-pos)
346                                   | "*"
347    instance-length           = 1*DIGIT
348</artwork></figure>
349<t>
350   The header &SHOULD; indicate the total length of the full entity-body,
351   unless this length is unknown or difficult to determine. The asterisk
352   "*" character means that the instance-length is unknown at the time
353   when the response was generated.
354</t>
355<t>
356   Unlike byte-ranges-specifier values (see <xref target="byte.ranges"/>), a byte-range-resp-spec
357   &MUST; only specify one range, and &MUST; contain
358   absolute byte positions for both the first and last byte of the
359   range.
360</t>
361<t>
362   A byte-content-range-spec with a byte-range-resp-spec whose last-byte-pos
363   value is less than its first-byte-pos value, or whose
364   instance-length value is less than or equal to its last-byte-pos
365   value, is invalid. The recipient of an invalid byte-content-range-spec
366   &MUST; ignore it and any content transferred along with it.
367</t>
368<t>
369   A server sending a response with status code 416 (Requested range not
370   satisfiable) &SHOULD; include a Content-Range field with a byte-range-resp-spec
371   of "*". The instance-length specifies the current length of
372   the selected resource. A response with status code 206 (Partial
373   Content) &MUST-NOT; include a Content-Range field with a byte-range-resp-spec of "*".
374</t>
375<t>
376   Examples of byte-content-range-spec values, assuming that the entity
377   contains a total of 1234 bytes:
378   <list style="symbols">
379      <t>
380        The first 500 bytes:
381<figure><artwork type="text/plain">
382   bytes 0-499/1234
383</artwork></figure>
384      </t>   
385      <t>
386        The second 500 bytes:
387<figure><artwork type="text/plain">
388   bytes 500-999/1234
389</artwork></figure>
390      </t>   
391      <t>
392        All except for the first 500 bytes:
393<figure><artwork type="text/plain">
394   bytes 500-1233/1234
395</artwork></figure>
396      </t>   
397      <t>
398        The last 500 bytes:
399<figure><artwork type="text/plain">
400   bytes 734-1233/1234
401</artwork></figure>
402      </t>   
403   </list>
404</t>
405<t>
406   When an HTTP message includes the content of a single range (for
407   example, a response to a request for a single range, or to a request
408   for a set of ranges that overlap without any holes), this content is
409   transmitted with a Content-Range header, and a Content-Length header
410   showing the number of bytes actually transferred. For example,
411</t>
412<figure><artwork type="example">
413    HTTP/1.1 206 Partial content
414    Date: Wed, 15 Nov 1995 06:25:24 GMT
415    Last-Modified: Wed, 15 Nov 1995 04:58:08 GMT
416    Content-Range: bytes 21010-47021/47022
417    Content-Length: 26012
418    Content-Type: image/gif
419</artwork></figure>
420<t>
421   When an HTTP message includes the content of multiple ranges (for
422   example, a response to a request for multiple non-overlapping
423   ranges), these are transmitted as a multipart message. The multipart
424   media type used for this purpose is "multipart/byteranges" as defined
425   in <xref target="internet.media.type.multipart.byteranges"/>. See <xref target="changes.from.rfc.2068"/> for a compatibility issue.
426</t>
427<t>
428   A response to a request for a single range &MUST-NOT; be sent using the
429   multipart/byteranges media type.  A response to a request for
430   multiple ranges, whose result is a single range, &MAY; be sent as a
431   multipart/byteranges media type with one part. A client that cannot
432   decode a multipart/byteranges message &MUST-NOT; ask for multiple
433   byte-ranges in a single request.
434</t>
435<t>
436   When a client requests multiple byte-ranges in one request, the
437   server &SHOULD; return them in the order that they appeared in the
438   request.
439</t>
440<t>
441   If the server ignores a byte-range-spec because it is syntactically
442   invalid, the server &SHOULD; treat the request as if the invalid Range
443   header field did not exist. (Normally, this means return a 200
444   response containing the full entity).
445</t>
446<t>
447   If the server receives a request (other than one including an If-Range
448   request-header field) with an unsatisfiable Range request-header
449   field (that is, all of whose byte-range-spec values have a
450   first-byte-pos value greater than the current length of the selected
451   resource), it &SHOULD; return a response code of 416 (Requested range
452   not satisfiable) (<xref target="status.416"/>).
453  <list><t>
454      <x:h>Note:</x:h> clients cannot depend on servers to send a 416 (Requested
455      range not satisfiable) response instead of a 200 (OK) response for
456      an unsatisfiable Range request-header, since not all servers
457      implement this request-header.
458  </t></list>
459</t>
460</section>
461
462<section title="If-Range" anchor="header.if-range">
463  <iref primary="true" item="If-Range header" x:for-anchor=""/>
464  <iref primary="true" item="Headers" subitem="If-Range" x:for-anchor=""/>
465<t>
466   If a client has a partial copy of an entity in its cache, and wishes
467   to have an up-to-date copy of the entire entity in its cache, it
468   could use the Range request-header with a conditional GET (using
469   either or both of If-Unmodified-Since and If-Match.) However, if the
470   condition fails because the entity has been modified, the client
471   would then have to make a second request to obtain the entire current
472   entity-body.
473</t>
474<t>
475   The If-Range header allows a client to "short-circuit" the second
476   request. Informally, its meaning is `if the entity is unchanged, send
477   me the part(s) that I am missing; otherwise, send me the entire new
478   entity'.
479</t>
480<figure><artwork type="abnf2616"><iref primary="true" item="Grammar" subitem="If-Range"/>
481     If-Range = "If-Range" ":" ( entity-tag | HTTP-date )
482</artwork></figure>
483<t>
484   If the client has no entity tag for an entity, but does have a Last-Modified
485   date, it &MAY; use that date in an If-Range header. (The
486   server can distinguish between a valid HTTP-date and any form of
487   entity-tag by examining no more than two characters.) The If-Range
488   header &SHOULD; only be used together with a Range header, and &MUST; be
489   ignored if the request does not include a Range header, or if the
490   server does not support the sub-range operation.
491</t>
492<t>
493   If the entity tag given in the If-Range header matches the current
494   entity tag for the entity, then the server &SHOULD; provide the
495   specified sub-range of the entity using a 206 (Partial content)
496   response. If the entity tag does not match, then the server &SHOULD;
497   return the entire entity using a 200 (OK) response.
498</t>
499</section>
500
501<section title="Range" anchor="header.range">
502  <iref primary="true" item="Range header" x:for-anchor=""/>
503  <iref primary="true" item="Headers" subitem="Range" x:for-anchor=""/>
504
505<section title="Byte Ranges" anchor="byte.ranges">
506<t>
507   Since all HTTP entities are represented in HTTP messages as sequences
508   of bytes, the concept of a byte range is meaningful for any HTTP
509   entity. (However, not all clients and servers need to support byte-range
510   operations.)
511</t>
512<t>
513   Byte range specifications in HTTP apply to the sequence of bytes in
514   the entity-body (not necessarily the same as the message-body).
515</t>
516<t>
517   A byte range operation &MAY; specify a single range of bytes, or a set
518   of ranges within a single entity.
519</t>
520<figure><artwork type="abnf2616"><iref primary="true" item="Grammar" subitem="ranges-specifier"/><iref primary="true" item="Grammar" subitem="byte-ranges-specifier"/><iref primary="true" item="Grammar" subitem="byte-range-set"/><iref primary="true" item="Grammar" subitem="byte-range-spec"/><iref primary="true" item="Grammar" subitem="first-byte-pos"/><iref primary="true" item="Grammar" subitem="last-byte-pos"/>
521    ranges-specifier = byte-ranges-specifier
522    byte-ranges-specifier = bytes-unit "=" byte-range-set
523    byte-range-set  = 1#( byte-range-spec | suffix-byte-range-spec )
524    byte-range-spec = first-byte-pos "-" [last-byte-pos]
525    first-byte-pos  = 1*DIGIT
526    last-byte-pos   = 1*DIGIT
527</artwork></figure>
528<t>
529   The first-byte-pos value in a byte-range-spec gives the byte-offset
530   of the first byte in a range. The last-byte-pos value gives the
531   byte-offset of the last byte in the range; that is, the byte
532   positions specified are inclusive. Byte offsets start at zero.
533</t>
534<t>
535   If the last-byte-pos value is present, it &MUST; be greater than or
536   equal to the first-byte-pos in that byte-range-spec, or the byte-range-spec
537   is syntactically invalid. The recipient of a byte-range-set
538   that includes one or more syntactically invalid byte-range-spec
539   values &MUST; ignore the header field that includes that byte-range-set.
540</t>
541<t>
542   If the last-byte-pos value is absent, or if the value is greater than
543   or equal to the current length of the entity-body, last-byte-pos is
544   taken to be equal to one less than the current length of the entity-body
545   in bytes.
546</t>
547<t>
548   By its choice of last-byte-pos, a client can limit the number of
549   bytes retrieved without knowing the size of the entity.
550</t>
551<figure><artwork type="abnf2616"><iref primary="true" item="Grammar" subitem="suffix-byte-range-spec"/><iref primary="true" item="Grammar" subitem="suffix-length"/>
552    suffix-byte-range-spec = "-" suffix-length
553    suffix-length = 1*DIGIT
554</artwork></figure>
555<t>
556   A suffix-byte-range-spec is used to specify the suffix of the
557   entity-body, of a length given by the suffix-length value. (That is,
558   this form specifies the last N bytes of an entity-body.) If the
559   entity is shorter than the specified suffix-length, the entire
560   entity-body is used.
561</t>
562<t>
563   If a syntactically valid byte-range-set includes at least one byte-range-spec
564   whose first-byte-pos is less than the current length of
565   the entity-body, or at least one suffix-byte-range-spec with a non-zero
566   suffix-length, then the byte-range-set is satisfiable.
567   Otherwise, the byte-range-set is unsatisfiable. If the byte-range-set
568   is unsatisfiable, the server &SHOULD; return a response with a status
569   of 416 (Requested range not satisfiable). Otherwise, the server
570   &SHOULD; return a response with a status of 206 (Partial Content)
571   containing the satisfiable ranges of the entity-body.
572</t>
573<t>
574   Examples of byte-ranges-specifier values (assuming an entity-body of
575   length 10000):
576  <list style="symbols">
577     <t>The first 500 bytes (byte offsets 0-499, inclusive):  bytes=0-499</t>
578
579     <t>The second 500 bytes (byte offsets 500-999, inclusive):
580        bytes=500-999</t>
581
582     <t>The final 500 bytes (byte offsets 9500-9999, inclusive):
583        bytes=-500</t>
584
585     <t>Or bytes=9500-</t>
586
587     <t>The first and last bytes only (bytes 0 and 9999):  bytes=0-0,-1</t>
588
589     <t>Several legal but not canonical specifications of the second 500
590        bytes (byte offsets 500-999, inclusive):
591        <vspace/>
592         bytes=500-600,601-999<vspace/>
593         bytes=500-700,601-999</t>
594  </list>
595</t>
596</section>
597
598<section title="Range Retrieval Requests" anchor="range.retrieval.requests">
599<t>
600   HTTP retrieval requests using conditional or unconditional GET
601   methods &MAY; request one or more sub-ranges of the entity, instead of
602   the entire entity, using the Range request header, which applies to
603   the entity returned as the result of the request:
604</t>
605<figure><artwork type="abnf2616"><iref primary="true" item="Grammar" subitem="Range"/>
606   Range = "Range" ":" ranges-specifier
607</artwork></figure>
608<t>
609   A server &MAY; ignore the Range header. However, HTTP/1.1 origin
610   servers and intermediate caches ought to support byte ranges when
611   possible, since Range supports efficient recovery from partially
612   failed transfers, and supports efficient partial retrieval of large
613   entities.
614</t>
615<t>
616   If the server supports the Range header and the specified range or
617   ranges are appropriate for the entity:
618  <list style="symbols">
619     <t>The presence of a Range header in an unconditional GET modifies
620        what is returned if the GET is otherwise successful. In other
621        words, the response carries a status code of 206 (Partial
622        Content) instead of 200 (OK).</t>
623
624     <t>The presence of a Range header in a conditional GET (a request
625        using one or both of If-Modified-Since and If-None-Match, or
626        one or both of If-Unmodified-Since and If-Match) modifies what
627        is returned if the GET is otherwise successful and the
628        condition is true. It does not affect the 304 (Not Modified)
629        response returned if the conditional is false.</t>
630  </list>
631</t>
632<t>
633   In some cases, it might be more appropriate to use the If-Range
634   header (see <xref target="header.if-range"/>) in addition to the Range header.
635</t>
636<t>
637   If a proxy that supports ranges receives a Range request, forwards
638   the request to an inbound server, and receives an entire entity in
639   reply, it &SHOULD; only return the requested range to its client. It
640   &SHOULD; store the entire received response in its cache if that is
641   consistent with its cache allocation policies.
642</t>
643</section>
644</section>
645</section>
646
647<section title="IANA Considerations" anchor="IANA.considerations">
648<t>
649   TBD.
650</t>
651</section>
652
653<section title="Security Considerations" anchor="security.considerations">
654<t>
655   No additional security considerations have been identified beyond
656   those applicable to HTTP in general &messaging;.
657</t>
658</section>
659
660<section title="Acknowledgments" anchor="ack">
661<t>
662   Most of the specification of ranges is based on work originally done
663   by Ari Luotonen and John Franks, with additional input from Steve
664   Zilles.
665</t>
666<t>
667   Based on an XML translation of RFC 2616 by Julian Reschke.
668</t>
669</section>
670</middle>
671<back>
672<references>
673
674<reference anchor="RFC2046">
675<front>
676<title abbrev="Media Types">Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types</title>
677<author initials="N." surname="Freed" fullname="Ned Freed">
678<organization>Innosoft International, Inc.</organization>
679<address>
680<postal>
681<street>1050 East Garvey Avenue South</street>
682<city>West Covina</city>
683<region>CA</region>
684<code>91790</code>
685<country>US</country></postal>
686<phone>+1 818 919 3600</phone>
687<facsimile>+1 818 919 3614</facsimile>
688<email>ned@innosoft.com</email></address></author>
689<author initials="N." surname="Borenstein" fullname="Nathaniel S. Borenstein">
690<organization>First Virtual Holdings</organization>
691<address>
692<postal>
693<street>25 Washington Avenue</street>
694<city>Morristown</city>
695<region>NJ</region>
696<code>07960</code>
697<country>US</country></postal>
698<phone>+1 201 540 8967</phone>
699<facsimile>+1 201 993 3032</facsimile>
700<email>nsb@nsb.fv.com</email></address></author>
701<date month="November" year="1996"/>
702</front>
703<seriesInfo name="RFC" value="2046"/>
704</reference>
705
706   <reference anchor="RFC2616">
707     <front>
708       <title>Hypertext Transfer Protocol -- HTTP/1.1</title>
709       <author initials="R." surname="Fielding" fullname="R. Fielding">
710         <organization>University of California, Irvine</organization>
711         <address><email>fielding@ics.uci.edu</email></address>
712       </author>
713       <author initials="J." surname="Gettys" fullname="J. Gettys">
714         <organization>W3C</organization>
715         <address><email>jg@w3.org</email></address>
716       </author>
717       <author initials="J." surname="Mogul" fullname="J. Mogul">
718         <organization>Compaq Computer Corporation</organization>
719         <address><email>mogul@wrl.dec.com</email></address>
720       </author>
721       <author initials="H." surname="Frystyk" fullname="H. Frystyk">
722         <organization>MIT Laboratory for Computer Science</organization>
723         <address><email>frystyk@w3.org</email></address>
724       </author>
725       <author initials="L." surname="Masinter" fullname="L. Masinter">
726         <organization>Xerox Corporation</organization>
727         <address><email>masinter@parc.xerox.com</email></address>
728       </author>
729       <author initials="P." surname="Leach" fullname="P. Leach">
730         <organization>Microsoft Corporation</organization>
731         <address><email>paulle@microsoft.com</email></address>
732       </author>
733       <author initials="T." surname="Berners-Lee" fullname="T. Berners-Lee">
734         <organization>W3C</organization>
735         <address><email>timbl@w3.org</email></address>
736       </author>
737       <date month="June" year="1999"/>
738     </front>
739     <seriesInfo name="RFC" value="2616"/>
740   </reference>
741
742</references>
743
744<section title="Internet Media Type multipart/byteranges" anchor="internet.media.type.multipart.byteranges">
745<iref item="Media Type" subitem="multipart/byteranges" primary="true"/>
746<iref item="multipart/byteranges Media Type" primary="true"/>
747<t>
748   When an HTTP 206 (Partial Content) response message includes the
749   content of multiple ranges (a response to a request for multiple
750   non-overlapping ranges), these are transmitted as a multipart
751   message-body. The media type for this purpose is called
752   "multipart/byteranges".
753</t><t>
754   The multipart/byteranges media type includes two or more parts, each
755   with its own Content-Type and Content-Range fields. The required
756   boundary parameter specifies the boundary string used to separate
757   each body-part.
758</t>
759<t>
760  <list style="hanging" x:indent="12em">
761    <t hangText="Media Type name:">
762      multipart
763    </t>
764    <t hangText="Media subtype name:">
765      byteranges
766    </t>
767    <t hangText="Required parameters:">
768      boundary
769    </t>
770    <t hangText="Optional parameters:">
771      none
772    </t>
773    <t hangText="Encoding considerations:">
774      only "7bit", "8bit", or "binary" are permitted
775    </t>
776    <t hangText="Security considerations:">
777      none
778    </t>
779  </list>
780</t>
781<figure><preamble>
782   For example:
783</preamble><artwork type="example">
784   HTTP/1.1 206 Partial Content
785   Date: Wed, 15 Nov 1995 06:25:24 GMT
786   Last-Modified: Wed, 15 Nov 1995 04:58:08 GMT
787   Content-type: multipart/byteranges; boundary=THIS_STRING_SEPARATES
788
789   --THIS_STRING_SEPARATES
790   Content-type: application/pdf
791   Content-range: bytes 500-999/8000
792
793   ...the first range...
794   --THIS_STRING_SEPARATES
795   Content-type: application/pdf
796   Content-range: bytes 7000-7999/8000
797
798   ...the second range
799   --THIS_STRING_SEPARATES--
800</artwork></figure>
801<t>
802      Notes:
803  <list style="numbers">
804      <t>Additional CRLFs may precede the first boundary string in the
805         entity.</t>
806
807      <t>Although RFC 2046 <xref target="RFC2046"/> permits the boundary string to be
808         quoted, some existing implementations handle a quoted boundary
809         string incorrectly.</t>
810
811      <t>A number of browsers and servers were coded to an early draft
812         of the byteranges specification to use a media type of
813         multipart/x-byteranges<iref item="multipart/x-byteranges Media Type"/><iref item="Media Type" subitem="multipart/x-byteranges"/>, which is almost, but not quite
814         compatible with the version documented in HTTP/1.1.</t>
815  </list>
816</t>
817</section>
818
819<section title="Changes from RFC 2068" anchor="changes.from.rfc.2068">
820<t>
821   There are situations where a server (especially a proxy) does not
822   know the full length of a response but is capable of serving a
823   byterange request. We therefore need a mechanism to allow byteranges
824   with a content-range not indicating the full length of the message.
825   (<xref target="header.content-range"/>)
826</t>
827<t>
828   Range request responses would become very verbose if all meta-data
829   were always returned; by allowing the server to only send needed
830   headers in a 206 response, this problem can be avoided.
831</t>
832<t>
833   Fix problem with unsatisfiable range requests; there are two cases:
834   syntactic problems, and range doesn't exist in the document. The 416
835   status code was needed to resolve this ambiguity needed to indicate
836   an error for a byte range request that falls outside of the actual
837   contents of a document. (Section <xref target="status.416" format="counter"/>, <xref target="header.content-range" format="counter"/>)
838</t>
839</section>
840
841</back>
842</rfc>
Note: See TracBrowser for help on using the repository browser.