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

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

update address for TimBL

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