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

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

move the p1 top-level sections "206 Partial Content" and
"416 Requested Range Not Satisfiable" into a common section
"Status Code Definitions".

Also add that top-level section to p7, and move 401 and 407 there.

Submitted by: Julian Reschke

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