source: draft-ietf-httpbis/01/draft-ietf-httpbis-p5-range-01.xml @ 377

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

generated draft 01

  • Property svn:eol-style set to native
File size: 46.3 KB
Line 
1<?xml version="1.0" encoding="UTF-8"?>
2<!--
3    This XML document is the output of clean-for-DTD.xslt; a tool that strips
4    extensions to RFC2629(bis) from documents for processing with xml2rfc.
5-->
6<?xml-stylesheet type='text/xsl' href='../myxml2rfc.xslt'?>
7<?rfc toc="yes" ?>
8<?rfc symrefs="yes" ?>
9<?rfc sortrefs="yes" ?>
10<?rfc compact="yes"?>
11<?rfc subcompact="no" ?>
12<?rfc linkmailto="no" ?>
13<?rfc editing="no" ?>
14<!DOCTYPE rfc
15  PUBLIC "" "rfc2629.dtd">
16<rfc obsoletes="2616" category="std" ipr="full3978" docName="draft-ietf-httpbis-p5-range-01">
17<front>
18
19  <title abbrev="HTTP/1.1, Part 5">HTTP/1.1, part 5: Range Requests and Partial Responses</title>
20
21  <author initials="R." surname="Fielding" fullname="Roy T. Fielding" role="editor">
22    <organization abbrev="Day Software">Day Software</organization>
23    <address>
24      <postal>
25        <street>23 Corporate Plaza DR, Suite 280</street>
26        <city>Newport Beach</city>
27        <region>CA</region>
28        <code>92660</code>
29        <country>USA</country>
30      </postal>
31      <phone>+1-949-706-5300</phone>
32      <facsimile>+1-949-706-5305</facsimile>
33      <email>fielding@gbiv.com</email>
34      <uri>http://roy.gbiv.com/</uri>
35    </address>
36  </author>
37
38  <author initials="J." surname="Gettys" fullname="Jim Gettys">
39    <organization>One Laptop per Child</organization>
40    <address>
41      <postal>
42        <street>21 Oak Knoll Road</street>
43        <city>Carlisle</city>
44        <region>MA</region>
45        <code>01741</code>
46        <country>USA</country>
47      </postal>
48      <email>jg@laptop.org</email>
49      <uri>http://www.laptop.org/</uri>
50    </address>
51  </author>
52 
53  <author initials="J." surname="Mogul" fullname="Jeffrey C. Mogul">
54    <organization abbrev="HP">Hewlett-Packard Company</organization>
55    <address>
56      <postal>
57        <street>HP Labs, Large Scale Systems Group</street>
58        <street>1501 Page Mill Road, MS 1177</street>
59        <city>Palo Alto</city>
60        <region>CA</region>
61        <code>94304</code>
62        <country>USA</country>
63      </postal>
64      <email>JeffMogul@acm.org</email>
65    </address>
66  </author>
67
68  <author initials="H." surname="Frystyk" fullname="Henrik Frystyk Nielsen">
69    <organization abbrev="Microsoft">Microsoft Corporation</organization>
70    <address>
71      <postal>
72        <street>1 Microsoft Way</street>
73        <city>Redmond</city>
74        <region>WA</region>
75        <code>98052</code>
76        <country>USA</country>
77      </postal>
78      <email>henrikn@microsoft.com</email>
79    </address>
80  </author>
81
82  <author initials="L." surname="Masinter" fullname="Larry Masinter">
83    <organization abbrev="Adobe Systems">Adobe Systems, Incorporated</organization>
84    <address>
85      <postal>
86        <street>345 Park Ave</street>
87        <city>San Jose</city>
88        <region>CA</region>
89        <code>95110</code>
90        <country>USA</country>
91      </postal>
92      <email>LMM@acm.org</email>
93      <uri>http://larry.masinter.net/</uri>
94    </address>
95  </author>
96 
97  <author initials="P." surname="Leach" fullname="Paul J. Leach">
98    <organization abbrev="Microsoft">Microsoft Corporation</organization>
99    <address>
100      <postal>
101        <street>1 Microsoft Way</street>
102        <city>Redmond</city>
103        <region>WA</region>
104        <code>98052</code>
105      </postal>
106      <email>paulle@microsoft.com</email>
107    </address>
108  </author>
109   
110  <author initials="T." surname="Berners-Lee" fullname="Tim Berners-Lee">
111    <organization abbrev="W3C/MIT">World Wide Web Consortium</organization>
112    <address>
113      <postal>
114        <street>MIT Computer Science and Artificial Intelligence Laboratory</street>
115        <street>The Stata Center, Building 32</street>
116        <street>32 Vassar Street</street>
117        <city>Cambridge</city>
118        <region>MA</region>
119        <code>02139</code>
120        <country>USA</country>
121      </postal>
122      <email>timbl@w3.org</email>
123      <uri>http://www.w3.org/People/Berners-Lee/</uri>
124    </address>
125  </author>
126
127  <author initials="Y." surname="Lafon" fullname="Yves Lafon" role="editor">
128    <organization abbrev="W3C">World Wide Web Consortium</organization>
129    <address>
130      <postal>
131        <street>W3C / ERCIM</street>
132        <street>2004, rte des Lucioles</street>
133        <city>Sophia-Antipolis</city>
134        <region>AM</region>
135        <code>06902</code>
136        <country>France</country>
137      </postal>
138      <email>ylafon@w3.org</email>
139      <uri>http://www.raubacapeu.net/people/yves/</uri>
140    </address>
141  </author>
142
143  <author initials="J. F." surname="Reschke" fullname="Julian F. Reschke" role="editor">
144    <organization abbrev="greenbytes">greenbytes GmbH</organization>
145    <address>
146      <postal>
147        <street>Hafenweg 16</street>
148        <city>Muenster</city><region>NW</region><code>48155</code>
149        <country>Germany</country>
150      </postal>
151      <phone>+49 251 2807760</phone>   
152      <facsimile>+49 251 2807761</facsimile>   
153      <email>julian.reschke@greenbytes.de</email>       
154      <uri>http://greenbytes.de/tech/webdav/</uri>     
155    </address>
156  </author>
157
158  <date month="January" year="2008" day="12"/>
159
160<abstract>
161<t>
162   The Hypertext Transfer Protocol (HTTP) is an application-level
163   protocol for distributed, collaborative, hypermedia information
164   systems. HTTP has been in use by the World Wide Web global information
165   initiative since 1990. This document is Part 5 of the seven-part specification
166   that defines the protocol referred to as "HTTP/1.1" and, taken together,
167   obsoletes RFC 2616.  Part 5 defines range-specific requests and
168   the rules for constructing and combining responses to those requests.
169</t>
170</abstract>
171
172<note title="Editorial Note (To be removed by RFC Editor)">
173  <t>
174    Discussion of this draft should take place on the HTTPBIS working group
175    mailing list (ietf-http-wg@w3.org). The current issues list is
176    at <eref target="http://www.tools.ietf.org/wg/httpbis/trac/report/11"/>
177    and related documents (including fancy diffs) can be found at
178    <eref target="http://www.tools.ietf.org/wg/httpbis/"/>.
179  </t>
180  <t>
181    This draft incorporates those issue resolutions that were either
182    collected in the original RFC2616 errata list (<eref target="http://purl.org/NET/http-errata"/>),
183    or which were agreed upon on the mailing list between October 2006 and
184    November 2007 (as published in "draft-lafon-rfc2616bis-03").
185  </t>
186</note>
187</front>
188<middle>
189<section title="Introduction" anchor="introduction">
190<t>
191   HTTP clients often encounter interrupted data transfers as a result
192   of cancelled requests or dropped connections.  When a cache has stored
193   a partial representation, it is desirable to request the remainder
194   of that representation in a subsequent request rather than transfer
195   the entire representation.
196   There are also a number of Web applications that benefit from being
197   able to request only a subset of a larger representation, such as a
198   single page of a very large document or only part of an image to be
199   rendered by a device with limited local storage.
200</t>
201<t>
202   This document defines HTTP/1.1 range requests,
203   partial responses, and the multipart/byteranges media type.
204   The protocol for range requests is an OPTIONAL feature of HTTP,
205   designed so resources or recipients that do not implement this feature
206   can respond as if it is a normal GET request without impacting
207   interoperability.  Partial responses are indicated by a distinct status
208   code to not be mistaken for full responses by intermediate caches
209   that might not implement the feature.
210</t>
211<t>
212   Although the HTTP range request mechanism is designed to allow for
213   extensible range types, this specification only defines requests for
214   byte ranges.
215</t>
216
217<section title="Requirements" anchor="intro.requirements">
218<t>
219   The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
220   "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
221   document are to be interpreted as described in <xref target="RFC2119"/>.
222</t>
223<t>
224   An implementation is not compliant if it fails to satisfy one or more
225   of the MUST or REQUIRED level requirements for the protocols it
226   implements. An implementation that satisfies all the MUST or REQUIRED
227   level and all the SHOULD level requirements for its protocols is said
228   to be "unconditionally compliant"; one that satisfies all the MUST
229   level requirements but not all the SHOULD level requirements for its
230   protocols is said to be "conditionally compliant."
231</t>
232</section>
233</section>
234
235<section title="Range Units" anchor="range.units">
236<t>
237   HTTP/1.1 allows a client to request that only part (a range of) the
238   response entity be included within the response. HTTP/1.1 uses range
239   units in the Range (<xref target="header.range"/>) and Content-Range (<xref target="header.content-range"/>)
240   header fields. An entity can be broken down into subranges according
241   to various structural units.
242</t>
243<figure><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"/><artwork type="abnf2616"><![CDATA[
244  range-unit       = bytes-unit | other-range-unit
245  bytes-unit       = "bytes"
246  other-range-unit = token
247]]></artwork></figure>
248<t>
249   The only range unit defined by HTTP/1.1 is "bytes". HTTP/1.1
250   implementations MAY ignore ranges specified using other units.
251</t>
252<t>
253   HTTP/1.1 has been designed to allow implementations of applications
254   that do not depend on knowledge of ranges.
255</t>
256</section>
257
258<section title="Status Code Definitions">
259<section title="206 Partial Content" anchor="status.206">
260  <iref primary="true" item="206 Partial Content (status code)"/>
261  <iref primary="true" item="Status Codes" subitem="206 Partial Content"/>
262<t>
263   The server has fulfilled the partial GET request for the resource.
264   The request MUST have included a Range header field (<xref target="header.range"/>)
265   indicating the desired range, and MAY have included an If-Range
266   header field (<xref target="header.if-range"/>) to make the request conditional.
267</t>
268<t>
269   The response MUST include the following header fields:
270  <list style="symbols">
271    <t>
272        Either a Content-Range header field (<xref target="header.content-range"/>) indicating
273        the range included with this response, or a multipart/byteranges
274        Content-Type including Content-Range fields for each part. If a
275        Content-Length header field is present in the response, its
276        value MUST match the actual number of OCTETs transmitted in the
277        message-body.
278    </t>
279    <t>
280        Date
281    </t>
282    <t>
283        ETag and/or Content-Location, if the header would have been sent
284        in a 200 response to the same request
285    </t>
286    <t>
287        Expires, Cache-Control, and/or Vary, if the field-value might
288        differ from that sent in any previous response for the same
289        variant
290    </t>
291  </list>
292</t>
293<t>
294   If the 206 response is the result of an If-Range request, the response
295   SHOULD NOT include other entity-headers. Otherwise, the response
296   MUST include all of the entity-headers that would have been returned
297   with a 200 (OK) response to the same request.
298</t>
299<t>
300   A cache MUST NOT combine a 206 response with other previously cached
301   content if the ETag or Last-Modified headers do not match exactly,
302   see <xref target="combining.byte.ranges"/>.
303</t>
304<t>
305   A cache that does not support the Range and Content-Range headers
306   MUST NOT cache 206 (Partial Content) responses.
307</t>
308</section>
309
310<section title="416 Requested Range Not Satisfiable" anchor="status.416">
311  <iref primary="true" item="416 Requested Range Not Satisfiable (status code)"/>
312  <iref primary="true" item="Status Codes" subitem="416 Requested Range Not Satisfiable"/>
313<t>
314   A server SHOULD return a response with this status code if a request
315   included a Range request-header field (<xref target="header.range"/>), and none of
316   the range-specifier values in this field overlap the current extent
317   of the selected resource, and the request did not include an If-Range
318   request-header field. (For byte-ranges, this means that the first-byte-pos
319   of all of the byte-range-spec values were greater than the
320   current length of the selected resource.)
321</t>
322<t>
323   When this status code is returned for a byte-range request, the
324   response SHOULD include a Content-Range entity-header field
325   specifying the current length of the selected resource (see <xref target="header.content-range"/>).
326   This response MUST NOT use the multipart/byteranges content-type.
327</t>
328</section>
329</section>
330
331<section title="Combining Byte Ranges" anchor="combining.byte.ranges">
332<t>
333   A response might transfer only a subrange of the bytes of an entity-body,
334   either because the request included one or more Range
335   specifications, or because a connection was broken prematurely. After
336   several such transfers, a cache might have received several ranges of
337   the same entity-body.
338</t>
339<t>
340   If a cache has a stored non-empty set of subranges for an entity, and
341   an incoming response transfers another subrange, the cache MAY
342   combine the new subrange with the existing set if both the following
343   conditions are met:
344  <list style="symbols">
345    <t>Both the incoming response and the cache entry have a cache
346        validator.</t>
347    <t>The two cache validators match using the strong comparison
348        function (see Section 4 of <xref target="Part4"/>).</t>
349  </list>
350</t>
351<t>
352   If either requirement is not met, the cache MUST use only the most
353   recent partial response (based on the Date values transmitted with
354   every response, and using the incoming response if these values are
355   equal or missing), and MUST discard the other partial information.
356</t>
357</section>
358
359<section title="Header Field Definitions" anchor="header.fields">
360<t>
361   This section defines the syntax and semantics of HTTP/1.1 header fields
362   related to range requests and partial responses.
363</t>
364<t>
365   For entity-header fields, both sender and recipient refer to either the
366   client or the server, depending on who sends and who receives the entity.
367</t>
368
369<section title="Accept-Ranges" anchor="header.accept-ranges">
370  <iref primary="true" item="Accept-Ranges header"/>
371  <iref primary="true" item="Headers" subitem="Accept-Ranges"/>
372<t>
373      The Accept-Ranges response-header field allows the server to
374      indicate its acceptance of range requests for a resource:
375</t>
376<figure><iref primary="true" item="Grammar" subitem="Accept-Ranges"/><iref primary="true" item="Grammar" subitem="acceptable-ranges"/><artwork type="abnf2616"><![CDATA[
377  Accept-Ranges     = "Accept-Ranges" ":" acceptable-ranges
378  acceptable-ranges = 1#range-unit | "none"
379]]></artwork></figure>
380<t>
381      Origin servers that accept byte-range requests MAY send
382</t>
383<figure><artwork type="example"><![CDATA[
384       Accept-Ranges: bytes
385]]></artwork></figure>
386<t>
387      but are not required to do so. Clients MAY generate byte-range
388      requests without having received this header for the resource
389      involved. Range units are defined in <xref target="range.units"/>.
390</t>
391<t>
392      Servers that do not accept any kind of range request for a
393      resource MAY send
394</t>
395<figure><artwork type="example"><![CDATA[
396       Accept-Ranges: none
397]]></artwork></figure>
398<t>
399      to advise the client not to attempt a range request.
400</t>
401</section>
402
403<section title="Content-Range" anchor="header.content-range">
404  <iref primary="true" item="Content-Range header"/>
405  <iref primary="true" item="Headers" subitem="Content-Range"/>
406<t>
407   The Content-Range entity-header is sent with a partial entity-body to
408   specify where in the full entity-body the partial body should be
409   applied. Range units are defined in <xref target="range.units"/>.
410</t>
411<figure><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"/><artwork type="abnf2616"><![CDATA[
412  Content-Range = "Content-Range" ":" content-range-spec
413 
414  content-range-spec      = byte-content-range-spec
415  byte-content-range-spec = bytes-unit SP
416                            byte-range-resp-spec "/"
417                            ( instance-length | "*" )
418 
419  byte-range-resp-spec = (first-byte-pos "-" last-byte-pos)
420                                 | "*"
421  instance-length           = 1*DIGIT
422]]></artwork></figure>
423<t>
424   The header SHOULD indicate the total length of the full entity-body,
425   unless this length is unknown or difficult to determine. The asterisk
426   "*" character means that the instance-length is unknown at the time
427   when the response was generated.
428</t>
429<t>
430   Unlike byte-ranges-specifier values (see <xref target="byte.ranges"/>), a byte-range-resp-spec
431   MUST only specify one range, and MUST contain
432   absolute byte positions for both the first and last byte of the
433   range.
434</t>
435<t>
436   A byte-content-range-spec with a byte-range-resp-spec whose last-byte-pos
437   value is less than its first-byte-pos value, or whose
438   instance-length value is less than or equal to its last-byte-pos
439   value, is invalid. The recipient of an invalid byte-content-range-spec
440   MUST ignore it and any content transferred along with it.
441</t>
442<t>
443   A server sending a response with status code 416 (Requested range not
444   satisfiable) SHOULD include a Content-Range field with a byte-range-resp-spec
445   of "*". The instance-length specifies the current length of
446   the selected resource. A response with status code 206 (Partial
447   Content) MUST NOT include a Content-Range field with a byte-range-resp-spec of "*".
448</t>
449<t>
450   Examples of byte-content-range-spec values, assuming that the entity
451   contains a total of 1234 bytes:
452   <list style="symbols">
453      <t>
454        The first 500 bytes:
455<figure><artwork type="text/plain"><![CDATA[
456   bytes 0-499/1234
457]]></artwork></figure>
458      </t>   
459      <t>
460        The second 500 bytes:
461<figure><artwork type="text/plain"><![CDATA[
462   bytes 500-999/1234
463]]></artwork></figure>
464      </t>   
465      <t>
466        All except for the first 500 bytes:
467<figure><artwork type="text/plain"><![CDATA[
468   bytes 500-1233/1234
469]]></artwork></figure>
470      </t>   
471      <t>
472        The last 500 bytes:
473<figure><artwork type="text/plain"><![CDATA[
474   bytes 734-1233/1234
475]]></artwork></figure>
476      </t>   
477   </list>
478</t>
479<t>
480   When an HTTP message includes the content of a single range (for
481   example, a response to a request for a single range, or to a request
482   for a set of ranges that overlap without any holes), this content is
483   transmitted with a Content-Range header, and a Content-Length header
484   showing the number of bytes actually transferred. For example,
485</t>
486<figure><artwork type="example"><![CDATA[
487    HTTP/1.1 206 Partial Content
488    Date: Wed, 15 Nov 1995 06:25:24 GMT
489    Last-Modified: Wed, 15 Nov 1995 04:58:08 GMT
490    Content-Range: bytes 21010-47021/47022
491    Content-Length: 26012
492    Content-Type: image/gif
493]]></artwork></figure>
494<t>
495   When an HTTP message includes the content of multiple ranges (for
496   example, a response to a request for multiple non-overlapping
497   ranges), these are transmitted as a multipart message. The multipart
498   media type used for this purpose is "multipart/byteranges" as defined
499   in <xref target="internet.media.type.multipart.byteranges"/>. See <xref target="changes.from.rfc.2068"/> for a compatibility issue.
500</t>
501<t>
502   A response to a request for a single range MUST NOT be sent using the
503   multipart/byteranges media type.  A response to a request for
504   multiple ranges, whose result is a single range, MAY be sent as a
505   multipart/byteranges media type with one part. A client that cannot
506   decode a multipart/byteranges message MUST NOT ask for multiple
507   byte-ranges in a single request.
508</t>
509<t>
510   When a client requests multiple byte-ranges in one request, the
511   server SHOULD return them in the order that they appeared in the
512   request.
513</t>
514<t>
515   If the server ignores a byte-range-spec because it is syntactically
516   invalid, the server SHOULD treat the request as if the invalid Range
517   header field did not exist. (Normally, this means return a 200
518   response containing the full entity).
519</t>
520<t>
521   If the server receives a request (other than one including an If-Range
522   request-header field) with an unsatisfiable Range request-header
523   field (that is, all of whose byte-range-spec values have a
524   first-byte-pos value greater than the current length of the selected
525   resource), it SHOULD return a response code of 416 (Requested range
526   not satisfiable) (<xref target="status.416"/>).
527  <list><t>
528      Note: clients cannot depend on servers to send a 416 (Requested
529      range not satisfiable) response instead of a 200 (OK) response for
530      an unsatisfiable Range request-header, since not all servers
531      implement this request-header.
532  </t></list>
533</t>
534</section>
535
536<section title="If-Range" anchor="header.if-range">
537  <iref primary="true" item="If-Range header"/>
538  <iref primary="true" item="Headers" subitem="If-Range"/>
539<t>
540   If a client has a partial copy of an entity in its cache, and wishes
541   to have an up-to-date copy of the entire entity in its cache, it
542   could use the Range request-header with a conditional GET (using
543   either or both of If-Unmodified-Since and If-Match.) However, if the
544   condition fails because the entity has been modified, the client
545   would then have to make a second request to obtain the entire current
546   entity-body.
547</t>
548<t>
549   The If-Range header allows a client to "short-circuit" the second
550   request. Informally, its meaning is `if the entity is unchanged, send
551   me the part(s) that I am missing; otherwise, send me the entire new
552   entity'.
553</t>
554<figure><iref primary="true" item="Grammar" subitem="If-Range"/><artwork type="abnf2616"><![CDATA[
555  If-Range = "If-Range" ":" ( entity-tag | HTTP-date )
556]]></artwork></figure>
557<t>
558   If the client has no entity tag for an entity, but does have a Last-Modified
559   date, it MAY use that date in an If-Range header. (The
560   server can distinguish between a valid HTTP-date and any form of
561   entity-tag by examining no more than two characters.) The If-Range
562   header SHOULD only be used together with a Range header, and MUST be
563   ignored if the request does not include a Range header, or if the
564   server does not support the sub-range operation.
565</t>
566<t>
567   If the entity tag given in the If-Range header matches the current
568   entity tag for the entity, then the server SHOULD provide the
569   specified sub-range of the entity using a 206 (Partial Content)
570   response. If the entity tag does not match, then the server SHOULD
571   return the entire entity using a 200 (OK) response.
572</t>
573</section>
574
575<section title="Range" anchor="header.range">
576  <iref primary="true" item="Range header"/>
577  <iref primary="true" item="Headers" subitem="Range"/>
578
579<section title="Byte Ranges" anchor="byte.ranges">
580<t>
581   Since all HTTP entities are represented in HTTP messages as sequences
582   of bytes, the concept of a byte range is meaningful for any HTTP
583   entity. (However, not all clients and servers need to support byte-range
584   operations.)
585</t>
586<t>
587   Byte range specifications in HTTP apply to the sequence of bytes in
588   the entity-body (not necessarily the same as the message-body).
589</t>
590<t>
591   A byte range operation MAY specify a single range of bytes, or a set
592   of ranges within a single entity.
593</t>
594<figure><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"/><artwork type="abnf2616"><![CDATA[
595  ranges-specifier = byte-ranges-specifier
596  byte-ranges-specifier = bytes-unit "=" byte-range-set
597  byte-range-set  = 1#( byte-range-spec | suffix-byte-range-spec )
598  byte-range-spec = first-byte-pos "-" [last-byte-pos]
599  first-byte-pos  = 1*DIGIT
600  last-byte-pos   = 1*DIGIT
601]]></artwork></figure>
602<t>
603   The first-byte-pos value in a byte-range-spec gives the byte-offset
604   of the first byte in a range. The last-byte-pos value gives the
605   byte-offset of the last byte in the range; that is, the byte
606   positions specified are inclusive. Byte offsets start at zero.
607</t>
608<t>
609   If the last-byte-pos value is present, it MUST be greater than or
610   equal to the first-byte-pos in that byte-range-spec, or the byte-range-spec
611   is syntactically invalid. The recipient of a byte-range-set
612   that includes one or more syntactically invalid byte-range-spec
613   values MUST ignore the header field that includes that byte-range-set.
614</t>
615<t>
616   If the last-byte-pos value is absent, or if the value is greater than
617   or equal to the current length of the entity-body, last-byte-pos is
618   taken to be equal to one less than the current length of the entity-body
619   in bytes.
620</t>
621<t>
622   By its choice of last-byte-pos, a client can limit the number of
623   bytes retrieved without knowing the size of the entity.
624</t>
625<figure><iref primary="true" item="Grammar" subitem="suffix-byte-range-spec"/><iref primary="true" item="Grammar" subitem="suffix-length"/><artwork type="abnf2616"><![CDATA[
626  suffix-byte-range-spec = "-" suffix-length
627  suffix-length = 1*DIGIT
628]]></artwork></figure>
629<t>
630   A suffix-byte-range-spec is used to specify the suffix of the
631   entity-body, of a length given by the suffix-length value. (That is,
632   this form specifies the last N bytes of an entity-body.) If the
633   entity is shorter than the specified suffix-length, the entire
634   entity-body is used.
635</t>
636<t>
637   If a syntactically valid byte-range-set includes at least one byte-range-spec
638   whose first-byte-pos is less than the current length of
639   the entity-body, or at least one suffix-byte-range-spec with a non-zero
640   suffix-length, then the byte-range-set is satisfiable.
641   Otherwise, the byte-range-set is unsatisfiable. If the byte-range-set
642   is unsatisfiable, the server SHOULD return a response with a status
643   of 416 (Requested range not satisfiable). Otherwise, the server
644   SHOULD return a response with a status of 206 (Partial Content)
645   containing the satisfiable ranges of the entity-body.
646</t>
647<t>
648   Examples of byte-ranges-specifier values (assuming an entity-body of
649   length 10000):
650  <list style="symbols">
651     <t>The first 500 bytes (byte offsets 0-499, inclusive):  bytes=0-499</t>
652
653     <t>The second 500 bytes (byte offsets 500-999, inclusive):
654        bytes=500-999</t>
655
656     <t>The final 500 bytes (byte offsets 9500-9999, inclusive):
657        bytes=-500</t>
658
659     <t>Or bytes=9500-</t>
660
661     <t>The first and last bytes only (bytes 0 and 9999):  bytes=0-0,-1</t>
662
663     <t>Several legal but not canonical specifications of the second 500
664        bytes (byte offsets 500-999, inclusive):
665        <vspace/>
666         bytes=500-600,601-999<vspace/>
667         bytes=500-700,601-999</t>
668  </list>
669</t>
670</section>
671
672<section title="Range Retrieval Requests" anchor="range.retrieval.requests">
673<t>
674   HTTP retrieval requests using conditional or unconditional GET
675   methods MAY request one or more sub-ranges of the entity, instead of
676   the entire entity, using the Range request header, which applies to
677   the entity returned as the result of the request:
678</t>
679<figure><iref primary="true" item="Grammar" subitem="Range"/><artwork type="abnf2616"><![CDATA[
680  Range = "Range" ":" ranges-specifier
681]]></artwork></figure>
682<t>
683   A server MAY ignore the Range header. However, HTTP/1.1 origin
684   servers and intermediate caches ought to support byte ranges when
685   possible, since Range supports efficient recovery from partially
686   failed transfers, and supports efficient partial retrieval of large
687   entities.
688</t>
689<t>
690   If the server supports the Range header and the specified range or
691   ranges are appropriate for the entity:
692  <list style="symbols">
693     <t>The presence of a Range header in an unconditional GET modifies
694        what is returned if the GET is otherwise successful. In other
695        words, the response carries a status code of 206 (Partial
696        Content) instead of 200 (OK).</t>
697
698     <t>The presence of a Range header in a conditional GET (a request
699        using one or both of If-Modified-Since and If-None-Match, or
700        one or both of If-Unmodified-Since and If-Match) modifies what
701        is returned if the GET is otherwise successful and the
702        condition is true. It does not affect the 304 (Not Modified)
703        response returned if the conditional is false.</t>
704  </list>
705</t>
706<t>
707   In some cases, it might be more appropriate to use the If-Range
708   header (see <xref target="header.if-range"/>) in addition to the Range header.
709</t>
710<t>
711   If a proxy that supports ranges receives a Range request, forwards
712   the request to an inbound server, and receives an entire entity in
713   reply, it SHOULD only return the requested range to its client. It
714   SHOULD store the entire received response in its cache if that is
715   consistent with its cache allocation policies.
716</t>
717</section>
718</section>
719</section>
720
721<section title="IANA Considerations" anchor="IANA.considerations">
722<t>
723   TBD.
724</t>
725</section>
726
727<section title="Security Considerations" anchor="security.considerations">
728<t>
729   No additional security considerations have been identified beyond
730   those applicable to HTTP in general <xref target="Part1"/>.
731</t>
732</section>
733
734<section title="Acknowledgments" anchor="ack">
735<t>
736   Most of the specification of ranges is based on work originally done
737   by Ari Luotonen and John Franks, with additional input from Steve
738   Zilles, Daniel W. Connolly, Roy T. Fielding, Jim Gettys, Martin Hamilton,
739   Koen Holtman, Shel Kaplan, Paul Leach, Alex Lopez-Ortiz, Larry Masinter,
740   Jeff Mogul, Lou Montulli, David W. Morris, Luigi Rizzo, and Bill Weihl.
741</t>
742</section>
743</middle>
744<back>
745
746<references title="Normative References">
747
748<reference anchor="Part1">
749  <front>
750    <title abbrev="HTTP/1.1">HTTP/1.1, part 1: URIs, Connections, and Message Parsing</title>
751    <author initials="R." surname="Fielding" fullname="Roy T. Fielding" role="editor">
752      <organization abbrev="Day Software">Day Software</organization>
753      <address><email>fielding@gbiv.com</email></address>
754    </author>
755    <author initials="J." surname="Gettys" fullname="Jim Gettys">
756      <organization>One Laptop per Child</organization>
757      <address><email>jg@laptop.org</email></address>
758    </author>
759    <author initials="J." surname="Mogul" fullname="Jeffrey C. Mogul">
760      <organization abbrev="HP">Hewlett-Packard Company</organization>
761      <address><email>JeffMogul@acm.org</email></address>
762    </author>
763    <author initials="H." surname="Frystyk" fullname="Henrik Frystyk Nielsen">
764      <organization abbrev="Microsoft">Microsoft Corporation</organization>
765      <address><email>henrikn@microsoft.com</email></address>
766    </author>
767    <author initials="L." surname="Masinter" fullname="Larry Masinter">
768      <organization abbrev="Adobe Systems">Adobe Systems, Incorporated</organization>
769      <address><email>LMM@acm.org</email></address>
770    </author>
771    <author initials="P." surname="Leach" fullname="Paul J. Leach">
772      <organization abbrev="Microsoft">Microsoft Corporation</organization>
773      <address><email>paulle@microsoft.com</email></address>
774    </author>
775    <author initials="T." surname="Berners-Lee" fullname="Tim Berners-Lee">
776      <organization abbrev="W3C/MIT">World Wide Web Consortium</organization>
777      <address><email>timbl@w3.org</email></address>
778    </author>
779    <author initials="Y." surname="Lafon" fullname="Yves Lafon" role="editor">
780      <organization abbrev="W3C">World Wide Web Consortium</organization>
781      <address><email>ylafon@w3.org</email></address>
782    </author>
783    <author initials="J. F." surname="Reschke" fullname="Julian F. Reschke" role="editor">
784      <organization abbrev="greenbytes">greenbytes GmbH</organization>
785      <address><email>julian.reschke@greenbytes.de</email></address>
786    </author>
787    <date month="January" year="2008"/>
788  </front>
789  <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-p1-messaging-01"/>
790 
791</reference>
792
793<reference anchor="Part3">
794  <front>
795    <title abbrev="HTTP/1.1">HTTP/1.1, part 3: Message Payload and Content Negotiation</title>
796    <author initials="R." surname="Fielding" fullname="Roy T. Fielding" role="editor">
797      <organization abbrev="Day Software">Day Software</organization>
798      <address><email>fielding@gbiv.com</email></address>
799    </author>
800    <author initials="J." surname="Gettys" fullname="Jim Gettys">
801      <organization>One Laptop per Child</organization>
802      <address><email>jg@laptop.org</email></address>
803    </author>
804    <author initials="J." surname="Mogul" fullname="Jeffrey C. Mogul">
805      <organization abbrev="HP">Hewlett-Packard Company</organization>
806      <address><email>JeffMogul@acm.org</email></address>
807    </author>
808    <author initials="H." surname="Frystyk" fullname="Henrik Frystyk Nielsen">
809      <organization abbrev="Microsoft">Microsoft Corporation</organization>
810      <address><email>henrikn@microsoft.com</email></address>
811    </author>
812    <author initials="L." surname="Masinter" fullname="Larry Masinter">
813      <organization abbrev="Adobe Systems">Adobe Systems, Incorporated</organization>
814      <address><email>LMM@acm.org</email></address>
815    </author>
816    <author initials="P." surname="Leach" fullname="Paul J. Leach">
817      <organization abbrev="Microsoft">Microsoft Corporation</organization>
818      <address><email>paulle@microsoft.com</email></address>
819    </author>
820    <author initials="T." surname="Berners-Lee" fullname="Tim Berners-Lee">
821      <organization abbrev="W3C/MIT">World Wide Web Consortium</organization>
822      <address><email>timbl@w3.org</email></address>
823    </author>
824    <author initials="Y." surname="Lafon" fullname="Yves Lafon" role="editor">
825      <organization abbrev="W3C">World Wide Web Consortium</organization>
826      <address><email>ylafon@w3.org</email></address>
827    </author>
828    <author initials="J. F." surname="Reschke" fullname="Julian F. Reschke" role="editor">
829      <organization abbrev="greenbytes">greenbytes GmbH</organization>
830      <address><email>julian.reschke@greenbytes.de</email></address>
831    </author>
832    <date month="January" year="2008"/>
833  </front>
834  <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-p3-payload-01"/>
835 
836</reference>
837
838<reference anchor="Part4">
839  <front>
840    <title abbrev="HTTP/1.1">HTTP/1.1, part 4: Conditional Requests</title>
841    <author initials="R." surname="Fielding" fullname="Roy T. Fielding" role="editor">
842      <organization abbrev="Day Software">Day Software</organization>
843      <address><email>fielding@gbiv.com</email></address>
844    </author>
845    <author initials="J." surname="Gettys" fullname="Jim Gettys">
846      <organization>One Laptop per Child</organization>
847      <address><email>jg@laptop.org</email></address>
848    </author>
849    <author initials="J." surname="Mogul" fullname="Jeffrey C. Mogul">
850      <organization abbrev="HP">Hewlett-Packard Company</organization>
851      <address><email>JeffMogul@acm.org</email></address>
852    </author>
853    <author initials="H." surname="Frystyk" fullname="Henrik Frystyk Nielsen">
854      <organization abbrev="Microsoft">Microsoft Corporation</organization>
855      <address><email>henrikn@microsoft.com</email></address>
856    </author>
857    <author initials="L." surname="Masinter" fullname="Larry Masinter">
858      <organization abbrev="Adobe Systems">Adobe Systems, Incorporated</organization>
859      <address><email>LMM@acm.org</email></address>
860    </author>
861    <author initials="P." surname="Leach" fullname="Paul J. Leach">
862      <organization abbrev="Microsoft">Microsoft Corporation</organization>
863      <address><email>paulle@microsoft.com</email></address>
864    </author>
865    <author initials="T." surname="Berners-Lee" fullname="Tim Berners-Lee">
866      <organization abbrev="W3C/MIT">World Wide Web Consortium</organization>
867      <address><email>timbl@w3.org</email></address>
868    </author>
869    <author initials="Y." surname="Lafon" fullname="Yves Lafon" role="editor">
870      <organization abbrev="W3C">World Wide Web Consortium</organization>
871      <address><email>ylafon@w3.org</email></address>
872    </author>
873    <author initials="J. F." surname="Reschke" fullname="Julian F. Reschke" role="editor">
874      <organization abbrev="greenbytes">greenbytes GmbH</organization>
875      <address><email>julian.reschke@greenbytes.de</email></address>
876    </author>
877    <date month="January" year="2008"/>
878  </front>
879  <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-p4-conditional-01"/>
880 
881</reference>
882
883<reference anchor="Part6">
884  <front>
885    <title abbrev="HTTP/1.1">HTTP/1.1, part 6: Caching</title>
886    <author initials="R." surname="Fielding" fullname="Roy T. Fielding" role="editor">
887      <organization abbrev="Day Software">Day Software</organization>
888      <address><email>fielding@gbiv.com</email></address>
889    </author>
890    <author initials="J." surname="Gettys" fullname="Jim Gettys">
891      <organization>One Laptop per Child</organization>
892      <address><email>jg@laptop.org</email></address>
893    </author>
894    <author initials="J." surname="Mogul" fullname="Jeffrey C. Mogul">
895      <organization abbrev="HP">Hewlett-Packard Company</organization>
896      <address><email>JeffMogul@acm.org</email></address>
897    </author>
898    <author initials="H." surname="Frystyk" fullname="Henrik Frystyk Nielsen">
899      <organization abbrev="Microsoft">Microsoft Corporation</organization>
900      <address><email>henrikn@microsoft.com</email></address>
901    </author>
902    <author initials="L." surname="Masinter" fullname="Larry Masinter">
903      <organization abbrev="Adobe Systems">Adobe Systems, Incorporated</organization>
904      <address><email>LMM@acm.org</email></address>
905    </author>
906    <author initials="P." surname="Leach" fullname="Paul J. Leach">
907      <organization abbrev="Microsoft">Microsoft Corporation</organization>
908      <address><email>paulle@microsoft.com</email></address>
909    </author>
910    <author initials="T." surname="Berners-Lee" fullname="Tim Berners-Lee">
911      <organization abbrev="W3C/MIT">World Wide Web Consortium</organization>
912      <address><email>timbl@w3.org</email></address>
913    </author>
914    <author initials="Y." surname="Lafon" fullname="Yves Lafon" role="editor">
915      <organization abbrev="W3C">World Wide Web Consortium</organization>
916      <address><email>ylafon@w3.org</email></address>
917    </author>
918    <author initials="J. F." surname="Reschke" fullname="Julian F. Reschke" role="editor">
919      <organization abbrev="greenbytes">greenbytes GmbH</organization>
920      <address><email>julian.reschke@greenbytes.de</email></address>
921    </author>
922    <date month="January" year="2008"/>
923  </front>
924  <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-p6-cache-01"/>
925 
926</reference>
927
928<reference anchor="RFC2046">
929  <front>
930    <title abbrev="Media Types">Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types</title>
931    <author initials="N." surname="Freed" fullname="Ned Freed">
932      <organization>Innosoft International, Inc.</organization>
933      <address><email>ned@innosoft.com</email></address>
934    </author>
935    <author initials="N." surname="Borenstein" fullname="Nathaniel S. Borenstein">
936      <organization>First Virtual Holdings</organization>
937      <address><email>nsb@nsb.fv.com</email></address>
938    </author>
939    <date month="November" year="1996"/>
940  </front>
941  <seriesInfo name="RFC" value="2046"/>
942</reference>
943
944<reference anchor="RFC2119">
945  <front>
946    <title>Key words for use in RFCs to Indicate Requirement Levels</title>
947    <author initials="S." surname="Bradner" fullname="Scott Bradner">
948      <organization>Harvard University</organization>
949      <address><email>sob@harvard.edu</email></address>
950    </author>
951    <date month="March" year="1997"/>
952  </front>
953  <seriesInfo name="BCP" value="14"/>
954  <seriesInfo name="RFC" value="2119"/>
955</reference>
956
957</references>
958
959<references title="Informative References">
960
961<reference anchor="RFC2616">
962  <front>
963    <title>Hypertext Transfer Protocol -- HTTP/1.1</title>
964    <author initials="R." surname="Fielding" fullname="R. Fielding">
965      <organization>University of California, Irvine</organization>
966      <address><email>fielding@ics.uci.edu</email></address>
967    </author>
968    <author initials="J." surname="Gettys" fullname="J. Gettys">
969      <organization>W3C</organization>
970      <address><email>jg@w3.org</email></address>
971    </author>
972    <author initials="J." surname="Mogul" fullname="J. Mogul">
973      <organization>Compaq Computer Corporation</organization>
974      <address><email>mogul@wrl.dec.com</email></address>
975    </author>
976    <author initials="H." surname="Frystyk" fullname="H. Frystyk">
977      <organization>MIT Laboratory for Computer Science</organization>
978      <address><email>frystyk@w3.org</email></address>
979    </author>
980    <author initials="L." surname="Masinter" fullname="L. Masinter">
981      <organization>Xerox Corporation</organization>
982      <address><email>masinter@parc.xerox.com</email></address>
983    </author>
984    <author initials="P." surname="Leach" fullname="P. Leach">
985      <organization>Microsoft Corporation</organization>
986      <address><email>paulle@microsoft.com</email></address>
987    </author>
988    <author initials="T." surname="Berners-Lee" fullname="T. Berners-Lee">
989      <organization>W3C</organization>
990      <address><email>timbl@w3.org</email></address>
991    </author>
992    <date month="June" year="1999"/>
993  </front>
994  <seriesInfo name="RFC" value="2616"/>
995</reference>
996
997</references>
998
999<section title="Internet Media Type multipart/byteranges" anchor="internet.media.type.multipart.byteranges">
1000<iref item="Media Type" subitem="multipart/byteranges" primary="true"/>
1001<iref item="multipart/byteranges Media Type" primary="true"/>
1002<t>
1003   When an HTTP 206 (Partial Content) response message includes the
1004   content of multiple ranges (a response to a request for multiple
1005   non-overlapping ranges), these are transmitted as a multipart
1006   message-body. The media type for this purpose is called
1007   "multipart/byteranges".
1008</t><t>
1009   The multipart/byteranges media type includes two or more parts, each
1010   with its own Content-Type and Content-Range fields. The required
1011   boundary parameter specifies the boundary string used to separate
1012   each body-part.
1013</t>
1014<t>
1015  <list style="hanging">
1016    <t hangText="Media Type name:">
1017      multipart
1018    </t>
1019    <t hangText="Media subtype name:">
1020      byteranges
1021    </t>
1022    <t hangText="Required parameters:">
1023      boundary
1024    </t>
1025    <t hangText="Optional parameters:">
1026      none
1027    </t>
1028    <t hangText="Encoding considerations:">
1029      only "7bit", "8bit", or "binary" are permitted
1030    </t>
1031    <t hangText="Security considerations:">
1032      none
1033    </t>
1034  </list>
1035</t>
1036<figure><preamble>
1037   For example:
1038</preamble><artwork type="example"><![CDATA[
1039   HTTP/1.1 206 Partial Content
1040   Date: Wed, 15 Nov 1995 06:25:24 GMT
1041   Last-Modified: Wed, 15 Nov 1995 04:58:08 GMT
1042   Content-type: multipart/byteranges; boundary=THIS_STRING_SEPARATES
1043
1044   --THIS_STRING_SEPARATES
1045   Content-type: application/pdf
1046   Content-range: bytes 500-999/8000
1047
1048   ...the first range...
1049   --THIS_STRING_SEPARATES
1050   Content-type: application/pdf
1051   Content-range: bytes 7000-7999/8000
1052
1053   ...the second range
1054   --THIS_STRING_SEPARATES--
1055]]></artwork></figure>
1056<t>
1057      Notes:
1058  <list style="numbers">
1059      <t>Additional CRLFs may precede the first boundary string in the
1060         entity.</t>
1061
1062      <t>Although <xref target="RFC2046"/> permits the boundary string to be
1063         quoted, some existing implementations handle a quoted boundary
1064         string incorrectly.</t>
1065
1066      <t>A number of browsers and servers were coded to an early draft
1067         of the byteranges specification to use a media type of
1068         multipart/x-byteranges<iref item="multipart/x-byteranges Media Type"/><iref item="Media Type" subitem="multipart/x-byteranges"/>, which is almost, but not quite
1069         compatible with the version documented in HTTP/1.1.</t>
1070  </list>
1071</t>
1072</section>
1073
1074<section title="Compatibility with Previous Versions" anchor="compatibility">
1075<section title="Changes from RFC 2068" anchor="changes.from.rfc.2068">
1076<t>
1077   Transfer-coding and message lengths all interact in ways that
1078   required fixing exactly when chunked encoding is used (to allow for
1079   transfer encoding that may not be self delimiting); it was important
1080   to straighten out exactly how message lengths are computed.
1081   (<xref target="header.content-range"/>,
1082   see also <xref target="Part1"/>, <xref target="Part3"/> and <xref target="Part6"/>)
1083</t>
1084<t>
1085   There are situations where a server (especially a proxy) does not
1086   know the full length of a response but is capable of serving a
1087   byterange request. We therefore need a mechanism to allow byteranges
1088   with a content-range not indicating the full length of the message.
1089   (<xref target="header.content-range"/>)
1090</t>
1091<t>
1092   Range request responses would become very verbose if all meta-data
1093   were always returned; by allowing the server to only send needed
1094   headers in a 206 response, this problem can be avoided.
1095   (Section <xref target="status.206" format="counter"/>
1096   and <xref target="header.if-range" format="counter"/>)
1097</t>
1098<t>
1099   Fix problem with unsatisfiable range requests; there are two cases:
1100   syntactic problems, and range doesn't exist in the document. The 416
1101   status code was needed to resolve this ambiguity needed to indicate
1102   an error for a byte range request that falls outside of the actual
1103   contents of a document. (Section <xref target="status.416" format="counter"/>, <xref target="header.content-range" format="counter"/>)
1104</t>
1105</section>
1106
1107<section title="Changes from RFC 2616" anchor="changes.from.rfc.2616">
1108<t>
1109  Clarify that it is not ok to use a weak cache validator in a 206 response.
1110  (<xref target="status.206"/>)
1111</t>
1112</section>
1113
1114</section>
1115
1116<section title="Change Log (to be removed by RFC Editor before publication)">
1117
1118<section title="Since RFC2616">
1119<t>
1120  Extracted relevant partitions from <xref target="RFC2616"/>.
1121</t>
1122</section>
1123
1124<section title="Since draft-ietf-httpbis-p5-range-00">
1125<t>
1126  Closed issues:
1127  <list style="symbols"> 
1128    <t>
1129      <eref target="http://www3.tools.ietf.org/wg/httpbis/trac/ticket/18"/>:
1130      "Cache validators in 206 responses"
1131      (<eref target="http://purl.org/NET/http-errata#ifrange206"/>)
1132    </t>
1133    <t>
1134      <eref target="http://www3.tools.ietf.org/wg/httpbis/trac/ticket/35"/>:
1135      "Normative and Informative references"
1136    </t>
1137    <t>
1138      <eref target="http://www3.tools.ietf.org/wg/httpbis/trac/ticket/86"/>:
1139      "Normative up-to-date references"
1140    </t>
1141  </list>
1142</t>
1143</section>
1144
1145</section>
1146
1147</back>
1148</rfc>
Note: See TracBrowser for help on using the repository browser.