source: draft-ietf-httpbis/06/draft-ietf-httpbis-p5-range-06.txt @ 558

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

Draft 06 (as recorded by www.ietf.org)

  • Property svn:eol-style set to native
File size: 45.1 KB
Line 
1
2
3
4HTTPbis Working Group                                   R. Fielding, Ed.
5Internet-Draft                                              Day Software
6Obsoletes: 2616 (if approved)                                  J. Gettys
7Intended status: Standards Track                    One Laptop per Child
8Expires: September 10, 2009                                     J. Mogul
9                                                                      HP
10                                                              H. Frystyk
11                                                               Microsoft
12                                                             L. Masinter
13                                                           Adobe Systems
14                                                                P. Leach
15                                                               Microsoft
16                                                          T. Berners-Lee
17                                                                 W3C/MIT
18                                                           Y. Lafon, Ed.
19                                                                     W3C
20                                                         J. Reschke, Ed.
21                                                              greenbytes
22                                                           March 9, 2009
23
24
25         HTTP/1.1, part 5: Range Requests and Partial Responses
26                     draft-ietf-httpbis-p5-range-06
27
28Status of this Memo
29
30   This Internet-Draft is submitted to IETF in full conformance with the
31   provisions of BCP 78 and BCP 79.  This document may contain material
32   from IETF Documents or IETF Contributions published or made publicly
33   available before November 10, 2008.  The person(s) controlling the
34   copyright in some of this material may not have granted the IETF
35   Trust the right to allow modifications of such material outside the
36   IETF Standards Process.  Without obtaining an adequate license from
37   the person(s) controlling the copyright in such materials, this
38   document may not be modified outside the IETF Standards Process, and
39   derivative works of it may not be created outside the IETF Standards
40   Process, except to format it for publication as an RFC or to
41   translate it into languages other than English.
42
43   Internet-Drafts are working documents of the Internet Engineering
44   Task Force (IETF), its areas, and its working groups.  Note that
45   other groups may also distribute working documents as Internet-
46   Drafts.
47
48   Internet-Drafts are draft documents valid for a maximum of six months
49   and may be updated, replaced, or obsoleted by other documents at any
50   time.  It is inappropriate to use Internet-Drafts as reference
51   material or to cite them other than as "work in progress."
52
53
54
55Fielding, et al.       Expires September 10, 2009               [Page 1]
56
57Internet-Draft              HTTP/1.1, Part 5                  March 2009
58
59
60   The list of current Internet-Drafts can be accessed at
61   http://www.ietf.org/ietf/1id-abstracts.txt.
62
63   The list of Internet-Draft Shadow Directories can be accessed at
64   http://www.ietf.org/shadow.html.
65
66   This Internet-Draft will expire on September 10, 2009.
67
68Copyright Notice
69
70   Copyright (c) 2009 IETF Trust and the persons identified as the
71   document authors.  All rights reserved.
72
73   This document is subject to BCP 78 and the IETF Trust's Legal
74   Provisions Relating to IETF Documents in effect on the date of
75   publication of this document (http://trustee.ietf.org/license-info).
76   Please review these documents carefully, as they describe your rights
77   and restrictions with respect to this document.
78
79Abstract
80
81   The Hypertext Transfer Protocol (HTTP) is an application-level
82   protocol for distributed, collaborative, hypermedia information
83   systems.  HTTP has been in use by the World Wide Web global
84   information initiative since 1990.  This document is Part 5 of the
85   seven-part specification that defines the protocol referred to as
86   "HTTP/1.1" and, taken together, obsoletes RFC 2616.  Part 5 defines
87   range-specific requests and the rules for constructing and combining
88   responses to those requests.
89
90Editorial Note (To be removed by RFC Editor)
91
92   Discussion of this draft should take place on the HTTPBIS working
93   group mailing list (ietf-http-wg@w3.org).  The current issues list is
94   at <http://tools.ietf.org/wg/httpbis/trac/report/11> and related
95   documents (including fancy diffs) can be found at
96   <http://tools.ietf.org/wg/httpbis/>.
97
98   The changes in this draft are summarized in Appendix D.7.
99
100
101
102
103
104
105
106
107
108
109
110
111Fielding, et al.       Expires September 10, 2009               [Page 2]
112
113Internet-Draft              HTTP/1.1, Part 5                  March 2009
114
115
116Table of Contents
117
118   1.  Introduction . . . . . . . . . . . . . . . . . . . . . . . . .  4
119     1.1.  Requirements . . . . . . . . . . . . . . . . . . . . . . .  4
120     1.2.  Syntax Notation  . . . . . . . . . . . . . . . . . . . . .  4
121       1.2.1.  Core Rules . . . . . . . . . . . . . . . . . . . . . .  5
122       1.2.2.  ABNF Rules defined in other Parts of the
123               Specification  . . . . . . . . . . . . . . . . . . . .  5
124   2.  Range Units  . . . . . . . . . . . . . . . . . . . . . . . . .  5
125   3.  Status Code Definitions  . . . . . . . . . . . . . . . . . . .  5
126     3.1.  206 Partial Content  . . . . . . . . . . . . . . . . . . .  6
127     3.2.  416 Requested Range Not Satisfiable  . . . . . . . . . . .  6
128   4.  Combining Ranges . . . . . . . . . . . . . . . . . . . . . . .  7
129   5.  Header Field Definitions . . . . . . . . . . . . . . . . . . .  7
130     5.1.  Accept-Ranges  . . . . . . . . . . . . . . . . . . . . . .  7
131     5.2.  Content-Range  . . . . . . . . . . . . . . . . . . . . . .  8
132     5.3.  If-Range . . . . . . . . . . . . . . . . . . . . . . . . . 10
133     5.4.  Range  . . . . . . . . . . . . . . . . . . . . . . . . . . 11
134       5.4.1.  Byte Ranges  . . . . . . . . . . . . . . . . . . . . . 11
135       5.4.2.  Range Retrieval Requests . . . . . . . . . . . . . . . 13
136   6.  IANA Considerations  . . . . . . . . . . . . . . . . . . . . . 13
137     6.1.  Message Header Registration  . . . . . . . . . . . . . . . 14
138   7.  Security Considerations  . . . . . . . . . . . . . . . . . . . 14
139   8.  Acknowledgments  . . . . . . . . . . . . . . . . . . . . . . . 14
140   9.  References . . . . . . . . . . . . . . . . . . . . . . . . . . 14
141     9.1.  Normative References . . . . . . . . . . . . . . . . . . . 14
142     9.2.  Informative References . . . . . . . . . . . . . . . . . . 15
143   Appendix A.  Internet Media Type multipart/byteranges  . . . . . . 15
144   Appendix B.  Compatibility with Previous Versions  . . . . . . . . 17
145     B.1.  Changes from RFC 2068  . . . . . . . . . . . . . . . . . . 17
146     B.2.  Changes from RFC 2616  . . . . . . . . . . . . . . . . . . 18
147   Appendix C.  Collected ABNF  . . . . . . . . . . . . . . . . . . . 18
148   Appendix D.  Change Log (to be removed by RFC Editor before
149                publication)  . . . . . . . . . . . . . . . . . . . . 19
150     D.1.  Since RFC2616  . . . . . . . . . . . . . . . . . . . . . . 19
151     D.2.  Since draft-ietf-httpbis-p5-range-00 . . . . . . . . . . . 20
152     D.3.  Since draft-ietf-httpbis-p5-range-01 . . . . . . . . . . . 20
153     D.4.  Since draft-ietf-httpbis-p5-range-02 . . . . . . . . . . . 20
154     D.5.  Since draft-ietf-httpbis-p5-range-03 . . . . . . . . . . . 20
155     D.6.  Since draft-ietf-httpbis-p5-range-04 . . . . . . . . . . . 20
156     D.7.  Since draft-ietf-httpbis-p5-range-05 . . . . . . . . . . . 21
157   Index  . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
158   Authors' Addresses . . . . . . . . . . . . . . . . . . . . . . . . 22
159
160
161
162
163
164
165
166
167Fielding, et al.       Expires September 10, 2009               [Page 3]
168
169Internet-Draft              HTTP/1.1, Part 5                  March 2009
170
171
1721.  Introduction
173
174   HTTP clients often encounter interrupted data transfers as a result
175   of cancelled requests or dropped connections.  When a cache has
176   stored a partial representation, it is desirable to request the
177   remainder of that representation in a subsequent request rather than
178   transfer the entire representation.  There are also a number of Web
179   applications that benefit from being able to request only a subset of
180   a larger representation, such as a single page of a very large
181   document or only part of an image to be rendered by a device with
182   limited local storage.
183
184   This document defines HTTP/1.1 range requests, partial responses, and
185   the multipart/byteranges media type.  The protocol for range requests
186   is an OPTIONAL feature of HTTP, designed so resources or recipients
187   that do not implement this feature can respond as if it is a normal
188   GET request without impacting interoperability.  Partial responses
189   are indicated by a distinct status code to not be mistaken for full
190   responses by intermediate caches that might not implement the
191   feature.
192
193   Although the HTTP range request mechanism is designed to allow for
194   extensible range types, this specification only defines requests for
195   byte ranges.
196
1971.1.  Requirements
198
199   The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
200   "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
201   document are to be interpreted as described in [RFC2119].
202
203   An implementation is not compliant if it fails to satisfy one or more
204   of the MUST or REQUIRED level requirements for the protocols it
205   implements.  An implementation that satisfies all the MUST or
206   REQUIRED level and all the SHOULD level requirements for its
207   protocols is said to be "unconditionally compliant"; one that
208   satisfies all the MUST level requirements but not all the SHOULD
209   level requirements for its protocols is said to be "conditionally
210   compliant."
211
2121.2.  Syntax Notation
213
214   This specification uses the ABNF syntax defined in Section 1.2 of
215   [Part1] (which extends the syntax defined in [RFC5234] with a list
216   rule).  Appendix C shows the collected ABNF, with the list rule
217   expanded.
218
219   The following core rules are included by reference, as defined in
220
221
222
223Fielding, et al.       Expires September 10, 2009               [Page 4]
224
225Internet-Draft              HTTP/1.1, Part 5                  March 2009
226
227
228   [RFC5234], Appendix B.1: ALPHA (letters), CR (carriage return), CRLF
229   (CR LF), CTL (controls), DIGIT (decimal 0-9), DQUOTE (double quote),
230   HEXDIG (hexadecimal 0-9/A-F/a-f), LF (line feed), OCTET (any 8-bit
231   sequence of data), SP (space), VCHAR (any visible USASCII character),
232   and WSP (whitespace).
233
2341.2.1.  Core Rules
235
236   The core rules below are defined in Section 1.2.2 of [Part1]:
237
238     token      = <token, defined in [Part1], Section 1.2.2>
239     OWS        = <OWS, defined in [Part1], Section 1.2.2>
240
2411.2.2.  ABNF Rules defined in other Parts of the Specification
242
243   The ABNF rules below are defined in other parts:
244
245     HTTP-date  = <HTTP-date, defined in [Part1], Section 3.2.1>
246
247
248     entity-tag = <entity-tag, defined in [Part4], Section 2>
249
250
2512.  Range Units
252
253   HTTP/1.1 allows a client to request that only part (a range of) the
254   response entity be included within the response.  HTTP/1.1 uses range
255   units in the Range (Section 5.4) and Content-Range (Section 5.2)
256   header fields.  An entity can be broken down into subranges according
257   to various structural units.
258
259     range-unit       = bytes-unit / other-range-unit
260     bytes-unit       = "bytes"
261     other-range-unit = token
262
263   HTTP/1.1 has been designed to allow implementations of applications
264   that do not depend on knowledge of ranges.  The only range unit
265   defined by HTTP/1.1 is "bytes".
266
267   If a range unit is not understood in a request, a server MUST ignore
268   the whole Range header (Section 5.4).  If a range unit is not
269   understood in a response, an intermediary SHOULD pass the response to
270   the client; a client MUST fail.
271
272
2733.  Status Code Definitions
274
275
276
277
278
279Fielding, et al.       Expires September 10, 2009               [Page 5]
280
281Internet-Draft              HTTP/1.1, Part 5                  March 2009
282
283
2843.1.  206 Partial Content
285
286   The server has fulfilled the partial GET request for the resource.
287   The request MUST have included a Range header field (Section 5.4)
288   indicating the desired range, and MAY have included an If-Range
289   header field (Section 5.3) to make the request conditional.
290
291   The response MUST include the following header fields:
292
293   o  Either a Content-Range header field (Section 5.2) indicating the
294      range included with this response, or a multipart/byteranges
295      Content-Type including Content-Range fields for each part.  If a
296      Content-Length header field is present in the response, its value
297      MUST match the actual number of OCTETs transmitted in the message-
298      body.
299
300   o  Date
301
302   o  ETag and/or Content-Location, if the header would have been sent
303      in a 200 response to the same request
304
305   o  Expires, Cache-Control, and/or Vary, if the field-value might
306      differ from that sent in any previous response for the same
307      variant
308
309   If the 206 response is the result of an If-Range request, the
310   response SHOULD NOT include other entity-headers.  Otherwise, the
311   response MUST include all of the entity-headers that would have been
312   returned with a 200 (OK) response to the same request.
313
314   A cache MUST NOT combine a 206 response with other previously cached
315   content if the ETag or Last-Modified headers do not match exactly,
316   see Section 4.
317
318   A cache that does not support the Range and Content-Range headers
319   MUST NOT cache 206 (Partial Content) responses.  Furthermore, if a
320   response uses a range unit that is not understood by the cache, then
321   it MUST NOT be cached either.
322
3233.2.  416 Requested Range Not Satisfiable
324
325   A server SHOULD return a response with this status code if a request
326   included a Range request-header field (Section 5.4), and none of the
327   ranges-specifier values in this field overlap the current extent of
328   the selected resource, and the request did not include an If-Range
329   request-header field.  (For byte-ranges, this means that the first-
330   byte-pos of all of the byte-range-spec values were greater than the
331   current length of the selected resource.)
332
333
334
335Fielding, et al.       Expires September 10, 2009               [Page 6]
336
337Internet-Draft              HTTP/1.1, Part 5                  March 2009
338
339
340   When this status code is returned for a byte-range request, the
341   response SHOULD include a Content-Range entity-header field
342   specifying the current length of the selected resource (see
343   Section 5.2).  This response MUST NOT use the multipart/byteranges
344   content-type.
345
346
3474.  Combining Ranges
348
349   A response might transfer only a subrange of an entity-body, either
350   the request included one or more Range specifications, or because a
351   connection was broken prematurely.  After several such transfers, a
352   cache might have received several ranges of the same entity-body.
353
354   If a cache has a stored non-empty set of subranges for an entity, and
355   an incoming response transfers another subrange, the cache MAY
356   combine the new subrange with the existing set if both the following
357   conditions are met:
358
359   o  Both the incoming response and the cache entry have a cache
360      validator.
361
362   o  The two cache validators match using the strong comparison
363      function (see Section 4 of [Part4]).
364
365   If either requirement is not met, the cache MUST use only the most
366   recent partial response (based on the Date values transmitted with
367   every response, and using the incoming response if these values are
368   equal or missing), and MUST discard the other partial information.
369
370
3715.  Header Field Definitions
372
373   This section defines the syntax and semantics of HTTP/1.1 header
374   fields related to range requests and partial responses.
375
376   For entity-header fields, both sender and recipient refer to either
377   the client or the server, depending on who sends and who receives the
378   entity.
379
3805.1.  Accept-Ranges
381
382   The response-header "Accept-Ranges" field allows the server to
383   indicate its acceptance of range requests for a resource:
384
385     Accept-Ranges     = "Accept-Ranges" ":" OWS Accept-Ranges-v
386     Accept-Ranges-v   = acceptable-ranges
387     acceptable-ranges = 1#range-unit / "none"
388
389
390
391Fielding, et al.       Expires September 10, 2009               [Page 7]
392
393Internet-Draft              HTTP/1.1, Part 5                  March 2009
394
395
396   Origin servers that accept byte-range requests MAY send
397
398     Accept-Ranges: bytes
399
400   but are not required to do so.  Clients MAY generate range requests
401   without having received this header for the resource involved.  Range
402   units are defined in Section 2.
403
404   Servers that do not accept any kind of range request for a resource
405   MAY send
406
407     Accept-Ranges: none
408
409   to advise the client not to attempt a range request.
410
4115.2.  Content-Range
412
413   The entity-header "Content-Range" is sent with a partial entity-body
414   to specify where in the full entity-body the partial body should be
415   applied.  Range units are defined in Section 2.
416
417     Content-Range = "Content-Range" ":" OWS Content-Range-v
418     Content-Range-v = content-range-spec
419
420     content-range-spec      = byte-content-range-spec
421                             / other-content-range-spec
422     byte-content-range-spec = bytes-unit SP
423                               byte-range-resp-spec "/"
424                               ( instance-length / "*" )
425
426     byte-range-resp-spec    = (first-byte-pos "-" last-byte-pos)
427                             / "*"
428
429     instance-length         = 1*DIGIT
430
431     other-content-range-spec = other-range-unit SP
432                                other-range-resp-spec
433     other-range-resp-spec    = *CHAR
434
435   The header SHOULD indicate the total length of the full entity-body,
436   unless this length is unknown or difficult to determine.  The
437   asterisk "*" character means that the instance-length is unknown at
438   the time when the response was generated.
439
440   Unlike byte-ranges-specifier values (see Section 5.4.1), a byte-
441   range-resp-spec MUST only specify one range, and MUST contain
442   absolute byte positions for both the first and last byte of the
443   range.
444
445
446
447Fielding, et al.       Expires September 10, 2009               [Page 8]
448
449Internet-Draft              HTTP/1.1, Part 5                  March 2009
450
451
452   A byte-content-range-spec with a byte-range-resp-spec whose last-
453   byte-pos value is less than its first-byte-pos value, or whose
454   instance-length value is less than or equal to its last-byte-pos
455   value, is invalid.  The recipient of an invalid byte-content-range-
456   spec MUST ignore it and any content transferred along with it.
457
458   In the case of a byte range request: A server sending a response with
459   status code 416 (Requested range not satisfiable) SHOULD include a
460   Content-Range field with a byte-range-resp-spec of "*".  The
461   instance-length specifies the current length of the selected resource
462   as a decimal number.  A response with status code 206 (Partial
463   Content) MUST NOT include a Content-Range field with a byte-range-
464   resp-spec of "*".
465
466   Examples of byte-content-range-spec values, assuming that the entity
467   contains a total of 1234 bytes:
468
469   o  The first 500 bytes:
470
471      bytes 0-499/1234
472
473   o  The second 500 bytes:
474
475      bytes 500-999/1234
476
477   o  All except for the first 500 bytes:
478
479      bytes 500-1233/1234
480
481   o  The last 500 bytes:
482
483      bytes 734-1233/1234
484
485   When an HTTP message includes the content of a single range (for
486   example, a response to a request for a single range, or to a request
487   for a set of ranges that overlap without any holes), this content is
488   transmitted with a Content-Range header, and a Content-Length header
489   showing the number of bytes actually transferred.  For example,
490
491     HTTP/1.1 206 Partial Content
492     Date: Wed, 15 Nov 1995 06:25:24 GMT
493     Last-Modified: Wed, 15 Nov 1995 04:58:08 GMT
494     Content-Range: bytes 21010-47021/47022
495     Content-Length: 26012
496     Content-Type: image/gif
497
498   When an HTTP message includes the content of multiple ranges (for
499   example, a response to a request for multiple non-overlapping
500
501
502
503Fielding, et al.       Expires September 10, 2009               [Page 9]
504
505Internet-Draft              HTTP/1.1, Part 5                  March 2009
506
507
508   ranges), these are transmitted as a multipart message.  The multipart
509   media type used for this purpose is "multipart/byteranges" as defined
510   in Appendix A.  See Appendix B.1 for a compatibility issue.
511
512   A response to a request for a single range MUST NOT be sent using the
513   multipart/byteranges media type.  A response to a request for
514   multiple ranges, whose result is a single range, MAY be sent as a
515   multipart/byteranges media type with one part.  A client that cannot
516   decode a multipart/byteranges message MUST NOT ask for multiple
517   ranges in a single request.
518
519   When a client requests multiple byte-ranges in one request, the
520   server SHOULD return them in the order that they appeared in the
521   request.
522
523   If the server ignores a byte-range-spec because it is syntactically
524   invalid, the server SHOULD treat the request as if the invalid Range
525   header field did not exist.  (Normally, this means return a 200
526   response containing the full entity).
527
528   If the server receives a request (other than one including an If-
529   Range request-header field) with an unsatisfiable Range request-
530   header field (that is, all of whose byte-range-spec values have a
531   first-byte-pos value greater than the current length of the selected
532   resource), it SHOULD return a response code of 416 (Requested range
533   not satisfiable) (Section 3.2).
534
535      Note: clients cannot depend on servers to send a 416 (Requested
536      range not satisfiable) response instead of a 200 (OK) response for
537      an unsatisfiable Range request-header, since not all servers
538      implement this request-header.
539
5405.3.  If-Range
541
542   If a client has a partial copy of an entity in its cache, and wishes
543   to have an up-to-date copy of the entire entity in its cache, it
544   could use the Range request-header with a conditional GET (using
545   either or both of If-Unmodified-Since and If-Match.)  However, if the
546   condition fails because the entity has been modified, the client
547   would then have to make a second request to obtain the entire current
548   entity-body.
549
550   The request header "If-Range" allows a client to "short-circuit" the
551   second request.  Informally, its meaning is `if the entity is
552   unchanged, send me the part(s) that I am missing; otherwise, send me
553   the entire new entity'.
554
555     If-Range   = "If-Range" ":" OWS If-Range-v
556
557
558
559Fielding, et al.       Expires September 10, 2009              [Page 10]
560
561Internet-Draft              HTTP/1.1, Part 5                  March 2009
562
563
564     If-Range-v = entity-tag / HTTP-date
565
566   If the client has no entity tag for an entity, but does have a Last-
567   Modified date, it MAY use that date in an If-Range header.  (The
568   server can distinguish between a valid HTTP-date and any form of
569   entity-tag by examining no more than two characters.)  The If-Range
570   header SHOULD only be used together with a Range header, and MUST be
571   ignored if the request does not include a Range header, or if the
572   server does not support the sub-range operation.
573
574   If the entity tag given in the If-Range header matches the current
575   entity tag for the entity, then the server SHOULD provide the
576   specified sub-range of the entity using a 206 (Partial Content)
577   response.  If the entity tag does not match, then the server SHOULD
578   return the entire entity using a 200 (OK) response.
579
5805.4.  Range
581
5825.4.1.  Byte Ranges
583
584   Since all HTTP entities are represented in HTTP messages as sequences
585   of bytes, the concept of a byte range is meaningful for any HTTP
586   entity.  (However, not all clients and servers need to support byte-
587   range operations.)
588
589   Byte range specifications in HTTP apply to the sequence of bytes in
590   the entity-body (not necessarily the same as the message-body).
591
592   A byte range operation MAY specify a single range of bytes, or a set
593   of ranges within a single entity.
594
595     byte-ranges-specifier = bytes-unit "=" byte-range-set
596     byte-range-set  = 1#( byte-range-spec / suffix-byte-range-spec )
597     byte-range-spec = first-byte-pos "-" [ last-byte-pos ]
598     first-byte-pos  = 1*DIGIT
599     last-byte-pos   = 1*DIGIT
600
601   The first-byte-pos value in a byte-range-spec gives the byte-offset
602   of the first byte in a range.  The last-byte-pos value gives the
603   byte-offset of the last byte in the range; that is, the byte
604   positions specified are inclusive.  Byte offsets are decimal and
605   start at zero.
606
607   If the last-byte-pos value is present, it MUST be greater than or
608   equal to the first-byte-pos in that byte-range-spec, or the byte-
609   range-spec is syntactically invalid.  The recipient of a byte-range-
610   set that includes one or more syntactically invalid byte-range-spec
611   values MUST ignore the header field that includes that byte-range-
612
613
614
615Fielding, et al.       Expires September 10, 2009              [Page 11]
616
617Internet-Draft              HTTP/1.1, Part 5                  March 2009
618
619
620   set.
621
622   If the last-byte-pos value is absent, or if the value is greater than
623   or equal to the current length of the entity-body, last-byte-pos is
624   taken to be equal to one less than the current length of the entity-
625   body in bytes.
626
627   By its choice of last-byte-pos, a client can limit the number of
628   bytes retrieved without knowing the size of the entity.
629
630     suffix-byte-range-spec = "-" suffix-length
631     suffix-length = 1*DIGIT
632
633   A suffix-byte-range-spec is used to specify the suffix of the entity-
634   body, of a length given by the decimal suffix-length value.  (That
635   is, this form specifies the last N bytes of an entity-body.)  If the
636   entity is shorter than the specified suffix-length, the entire
637   entity-body is used.
638
639   If a syntactically valid byte-range-set includes at least one byte-
640   range-spec whose first-byte-pos is less than the current length of
641   the entity-body, or at least one suffix-byte-range-spec with a non-
642   zero suffix-length, then the byte-range-set is satisfiable.
643   Otherwise, the byte-range-set is unsatisfiable.  If the byte-range-
644   set is unsatisfiable, the server SHOULD return a response with a
645   status of 416 (Requested range not satisfiable).  Otherwise, the
646   server SHOULD return a response with a status of 206 (Partial
647   Content) containing the satisfiable ranges of the entity-body.
648
649   Examples of byte-ranges-specifier values (assuming an entity-body of
650   length 10000):
651
652   o  The first 500 bytes (byte offsets 0-499, inclusive): bytes=0-499
653
654   o  The second 500 bytes (byte offsets 500-999, inclusive): bytes=500-
655      999
656
657   o  The final 500 bytes (byte offsets 9500-9999, inclusive): bytes=-
658      500
659
660   o  Or bytes=9500-
661
662   o  The first and last bytes only (bytes 0 and 9999): bytes=0-0,-1
663
664   o  Several legal but not canonical specifications of the second 500
665      bytes (byte offsets 500-999, inclusive):
666      bytes=500-600,601-999
667      bytes=500-700,601-999
668
669
670
671Fielding, et al.       Expires September 10, 2009              [Page 12]
672
673Internet-Draft              HTTP/1.1, Part 5                  March 2009
674
675
6765.4.2.  Range Retrieval Requests
677
678   HTTP retrieval requests using conditional or unconditional GET
679   methods MAY request one or more sub-ranges of the entity, instead of
680   the entire entity, using the Range request header, which applies to
681   the entity returned as the result of the request:
682
683     Range   = "Range" ":" OWS Range-v
684     Range-v = byte-ranges-specifier
685             / other-ranges-specifier
686     other-ranges-specifier = 1*CHAR
687
688   A server MAY ignore the Range header.  However, HTTP/1.1 origin
689   servers and intermediate caches ought to support byte ranges when
690   possible, since Range supports efficient recovery from partially
691   failed transfers, and supports efficient partial retrieval of large
692   entities.
693
694   If the server supports the Range header and the specified range or
695   ranges are appropriate for the entity:
696
697   o  The presence of a Range header in an unconditional GET modifies
698      what is returned if the GET is otherwise successful.  In other
699      words, the response carries a status code of 206 (Partial Content)
700      instead of 200 (OK).
701
702   o  The presence of a Range header in a conditional GET (a request
703      using one or both of If-Modified-Since and If-None-Match, or one
704      or both of If-Unmodified-Since and If-Match) modifies what is
705      returned if the GET is otherwise successful and the condition is
706      true.  It does not affect the 304 (Not Modified) response returned
707      if the conditional is false.
708
709   In some cases, it might be more appropriate to use the If-Range
710   header (see Section 5.3) in addition to the Range header.
711
712   If a proxy that supports ranges receives a Range request, forwards
713   the request to an inbound server, and receives an entire entity in
714   reply, it SHOULD only return the requested range to its client.  It
715   SHOULD store the entire received response in its cache if that is
716   consistent with its cache allocation policies.
717
718
7196.  IANA Considerations
720
721
722
723
724
725
726
727Fielding, et al.       Expires September 10, 2009              [Page 13]
728
729Internet-Draft              HTTP/1.1, Part 5                  March 2009
730
731
7326.1.  Message Header Registration
733
734   The Message Header Registry located at <http://www.iana.org/
735   assignments/message-headers/message-header-index.html> should be
736   updated with the permanent registrations below (see [RFC3864]):
737
738   +-------------------+----------+----------+-------------+
739   | Header Field Name | Protocol | Status   | Reference   |
740   +-------------------+----------+----------+-------------+
741   | Accept-Ranges     | http     | standard | Section 5.1 |
742   | Content-Range     | http     | standard | Section 5.2 |
743   | If-Range          | http     | standard | Section 5.3 |
744   | Range             | http     | standard | Section 5.4 |
745   +-------------------+----------+----------+-------------+
746
747   The change controller is: "IETF (iesg@ietf.org) - Internet
748   Engineering Task Force".
749
750
7517.  Security Considerations
752
753   No additional security considerations have been identified beyond
754   those applicable to HTTP in general [Part1].
755
756
7578.  Acknowledgments
758
759   Most of the specification of ranges is based on work originally done
760   by Ari Luotonen and John Franks, with additional input from Steve
761   Zilles, Daniel W. Connolly, Roy T. Fielding, Jim Gettys, Martin
762   Hamilton, Koen Holtman, Shel Kaplan, Paul Leach, Alex Lopez-Ortiz,
763   Larry Masinter, Jeff Mogul, Lou Montulli, David W. Morris, Luigi
764   Rizzo, and Bill Weihl.
765
766
7679.  References
768
7699.1.  Normative References
770
771   [Part1]    Fielding, R., Ed., Gettys, J., Mogul, J., Frystyk, H.,
772              Masinter, L., Leach, P., Berners-Lee, T., Lafon, Y., Ed.,
773              and J. Reschke, Ed., "HTTP/1.1, part 1: URIs, Connections,
774              and Message Parsing", draft-ietf-httpbis-p1-messaging-06
775              (work in progress), March 2009.
776
777   [Part3]    Fielding, R., Ed., Gettys, J., Mogul, J., Frystyk, H.,
778              Masinter, L., Leach, P., Berners-Lee, T., Lafon, Y., Ed.,
779              and J. Reschke, Ed., "HTTP/1.1, part 3: Message Payload
780
781
782
783Fielding, et al.       Expires September 10, 2009              [Page 14]
784
785Internet-Draft              HTTP/1.1, Part 5                  March 2009
786
787
788              and Content Negotiation", draft-ietf-httpbis-p3-payload-06
789              (work in progress), March 2009.
790
791   [Part4]    Fielding, R., Ed., Gettys, J., Mogul, J., Frystyk, H.,
792              Masinter, L., Leach, P., Berners-Lee, T., Lafon, Y., Ed.,
793              and J. Reschke, Ed., "HTTP/1.1, part 4: Conditional
794              Requests", draft-ietf-httpbis-p4-conditional-06 (work in
795              progress), March 2009.
796
797   [Part6]    Fielding, R., Ed., Gettys, J., Mogul, J., Frystyk, H.,
798              Masinter, L., Leach, P., Berners-Lee, T., Lafon, Y., Ed.,
799              and J. Reschke, Ed., "HTTP/1.1, part 6: Caching",
800              draft-ietf-httpbis-p6-cache-06 (work in progress),
801              March 2009.
802
803   [RFC2046]  Freed, N. and N. Borenstein, "Multipurpose Internet Mail
804              Extensions (MIME) Part Two: Media Types", RFC 2046,
805              November 1996.
806
807   [RFC2119]  Bradner, S., "Key words for use in RFCs to Indicate
808              Requirement Levels", BCP 14, RFC 2119, March 1997.
809
810   [RFC5234]  Crocker, D., Ed. and P. Overell, "Augmented BNF for Syntax
811              Specifications: ABNF", STD 68, RFC 5234, January 2008.
812
8139.2.  Informative References
814
815   [RFC2616]  Fielding, R., Gettys, J., Mogul, J., Frystyk, H.,
816              Masinter, L., Leach, P., and T. Berners-Lee, "Hypertext
817              Transfer Protocol -- HTTP/1.1", RFC 2616, June 1999.
818
819   [RFC3864]  Klyne, G., Nottingham, M., and J. Mogul, "Registration
820              Procedures for Message Header Fields", BCP 90, RFC 3864,
821              September 2004.
822
823   [RFC4288]  Freed, N. and J. Klensin, "Media Type Specifications and
824              Registration Procedures", BCP 13, RFC 4288, December 2005.
825
826
827Appendix A.  Internet Media Type multipart/byteranges
828
829   When an HTTP 206 (Partial Content) response message includes the
830   content of multiple ranges (a response to a request for multiple non-
831   overlapping ranges), these are transmitted as a multipart message-
832   body ([RFC2046], Section 5.1).  The media type for this purpose is
833   called "multipart/byteranges".  The following is to be registered
834   with IANA [RFC4288].
835
836
837
838
839Fielding, et al.       Expires September 10, 2009              [Page 15]
840
841Internet-Draft              HTTP/1.1, Part 5                  March 2009
842
843
844   The multipart/byteranges media type includes one or more parts, each
845   with its own Content-Type and Content-Range fields.  The required
846   boundary parameter specifies the boundary string used to separate
847   each body-part.
848
849   Type name:  multipart
850
851   Subtype name:  byteranges
852
853   Required parameters:  boundary
854
855   Optional parameters:  none
856
857   Encoding considerations:  only "7bit", "8bit", or "binary" are
858      permitted
859
860   Security considerations:  none
861
862   Interoperability considerations:  none
863
864   Published specification:  This specification (see Appendix A).
865
866   Applications that use this media type:
867
868   Additional information:
869
870      Magic number(s):  none
871
872      File extension(s):  none
873
874      Macintosh file type code(s):  none
875
876   Person and email address to contact for further information:  See
877      Authors Section.
878
879   Intended usage:  COMMON
880
881   Restrictions on usage:  none
882
883   Author/Change controller:  IESG
884
885
886
887
888
889
890
891
892
893
894
895Fielding, et al.       Expires September 10, 2009              [Page 16]
896
897Internet-Draft              HTTP/1.1, Part 5                  March 2009
898
899
900   For example:
901
902     HTTP/1.1 206 Partial Content
903     Date: Wed, 15 Nov 1995 06:25:24 GMT
904     Last-Modified: Wed, 15 Nov 1995 04:58:08 GMT
905     Content-type: multipart/byteranges; boundary=THIS_STRING_SEPARATES
906
907     --THIS_STRING_SEPARATES
908     Content-type: application/pdf
909     Content-range: bytes 500-999/8000
910
911     ...the first range...
912     --THIS_STRING_SEPARATES
913     Content-type: application/pdf
914     Content-range: bytes 7000-7999/8000
915
916     ...the second range
917     --THIS_STRING_SEPARATES--
918
919   Notes:
920
921   1.  Additional CRLFs may precede the first boundary string in the
922       entity.
923
924   2.  Although [RFC2046] permits the boundary string to be quoted, some
925       existing implementations handle a quoted boundary string
926       incorrectly.
927
928   3.  A number of browsers and servers were coded to an early draft of
929       the byteranges specification to use a media type of multipart/
930       x-byteranges, which is almost, but not quite compatible with the
931       version documented in HTTP/1.1.
932
933
934Appendix B.  Compatibility with Previous Versions
935
936B.1.  Changes from RFC 2068
937
938   Transfer-coding and message lengths all interact in ways that
939   required fixing exactly when chunked encoding is used (to allow for
940   transfer encoding that may not be self delimiting); it was important
941   to straighten out exactly how message lengths are computed.
942   (Section 5.2, see also [Part1], [Part3] and [Part6])
943
944   There are situations where a server (especially a proxy) does not
945   know the full length of a response but is capable of serving a
946   byterange request.  We therefore need a mechanism to allow byteranges
947   with a content-range not indicating the full length of the message.
948
949
950
951Fielding, et al.       Expires September 10, 2009              [Page 17]
952
953Internet-Draft              HTTP/1.1, Part 5                  March 2009
954
955
956   (Section 5.2)
957
958   Range request responses would become very verbose if all meta-data
959   were always returned; by allowing the server to only send needed
960   headers in a 206 response, this problem can be avoided.  (Section 3.1
961   and 5.3)
962
963   Fix problem with unsatisfiable range requests; there are two cases:
964   syntactic problems, and range doesn't exist in the document.  The 416
965   status code was needed to resolve this ambiguity needed to indicate
966   an error for a byte range request that falls outside of the actual
967   contents of a document.  (Section 3.2, 5.2)
968
969B.2.  Changes from RFC 2616
970
971   Clarify that it is not ok to use a weak cache validator in a 206
972   response.  (Section 3.1)
973
974   Clarify that multipart/byteranges can consist of a single part.
975   (Appendix A)
976
977
978Appendix C.  Collected ABNF
979
980   Accept-Ranges = "Accept-Ranges:" OWS Accept-Ranges-v
981   Accept-Ranges-v = acceptable-ranges
982
983   Content-Range = "Content-Range:" OWS Content-Range-v
984   Content-Range-v = content-range-spec
985
986   HTTP-date = <HTTP-date, defined in [Part1], Section 3.2.1>
987
988   If-Range = "If-Range:" OWS If-Range-v
989   If-Range-v = entity-tag / HTTP-date
990
991   OWS = <OWS, defined in [Part1], Section 1.2.2>
992
993   Range = "Range:" OWS Range-v
994   Range-v = byte-ranges-specifier / other-ranges-specifier
995
996   acceptable-ranges = ( *( "," OWS ) range-unit *( OWS "," [ OWS
997    range-unit ] ) ) / "none"
998
999   byte-content-range-spec = bytes-unit SP byte-range-resp-spec "/" (
1000    instance-length / "*" )
1001   byte-range-resp-spec = ( first-byte-pos "-" last-byte-pos ) / "*"
1002
1003
1004
1005
1006
1007Fielding, et al.       Expires September 10, 2009              [Page 18]
1008
1009Internet-Draft              HTTP/1.1, Part 5                  March 2009
1010
1011
1012   byte-range-set = ( *( "," OWS ) byte-range-spec ) / (
1013    suffix-byte-range-spec *( OWS "," [ ( OWS byte-range-spec ) /
1014    suffix-byte-range-spec ] ) )
1015   byte-range-spec = first-byte-pos "-" [ last-byte-pos ]
1016   byte-ranges-specifier = bytes-unit "=" byte-range-set
1017   bytes-unit = "bytes"
1018
1019   content-range-spec = byte-content-range-spec /
1020    other-content-range-spec
1021
1022   entity-tag = <entity-tag, defined in [Part4], Section 2>
1023
1024   first-byte-pos = 1*DIGIT
1025
1026   instance-length = 1*DIGIT
1027
1028   last-byte-pos = 1*DIGIT
1029
1030   other-content-range-spec = other-range-unit SP other-range-resp-spec
1031   other-range-resp-spec = *CHAR
1032   other-range-unit = token
1033   other-ranges-specifier = 1*CHAR
1034
1035   range-unit = bytes-unit / other-range-unit
1036
1037   suffix-byte-range-spec = "-" suffix-length
1038   suffix-length = 1*DIGIT
1039
1040   token = <token, defined in [Part1], Section 1.2.2>
1041
1042
1043
1044   ABNF diagnostics:
1045
1046   ; Accept-Ranges defined but not used
1047   ; Content-Range defined but not used
1048   ; If-Range defined but not used
1049   ; Range defined but not used
1050
1051
1052Appendix D.  Change Log (to be removed by RFC Editor before publication)
1053
1054D.1.  Since RFC2616
1055
1056   Extracted relevant partitions from [RFC2616].
1057
1058
1059
1060
1061
1062
1063Fielding, et al.       Expires September 10, 2009              [Page 19]
1064
1065Internet-Draft              HTTP/1.1, Part 5                  March 2009
1066
1067
1068D.2.  Since draft-ietf-httpbis-p5-range-00
1069
1070   Closed issues:
1071
1072   o  <http://tools.ietf.org/wg/httpbis/trac/ticket/18>: "Cache
1073      validators in 206 responses"
1074      (<http://purl.org/NET/http-errata#ifrange206>)
1075
1076   o  <http://tools.ietf.org/wg/httpbis/trac/ticket/35>: "Normative and
1077      Informative references"
1078
1079   o  <http://tools.ietf.org/wg/httpbis/trac/ticket/86>: "Normative up-
1080      to-date references"
1081
1082D.3.  Since draft-ietf-httpbis-p5-range-01
1083
1084   Closed issues:
1085
1086   o  <http://tools.ietf.org/wg/httpbis/trac/ticket/55>: "Updating to
1087      RFC4288"
1088
1089   Ongoing work on ABNF conversion
1090   (<http://tools.ietf.org/wg/httpbis/trac/ticket/36>):
1091
1092   o  Add explicit references to BNF syntax and rules imported from
1093      other parts of the specification.
1094
1095D.4.  Since draft-ietf-httpbis-p5-range-02
1096
1097   Ongoing work on IANA Message Header Registration
1098   (<http://tools.ietf.org/wg/httpbis/trac/ticket/40>):
1099
1100   o  Reference RFC 3984, and update header registrations for headers
1101      defined in this document.
1102
1103D.5.  Since draft-ietf-httpbis-p5-range-03
1104
1105D.6.  Since draft-ietf-httpbis-p5-range-04
1106
1107   Closed issues:
1108
1109   o  <http://tools.ietf.org/wg/httpbis/trac/ticket/133>: "multipart/
1110      byteranges minimum number of parts"
1111
1112   Ongoing work on ABNF conversion
1113   (<http://tools.ietf.org/wg/httpbis/trac/ticket/36>):
1114
1115
1116
1117
1118
1119Fielding, et al.       Expires September 10, 2009              [Page 20]
1120
1121Internet-Draft              HTTP/1.1, Part 5                  March 2009
1122
1123
1124   o  Use "/" instead of "|" for alternatives.
1125
1126   o  Introduce new ABNF rules for "bad" whitespace ("BWS"), optional
1127      whitespace ("OWS") and required whitespace ("RWS").
1128
1129   o  Rewrite ABNFs to spell out whitespace rules, factor out header
1130      value format definitions.
1131
1132D.7.  Since draft-ietf-httpbis-p5-range-05
1133
1134   Closed issues:
1135
1136   o  <http://tools.ietf.org/wg/httpbis/trac/ticket/142>: "State base
1137      for *-byte-pos and suffix-length"
1138
1139   Ongoing work on Custom Ranges
1140   (<http://tools.ietf.org/wg/httpbis/trac/ticket/85>):
1141
1142   o  Remove bias in favor of byte ranges; allow custom ranges in ABNF.
1143
1144   Final work on ABNF conversion
1145   (<http://tools.ietf.org/wg/httpbis/trac/ticket/36>):
1146
1147   o  Add appendix containing collected and expanded ABNF, reorganize
1148      ABNF introduction.
1149
1150
1151Index
1152
1153   2
1154      206 Partial Content (status code)  6
1155
1156   4
1157      416 Requested Range Not Satisfiable (status code)  6
1158
1159   A
1160      Accept-Ranges header  7
1161
1162   C
1163      Content-Range header  8
1164
1165   G
1166      Grammar
1167         Accept-Ranges  7
1168         Accept-Ranges-v  7
1169         acceptable-ranges  7
1170         byte-content-range-spec  8
1171         byte-range-resp-spec  8
1172
1173
1174
1175Fielding, et al.       Expires September 10, 2009              [Page 21]
1176
1177Internet-Draft              HTTP/1.1, Part 5                  March 2009
1178
1179
1180         byte-range-set  11
1181         byte-range-spec  11
1182         byte-ranges-specifier  11
1183         bytes-unit  5
1184         Content-Range  8
1185         content-range-spec  8
1186         Content-Range-v  8
1187         first-byte-pos  11
1188         If-Range  10
1189         If-Range-v  10
1190         instance-length  8
1191         last-byte-pos  11
1192         other-range-unit  5
1193         Range  13
1194         range-unit  5
1195         ranges-specifier  11
1196         suffix-byte-range-spec  12
1197         suffix-length  12
1198
1199   H
1200      Headers
1201         Accept-Ranges  7
1202         Content-Range  8
1203         If-Range  10
1204         Range  11
1205
1206   I
1207      If-Range header  10
1208
1209   M
1210      Media Type
1211         multipart/byteranges  15
1212         multipart/x-byteranges  17
1213      multipart/byteranges Media Type  15
1214      multipart/x-byteranges Media Type  17
1215
1216   R
1217      Range header  11
1218
1219   S
1220      Status Codes
1221         206 Partial Content  6
1222         416 Requested Range Not Satisfiable  6
1223
1224
1225
1226
1227
1228
1229
1230
1231Fielding, et al.       Expires September 10, 2009              [Page 22]
1232
1233Internet-Draft              HTTP/1.1, Part 5                  March 2009
1234
1235
1236Authors' Addresses
1237
1238   Roy T. Fielding (editor)
1239   Day Software
1240   23 Corporate Plaza DR, Suite 280
1241   Newport Beach, CA  92660
1242   USA
1243
1244   Phone: +1-949-706-5300
1245   Fax:   +1-949-706-5305
1246   Email: fielding@gbiv.com
1247   URI:   http://roy.gbiv.com/
1248
1249
1250   Jim Gettys
1251   One Laptop per Child
1252   21 Oak Knoll Road
1253   Carlisle, MA  01741
1254   USA
1255
1256   Email: jg@laptop.org
1257   URI:   http://www.laptop.org/
1258
1259
1260   Jeffrey C. Mogul
1261   Hewlett-Packard Company
1262   HP Labs, Large Scale Systems Group
1263   1501 Page Mill Road, MS 1177
1264   Palo Alto, CA  94304
1265   USA
1266
1267   Email: JeffMogul@acm.org
1268
1269
1270   Henrik Frystyk Nielsen
1271   Microsoft Corporation
1272   1 Microsoft Way
1273   Redmond, WA  98052
1274   USA
1275
1276   Email: henrikn@microsoft.com
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287Fielding, et al.       Expires September 10, 2009              [Page 23]
1288
1289Internet-Draft              HTTP/1.1, Part 5                  March 2009
1290
1291
1292   Larry Masinter
1293   Adobe Systems, Incorporated
1294   345 Park Ave
1295   San Jose, CA  95110
1296   USA
1297
1298   Email: LMM@acm.org
1299   URI:   http://larry.masinter.net/
1300
1301
1302   Paul J. Leach
1303   Microsoft Corporation
1304   1 Microsoft Way
1305   Redmond, WA  98052
1306
1307   Email: paulle@microsoft.com
1308
1309
1310   Tim Berners-Lee
1311   World Wide Web Consortium
1312   MIT Computer Science and Artificial Intelligence Laboratory
1313   The Stata Center, Building 32
1314   32 Vassar Street
1315   Cambridge, MA  02139
1316   USA
1317
1318   Email: timbl@w3.org
1319   URI:   http://www.w3.org/People/Berners-Lee/
1320
1321
1322   Yves Lafon (editor)
1323   World Wide Web Consortium
1324   W3C / ERCIM
1325   2004, rte des Lucioles
1326   Sophia-Antipolis, AM  06902
1327   France
1328
1329   Email: ylafon@w3.org
1330   URI:   http://www.raubacapeu.net/people/yves/
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343Fielding, et al.       Expires September 10, 2009              [Page 24]
1344
1345Internet-Draft              HTTP/1.1, Part 5                  March 2009
1346
1347
1348   Julian F. Reschke (editor)
1349   greenbytes GmbH
1350   Hafenweg 16
1351   Muenster, NW  48155
1352   Germany
1353
1354   Phone: +49 251 2807760
1355   Fax:   +49 251 2807761
1356   Email: julian.reschke@greenbytes.de
1357   URI:   http://greenbytes.de/tech/webdav/
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399Fielding, et al.       Expires September 10, 2009              [Page 25]
1400
Note: See TracBrowser for help on using the repository browser.