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

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

(editorial) clarify that If-Range uses an exact match comparison even for HTTP-date, unlike If-Unmodified-Since; see #534 comment from Richard Barnes

  • Property svn:eol-style set to native
  • Property svn:mime-type set to text/xml
File size: 64.4 KB
Line 
1<?xml version="1.0" encoding="utf-8"?>
2<?xml-stylesheet type='text/xsl' href='../myxml2rfc.xslt'?>
3<!DOCTYPE rfc [
4  <!ENTITY MAY "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>MAY</bcp14>">
5  <!ENTITY MUST "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>MUST</bcp14>">
6  <!ENTITY MUST-NOT "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>MUST NOT</bcp14>">
7  <!ENTITY OPTIONAL "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>OPTIONAL</bcp14>">
8  <!ENTITY RECOMMENDED "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>RECOMMENDED</bcp14>">
9  <!ENTITY REQUIRED "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>REQUIRED</bcp14>">
10  <!ENTITY SHALL "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>SHALL</bcp14>">
11  <!ENTITY SHALL-NOT "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>SHALL NOT</bcp14>">
12  <!ENTITY SHOULD "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>SHOULD</bcp14>">
13  <!ENTITY SHOULD-NOT "<bcp14 xmlns='http://purl.org/net/xml2rfc/ext'>SHOULD NOT</bcp14>">
14  <!ENTITY ID-VERSION "latest">
15  <!ENTITY ID-MONTH "January">
16  <!ENTITY ID-YEAR "2014">
17  <!ENTITY mdash "&#8212;">
18  <!ENTITY Note "<x:h xmlns:x='http://purl.org/net/xml2rfc/ext'>Note:</x:h>">
19  <!ENTITY architecture               "<xref target='Part1' x:rel='#architecture' xmlns:x='http://purl.org/net/xml2rfc/ext'/>">
20  <!ENTITY conformance                "<xref target='Part1' x:rel='#conformance' xmlns:x='http://purl.org/net/xml2rfc/ext'/>">
21  <!ENTITY notation                   "<xref target='Part1' x:rel='#notation' xmlns:x='http://purl.org/net/xml2rfc/ext'/>">
22  <!ENTITY abnf-extension             "<xref target='Part1' x:rel='#abnf.extension' xmlns:x='http://purl.org/net/xml2rfc/ext'/>">
23  <!ENTITY acks                       "<xref target='Part1' x:rel='#acks' xmlns:x='http://purl.org/net/xml2rfc/ext'/>">
24  <!ENTITY whitespace                 "<xref target='Part1' x:rel='#whitespace' xmlns:x='http://purl.org/net/xml2rfc/ext'/>">
25  <!ENTITY field-components           "<xref target='Part1' x:rel='#field.components' xmlns:x='http://purl.org/net/xml2rfc/ext'/>">
26  <!ENTITY messaging                  "<xref target='Part1' xmlns:x='http://purl.org/net/xml2rfc/ext'/>">
27  <!ENTITY semantics                  "<xref target='Part2' xmlns:x='http://purl.org/net/xml2rfc/ext'/>">
28  <!ENTITY http-date                  "<xref target='Part2' x:rel='#http.date' xmlns:x='http://purl.org/net/xml2rfc/ext'/>">
29  <!ENTITY representation             "<xref target='Part2' x:rel='#representations' xmlns:x='http://purl.org/net/xml2rfc/ext'/>">
30  <!ENTITY entity-tags                "<xref target='Part4' x:rel='#header.etag' xmlns:x='http://purl.org/net/xml2rfc/ext'/>">
31  <!ENTITY weak-and-strong-validators "<xref target='Part4' x:rel='#weak.and.strong.validators' xmlns:x='http://purl.org/net/xml2rfc/ext'/>">
32  <!ENTITY entity-tag-comparison      "<xref target='Part4' x:rel='#entity.tag.comparison' xmlns:x='http://purl.org/net/xml2rfc/ext'/>">
33  <!ENTITY lastmod-comparison         "<xref target='Part4' x:rel='#lastmod.comparison' xmlns:x='http://purl.org/net/xml2rfc/ext'/>">
34  <!ENTITY p6-heuristic               "<xref target='Part6' x:rel='#heuristic.freshness' xmlns:x='http://purl.org/net/xml2rfc/ext'/>">
35]>
36<?rfc toc="yes" ?>
37<?rfc symrefs="yes" ?>
38<?rfc sortrefs="yes" ?>
39<?rfc compact="yes"?>
40<?rfc subcompact="no" ?>
41<?rfc linkmailto="no" ?>
42<?rfc editing="no" ?>
43<?rfc comments="yes"?>
44<?rfc inline="yes"?>
45<?rfc rfcedstyle="yes"?>
46<?rfc-ext allow-markup-in-artwork="yes" ?>
47<?rfc-ext include-references-in-index="yes" ?>
48<rfc obsoletes="2616" category="std" x:maturity-level="proposed"
49     ipr="pre5378Trust200902" docName="draft-ietf-httpbis-p5-range-&ID-VERSION;"
50     xmlns:x='http://purl.org/net/xml2rfc/ext'>
51<x:link rel="prev" basename="p4-conditional"/>
52<x:link rel="next" basename="p6-cache"/>
53<x:feedback template="mailto:ietf-http-wg@w3.org?subject={docname},%20%22{section}%22&amp;body=&lt;{ref}&gt;:"/>
54<front>
55
56  <title abbrev="HTTP/1.1 Range Requests">Hypertext Transfer Protocol (HTTP/1.1): Range Requests</title>
57
58  <author initials="R." surname="Fielding" fullname="Roy T. Fielding" role="editor">
59    <organization abbrev="Adobe">Adobe Systems Incorporated</organization>
60    <address>
61      <postal>
62        <street>345 Park Ave</street>
63        <city>San Jose</city>
64        <region>CA</region>
65        <code>95110</code>
66        <country>USA</country>
67      </postal>
68      <email>fielding@gbiv.com</email>
69      <uri>http://roy.gbiv.com/</uri>
70    </address>
71  </author>
72
73  <author initials="Y." surname="Lafon" fullname="Yves Lafon" role="editor">
74    <organization abbrev="W3C">World Wide Web Consortium</organization>
75    <address>
76      <postal>
77        <street>W3C / ERCIM</street>
78        <street>2004, rte des Lucioles</street>
79        <city>Sophia-Antipolis</city>
80        <region>AM</region>
81        <code>06902</code>
82        <country>France</country>
83      </postal>
84      <email>ylafon@w3.org</email>
85      <uri>http://www.raubacapeu.net/people/yves/</uri>
86    </address>
87  </author>
88
89  <author initials="J. F." surname="Reschke" fullname="Julian F. Reschke" role="editor">
90    <organization abbrev="greenbytes">greenbytes GmbH</organization>
91    <address>
92      <postal>
93        <street>Hafenweg 16</street>
94        <city>Muenster</city><region>NW</region><code>48155</code>
95        <country>Germany</country>
96      </postal>
97      <email>julian.reschke@greenbytes.de</email>
98      <uri>http://greenbytes.de/tech/webdav/</uri>
99    </address>
100  </author>
101
102  <date month="&ID-MONTH;" year="&ID-YEAR;"/>
103  <workgroup>HTTPbis Working Group</workgroup>
104
105<abstract>
106<t>
107   The Hypertext Transfer Protocol (HTTP) is a stateless application-level protocol for
108   distributed, collaborative, hypertext information systems. This document
109   defines range requests and the rules for constructing and combining
110   responses to those requests.
111</t>
112</abstract>
113
114<note title="Editorial Note (To be removed by RFC Editor)">
115  <t>
116    Discussion of this draft takes place on the HTTPBIS working group
117    mailing list (ietf-http-wg@w3.org), which is archived at
118    <eref target="http://lists.w3.org/Archives/Public/ietf-http-wg/"/>.
119  </t>
120  <t>
121    The current issues list is at
122    <eref target="http://tools.ietf.org/wg/httpbis/trac/report/3"/> and related
123    documents (including fancy diffs) can be found at
124    <eref target="http://tools.ietf.org/wg/httpbis/"/>.
125  </t>
126  <t>
127    The changes in this draft are summarized in <xref target="changes.since.25"/>.
128  </t>
129</note>
130</front>
131<middle>
132<section title="Introduction" anchor="introduction">
133<t>
134   Hypertext Transfer Protocol (HTTP) clients often encounter interrupted data
135   transfers as a result of canceled requests or dropped connections. When a
136   client has stored a partial representation, it is desirable to request the
137   remainder of that representation in a subsequent request rather than
138   transfer the entire representation. Likewise, devices with limited local
139   storage might benefit from being able to request only a subset of a larger
140   representation, such as a single page of a very large document, or the
141   dimensions of an embedded image.
142</t>
143<t>
144   This document defines HTTP/1.1 range requests, partial responses, and the
145   multipart/byteranges media type. Range requests are an &OPTIONAL; feature
146   of HTTP, designed so that recipients not implementing this feature (or not
147   supporting it for the target resource) can respond as if it is a normal
148   GET request without impacting interoperability. Partial responses are
149   indicated by a distinct status code to not be mistaken for full responses
150   by caches that might not implement the feature.
151</t>
152<t>
153   Although the range request mechanism is designed to allow for
154   extensible range types, this specification only defines requests for
155   byte ranges.
156</t>
157
158<section title="Conformance and Error Handling" anchor="conformance">
159<t>
160   The key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT",
161   "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this
162   document are to be interpreted as described in <xref target="RFC2119"/>.
163</t>
164<t>
165   Conformance criteria and considerations regarding error handling
166   are defined in &conformance;.
167</t>
168</section>
169
170<section title="Syntax Notation" anchor="notation">
171<t>
172   This specification uses the Augmented Backus-Naur Form (ABNF) notation of
173   <xref target="RFC5234"/> with a list extension, defined in
174   &abnf-extension;, that allows for compact definition of
175   comma-separated lists using a '#' operator (similar to how the '*' operator
176   indicates repetition).
177   <xref target="imported.abnf"/> describes rules imported from
178   other documents.
179   <xref target="collected.abnf"/> shows the collected grammar with all list
180   operators expanded to standard ABNF notation.
181</t>
182</section>
183</section>
184
185
186<section title="Range Units" anchor="range.units">
187  <x:anchor-alias value="range-unit"/>
188  <x:anchor-alias value="range unit"/>
189<t>
190   A representation can be partitioned into subranges according to various
191   structural units, depending on the structure inherent in the
192   representation's media type. This "<x:dfn>range unit</x:dfn>" is used
193   in the <x:ref>Accept-Ranges</x:ref> (<xref target="header.accept-ranges"/>)
194   response header field to advertise support for range requests, the
195   <x:ref>Range</x:ref> (<xref target="header.range"/>) request header field
196   to delineate the parts of a representation that are requested, and the
197   <x:ref>Content-Range</x:ref> (<xref target="header.content-range"/>)
198   payload header field to describe which part of a representation is being
199   transferred.
200</t>
201<figure><artwork type="abnf2616"><iref primary="true" item="Grammar" subitem="range-unit"/><iref item="Grammar" subitem="bytes-unit"/><iref item="Grammar" subitem="other-range-unit"/>
202  <x:ref>range-unit</x:ref>       = <x:ref>bytes-unit</x:ref> / <x:ref>other-range-unit</x:ref>
203</artwork></figure>
204
205<section title="Byte Ranges" anchor="byte.ranges">
206  <x:anchor-alias value="bytes-unit"/>
207<t>
208   Since representation data is transferred in payloads as a sequence of
209   octets, a byte range is a meaningful substructure for any representation
210   transferable over HTTP (&representation;). We define the "bytes" range
211   unit for expressing subranges of the data's octet sequence.
212</t>
213<figure><artwork type="abnf2616"><iref primary="true" item="Grammar" subitem="bytes-unit"/>
214  <x:ref>bytes-unit</x:ref>       = "bytes"
215</artwork></figure>
216<t anchor="rule.ranges-specifier">
217  <x:anchor-alias value="byte-range-set"/>
218  <x:anchor-alias value="byte-range-spec"/>
219  <x:anchor-alias value="byte-ranges-specifier"/>
220  <x:anchor-alias value="first-byte-pos"/>
221  <x:anchor-alias value="last-byte-pos"/>
222  <x:anchor-alias value="ranges-specifier"/>
223  <x:anchor-alias value="suffix-byte-range-spec"/>
224  <x:anchor-alias value="suffix-length"/>
225   A byte range request can specify a single range of bytes, or a set
226   of ranges within a single representation.
227</t>
228<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"/>
229  <x:ref>byte-ranges-specifier</x:ref> = <x:ref>bytes-unit</x:ref> "=" <x:ref>byte-range-set</x:ref>
230  <x:ref>byte-range-set</x:ref>  = 1#( <x:ref>byte-range-spec</x:ref> / <x:ref>suffix-byte-range-spec</x:ref> )
231  <x:ref>byte-range-spec</x:ref> = <x:ref>first-byte-pos</x:ref> "-" [ <x:ref>last-byte-pos</x:ref> ]
232  <x:ref>first-byte-pos</x:ref>  = 1*<x:ref>DIGIT</x:ref>
233  <x:ref>last-byte-pos</x:ref>   = 1*<x:ref>DIGIT</x:ref>
234</artwork></figure>
235<t>
236   The <x:ref>first-byte-pos</x:ref> value in a <x:ref>byte-range-spec</x:ref>
237   gives the byte-offset of the first byte in a range.
238   The <x:ref>last-byte-pos</x:ref> value gives the byte-offset of the last
239   byte in the range; that is, the byte positions specified are inclusive.
240   Byte offsets start at zero.
241</t>
242<t>
243   Examples of <x:ref>byte-ranges-specifier</x:ref> values:
244  <list style="symbols">
245     <t>The first 500 bytes (byte offsets 0-499, inclusive):
246<figure><artwork type="example" x:indent-with="   ">
247  bytes=0-499
248</artwork></figure>
249    </t>
250     <t>The second 500 bytes (byte offsets 500-999, inclusive):
251<figure><artwork type="example" x:indent-with="   ">
252  bytes=500-999
253</artwork></figure>
254    </t>
255  </list>
256</t>
257<t>
258   A <x:ref>byte-range-spec</x:ref> is invalid if the
259   <x:ref>last-byte-pos</x:ref> value is present and less than the
260   <x:ref>first-byte-pos</x:ref>.
261</t>
262<t>
263   A client can limit the number of bytes requested without knowing the size
264   of the selected representation.
265   If the <x:ref>last-byte-pos</x:ref> value is absent, or if the value is
266   greater than or equal to the current length of the representation data, the
267   byte range is interpreted as the remainder of the representation (i.e., the
268   server replaces the value of <x:ref>last-byte-pos</x:ref> with a value that
269   is one less than the current length of the selected representation).
270</t>
271<t>
272   A client can request the last N bytes of the selected representation using
273   a <x:ref>suffix-byte-range-spec</x:ref>.
274</t>
275<figure><artwork type="abnf2616"><iref primary="true" item="Grammar" subitem="suffix-byte-range-spec"/><iref primary="true" item="Grammar" subitem="suffix-length"/>
276  <x:ref>suffix-byte-range-spec</x:ref> = "-" <x:ref>suffix-length</x:ref>
277  <x:ref>suffix-length</x:ref> = 1*<x:ref>DIGIT</x:ref>
278</artwork></figure>
279<t>
280   If the selected representation is shorter than the specified
281   <x:ref>suffix-length</x:ref>, the entire representation is used.
282</t>
283<t>  
284   Additional examples, assuming a representation of length 10000:
285  <list style="symbols">
286     <t>The final 500 bytes (byte offsets 9500-9999, inclusive):
287<figure><artwork type="example" x:indent-with="   ">
288  bytes=-500
289</artwork></figure>
290    Or:
291<figure><artwork type="example" x:indent-with="   ">
292  bytes=9500-
293</artwork></figure>
294    </t>
295     <t>The first and last bytes only (bytes 0 and 9999):
296<figure><artwork type="example" x:indent-with="   ">
297  bytes=0-0,-1
298</artwork></figure>
299     </t>
300     <t>Other valid (but not canonical) specifications of the second 500
301        bytes (byte offsets 500-999, inclusive):
302<figure><artwork type="example" x:indent-with="   ">
303  bytes=500-600,601-999
304  bytes=500-700,601-999
305</artwork></figure>
306     </t>
307  </list>
308</t>
309<t>
310   If a valid <x:ref>byte-range-set</x:ref> includes at least one
311   <x:ref>byte-range-spec</x:ref> with a <x:ref>first-byte-pos</x:ref> that is
312   less than the current length of the representation, or at least one
313   <x:ref>suffix-byte-range-spec</x:ref> with a non-zero
314   <x:ref>suffix-length</x:ref>, then the <x:ref>byte-range-set</x:ref> is
315   satisfiable. Otherwise, the <x:ref>byte-range-set</x:ref> is unsatisfiable.
316</t>
317<t>
318   In the byte range syntax, <x:ref>first-byte-pos</x:ref>,
319   <x:ref>last-byte-pos</x:ref>, and <x:ref>suffix-length</x:ref> are
320   expressed as decimal number of octets. Since there is no predefined limit
321   to the length of a payload, recipients &MUST; anticipate potentially
322   large decimal numerals and prevent parsing errors due to integer conversion
323   overflows.
324</t>
325</section>
326
327<section title="Other Range Units" anchor="range.units.other">
328  <x:anchor-alias value="other-range-unit"/>
329<t>
330  Range units are intended to be extensible.  New range units ought to be
331  registered with IANA, as defined in <xref target="range.unit.registry"/>.
332</t>
333<figure><artwork type="abnf2616"><iref primary="true" item="Grammar" subitem="other-range-unit"/>
334  <x:ref>other-range-unit</x:ref> = <x:ref>token</x:ref>
335</artwork></figure>
336</section>
337
338<section title="Accept-Ranges" anchor="header.accept-ranges">
339  <iref primary="true" item="Accept-Ranges header field" x:for-anchor=""/>
340  <x:anchor-alias value="Accept-Ranges"/>
341  <x:anchor-alias value="acceptable-ranges"/>
342<t>
343   The "Accept-Ranges" header field allows a server to indicate that it
344   supports range requests for the target resource.
345</t>
346<figure><artwork type="abnf2616"><iref primary="true" item="Grammar" subitem="Accept-Ranges"/><iref primary="true" item="Grammar" subitem="acceptable-ranges"/>
347  <x:ref>Accept-Ranges</x:ref>     = <x:ref>acceptable-ranges</x:ref>
348  <x:ref>acceptable-ranges</x:ref> = 1#<x:ref>range-unit</x:ref> / "none"
349</artwork></figure>
350<t>
351   An origin server that supports byte-range requests for a given target
352   resource &MAY; send
353</t>
354<figure><artwork type="example">
355  Accept-Ranges: bytes
356</artwork></figure>
357<t>
358   to indicate what range units are supported. A client &MAY; generate range
359   requests without having received this header field for the resource
360   involved. Range units are defined in <xref target="range.units"/>.
361</t>
362<t>
363   A server that does not support any kind of range request for the target
364   resource &MAY; send
365</t>
366<figure><artwork type="example">
367  Accept-Ranges: none
368</artwork></figure>
369<t>
370   to advise the client not to attempt a range request.
371</t>
372</section>
373</section>
374
375
376<section title="Range Requests" anchor="range.requests">
377<section title="Range" anchor="header.range">
378  <iref primary="true" item="Range header field" x:for-anchor=""/>
379  <x:anchor-alias value="Range"/>
380  <x:anchor-alias value="other-ranges-specifier"/>
381  <x:anchor-alias value="other-range-set"/>
382<t>
383   The "Range" header field on a GET request modifies the method semantics to
384   request transfer of only one or more subranges of the selected
385   representation data, rather than the entire selected representation data.
386</t>
387<figure><artwork type="abnf2616"><iref primary="true" item="Grammar" subitem="Range"/>
388  <x:ref>Range</x:ref> = <x:ref>byte-ranges-specifier</x:ref> / <x:ref>other-ranges-specifier</x:ref>
389  <x:ref>other-ranges-specifier</x:ref> = <x:ref>other-range-unit</x:ref> "=" <x:ref>other-range-set</x:ref>
390  <x:ref>other-range-set</x:ref> = 1*<x:ref>VCHAR</x:ref>
391</artwork></figure>
392<t>
393   A server &MAY; ignore the Range header field. However, origin servers and
394   intermediate caches ought to support byte ranges when possible, since Range
395   supports efficient recovery from partially failed transfers and partial
396   retrieval of large representations. A server &MUST; ignore a Range header
397   field received with a request method other than GET.
398</t>
399<t>
400   An origin server &MUST; ignore a Range header field that contains a range
401   unit it does not understand. A proxy &MAY; discard a Range header
402   field that contains a range unit it does not understand.
403</t>
404<t>
405   A server that supports range requests &MAY; ignore or reject a
406   <x:ref>Range</x:ref> header field that consists of more than two
407   overlapping ranges, or a set of many small ranges that are not listed
408   in ascending order, since both are indications of either a broken client or
409   a deliberate denial of service attack (<xref target="overlapping.ranges"/>).
410   A client &SHOULD-NOT; request multiple ranges that are inherently less
411   efficient to process and transfer than a single range that encompasses the
412   same data.
413</t>
414<t>
415   A client that is requesting multiple ranges &SHOULD; list those ranges in
416   ascending order (the order in which they would typically be received in a
417   complete representation) unless there is a specific need to request a later
418   part earlier. For example, a user agent processing a large representation
419   with an internal catalog of parts might need to request later parts first,
420   particularly if the representation consists of pages stored in reverse
421   order and the user agent wishes to transfer one page at a time.
422</t>
423<t>
424   The Range header field is evaluated after evaluating the precondition header
425   fields defined in <xref target="Part4"/>, and only if the result in absence
426   of the Range header field would be a <x:ref>200 (OK)</x:ref> response. In
427   other words, Range is ignored when a conditional GET would result in a
428   <x:ref>304 (Not Modified)</x:ref> response.
429</t>
430<t>
431   The If-Range header field (<xref target="header.if-range"/>) can be used as
432   a precondition to applying the Range header field.
433</t>
434<t>
435   If all of the preconditions are true, the server supports the Range header
436   field for the target resource, and the specified range(s) are valid and
437   satisfiable (as defined in <xref target="byte.ranges"/>), the
438   server &SHOULD; send a <x:ref>206 (Partial Content)</x:ref> response with a
439   payload containing one or more partial representations that correspond to
440   the satisfiable ranges requested, as defined in
441   <xref target="range.response"/>.
442</t>
443<t>
444   If all of the preconditions are true, the server supports the Range header
445   field for the target resource, and the specified range(s) are invalid or
446   unsatisfiable, the server &SHOULD; send a
447   <x:ref>416 (Range Not Satisfiable)</x:ref> response.
448</t>
449</section>
450
451<section title="If-Range" anchor="header.if-range">
452  <iref primary="true" item="If-Range header field" x:for-anchor=""/>
453  <x:anchor-alias value="If-Range"/>
454<t>
455   If a client has a partial copy of a representation and wishes
456   to have an up-to-date copy of the entire representation, it could use the
457   <x:ref>Range</x:ref> header field with a conditional GET (using
458   either or both of <x:ref>If-Unmodified-Since</x:ref> and
459   <x:ref>If-Match</x:ref>.) However, if the precondition fails because the
460   representation has been modified, the client would then have to make a
461   second request to obtain the entire current representation.
462</t>
463<t>
464   The "If-Range" header field allows a client to "short-circuit" the second
465   request. Informally, its meaning is: if the representation is unchanged,
466   send me the part(s) that I am requesting in Range; otherwise, send me the
467   entire representation.
468</t>
469<figure><artwork type="abnf2616"><iref primary="true" item="Grammar" subitem="If-Range"/>
470  <x:ref>If-Range</x:ref> = <x:ref>entity-tag</x:ref> / <x:ref>HTTP-date</x:ref>
471</artwork></figure>
472<t>
473   A client &MUST-NOT; generate an If-Range header field in a request that
474   does not contain a <x:ref>Range</x:ref> header field.
475   A server &MUST; ignore an If-Range header field received in a request that
476   does not contain a <x:ref>Range</x:ref> header field.
477   An origin server &MUST; ignore an If-Range header field received in a
478   request for a target resource that does not support Range requests.
479</t>
480<t>
481   A client &MUST-NOT; generate an If-Range header field containing an
482   entity-tag that is marked as weak.
483   A client &MUST-NOT; generate an If-Range header field containing an
484   <x:ref>HTTP-date</x:ref> unless the client has no entity-tag for
485   the corresponding representation and the date is a strong validator
486   in the sense defined by &lastmod-comparison;.
487</t>
488<t>
489   A server that evaluates an If-Range precondition &MUST; use the strong
490   comparison function when comparing entity-tags (&entity-tag-comparison;)
491   and &MUST; evaluate the condition as false if an <x:ref>HTTP-date</x:ref>
492   validator is provided that is not a strong validator in the sense defined
493   by &lastmod-comparison;.
494   (A server can distinguish between a valid <x:ref>HTTP-date</x:ref> and any
495   form of entity-tag by examining the first two characters.)
496</t>
497<t>
498   If the validator given in the If-Range header field matches the current
499   validator for the selected representation of the target resource, then
500   the server &SHOULD; process the <x:ref>Range</x:ref> header field as
501   requested. If the validator does not match, the server &MUST; ignore the
502   <x:ref>Range</x:ref> header field. Note that this comparison by exact
503   match, including when the validator is an <x:ref>HTTP-date</x:ref>, differs
504   from the "earlier than or equal to" comparison used when evaluating an
505   <x:ref>If-Unmodified-Since</x:ref> conditional.
506</t>
507</section>
508</section>
509
510
511<section title="Responses to a Range Request" anchor="range.response">
512
513<section title="206 Partial Content" anchor="status.206">
514  <iref primary="true" item="206 Partial Content (status code)" x:for-anchor=""/>
515  <x:anchor-alias value="206"/>
516  <x:anchor-alias value="206 (Partial Content)"/>
517<t>
518   The <x:dfn>206 (Partial Content)</x:dfn> status code indicates that the
519   server is successfully fulfilling a range request for the target resource
520   by transferring one or more parts of the selected representation that
521   correspond to the satisfiable ranges found in the request's
522   <x:ref>Range</x:ref> header field (<xref target="header.range"/>).
523</t>
524<t>
525   If a single part is being transferred, the server generating the 206
526   response &MUST; generate a <x:ref>Content-Range</x:ref> header field,
527   describing what range of the selected representation is enclosed, and a
528   payload consisting of the range. For example:
529</t>
530<figure><artwork type="message/http; msgtype=&#34;response&#34;" x:indent-with="  ">
531HTTP/1.1 206 Partial Content
532Date: Wed, 15 Nov 1995 06:25:24 GMT
533Last-Modified: Wed, 15 Nov 1995 04:58:08 GMT
534Content-Range: bytes 21010-47021/47022
535Content-Length: 26012
536Content-Type: image/gif
537
538... 26012 bytes of partial image data ...
539</artwork></figure>
540<t>
541   If multiple parts are being transferred, the server generating the 206
542   response &MUST; generate a "multipart/byteranges" payload, as defined
543   in <xref target="internet.media.type.multipart.byteranges"/>, and a
544   <x:ref>Content-Type</x:ref> header field containing the
545   multipart/byteranges media type and its required boundary parameter.
546   To avoid confusion with single part responses, a server &MUST-NOT; generate
547   a <x:ref>Content-Range</x:ref> header field in the HTTP header section of a
548   multiple part response (this field will be sent in each part instead).
549</t>
550<t>
551   Within the header area of each body part in the multipart payload, the
552   server &MUST; generate a <x:ref>Content-Range</x:ref> header field
553   corresponding to the range being enclosed in that body part.
554   If the selected representation would have had a <x:ref>Content-Type</x:ref>
555   header field in a <x:ref>200 (OK)</x:ref> response, the server &SHOULD;
556   generate that same <x:ref>Content-Type</x:ref> field in the header area of
557   each body part. For example:
558</t>
559<figure><artwork type="message/http; msgtype=&#34;response&#34;" x:indent-with="  ">
560HTTP/1.1 206 Partial Content
561Date: Wed, 15 Nov 1995 06:25:24 GMT
562Last-Modified: Wed, 15 Nov 1995 04:58:08 GMT
563Content-Length: 1741
564Content-Type: multipart/byteranges; boundary=THIS_STRING_SEPARATES
565
566--THIS_STRING_SEPARATES
567Content-Type: application/pdf
568Content-Range: bytes 500-999/8000
569
570...the first range...
571--THIS_STRING_SEPARATES
572Content-Type: application/pdf
573Content-Range: bytes 7000-7999/8000
574
575...the second range
576--THIS_STRING_SEPARATES--
577</artwork></figure>
578<t>
579   When multiple ranges are requested, a server &MAY; coalesce any of the
580   ranges that overlap, or that are separated by a gap that is smaller than the
581   overhead of sending multiple parts, regardless of the order in which the
582   corresponding byte-range-spec appeared in the received <x:ref>Range</x:ref>
583   header field. Since the typical overhead between parts of a
584   multipart/byteranges payload is around 80 bytes, depending on the selected
585   representation's media type and the chosen boundary parameter length, it
586   can be less efficient to transfer many small disjoint parts than it is to
587   transfer the entire selected representation.
588</t>
589<t>
590   A server &MUST-NOT; generate a multipart response to a request for a single
591   range, since a client that does not request multiple parts might not
592   support multipart responses. However, a server &MAY; generate a
593   multipart/byteranges payload with only a single body part if multiple
594   ranges were requested and only one range was found to be satisfiable or
595   only one range remained after coalescing.
596   A client that cannot process a multipart/byteranges response &MUST-NOT;
597   generate a request that asks for multiple ranges.
598</t>
599<t>
600   When a multipart response payload is generated, the server &SHOULD; send
601   the parts in the same order that the corresponding byte-range-spec appeared
602   in the received <x:ref>Range</x:ref> header field, excluding those ranges
603   that were deemed unsatisfiable or that were coalesced into other ranges.
604   A client that receives a multipart response &MUST; inspect the
605   <x:ref>Content-Range</x:ref> header field present in each body part in
606   order to determine which range is contained in that body part; a client
607   cannot rely on receiving the same ranges that it requested, nor the same
608   order that it requested.
609</t>
610<t>
611   When a 206 response is generated, the server &MUST; generate the following
612   header fields, in addition to those required above, if the field would
613   have been sent in a <x:ref>200 (OK)</x:ref> response to the same request:
614   <x:ref>Date</x:ref>, <x:ref>Cache-Control</x:ref>, <x:ref>ETag</x:ref>,
615   <x:ref>Expires</x:ref>, <x:ref>Content-Location</x:ref>, and
616   <x:ref>Vary</x:ref>.
617</t>
618<t>
619   If a 206 is generated in response to a request with an <x:ref>If-Range</x:ref>
620   header field, the sender &SHOULD-NOT; generate other representation header
621   fields beyond those required above, because the client is understood to
622   already have a prior response containing those header fields.
623   Otherwise, the sender &MUST; generate all of the representation header
624   fields that would have been sent in a <x:ref>200 (OK)</x:ref> response
625   to the same request.
626</t>
627<t>
628   A 206 response is cacheable by default; i.e., unless otherwise indicated by
629   explicit cache controls (see &p6-heuristic;).
630</t>
631</section>
632
633<section title="Content-Range" anchor="header.content-range">
634  <iref primary="true" item="Content-Range header field" x:for-anchor=""/>
635  <x:anchor-alias value="Content-Range"/>
636  <x:anchor-alias value="byte-content-range"/>
637  <x:anchor-alias value="byte-range-resp"/>
638  <x:anchor-alias value="byte-range"/>
639  <x:anchor-alias value="unsatisfied-range"/>
640  <x:anchor-alias value="complete-length"/>
641  <x:anchor-alias value="other-content-range"/>
642  <x:anchor-alias value="other-range-resp"/>
643<t>
644   The "Content-Range" header field is sent in a single part
645   <x:ref>206 (Partial Content)</x:ref> response to indicate the partial range
646   of the selected representation enclosed as the message payload, sent in
647   each part of a multipart 206 response to indicate the range enclosed within
648   each body part, and sent in <x:ref>416 (Range Not Satisfiable)</x:ref>
649   responses to provide information about the selected representation.
650</t>
651<figure><artwork type="abnf2616"><iref primary="true" item="Grammar" subitem="Content-Range"/><iref primary="true" item="Grammar" subitem="byte-content-range"/><iref primary="true" item="Grammar" subitem="byte-range-resp"/><iref primary="true" item="Grammar" subitem="byte-range"/><iref primary="true" item="Grammar" subitem="unsatisfied-range"/><iref primary="true" item="Grammar" subitem="other-content-range"/><iref primary="true" item="Grammar" subitem="other-range-resp"/><iref primary="true" item="Grammar" subitem="complete-length"/>
652  <x:ref>Content-Range</x:ref>       = <x:ref>byte-content-range</x:ref>
653                      / <x:ref>other-content-range</x:ref>
654                         
655  <x:ref>byte-content-range</x:ref>  = <x:ref>bytes-unit</x:ref> <x:ref>SP</x:ref>
656                        ( <x:ref>byte-range-resp</x:ref> / <x:ref>unsatisfied-range</x:ref> )
657
658  <x:ref>byte-range-resp</x:ref>     = <x:ref>byte-range</x:ref> "/" ( <x:ref>complete-length</x:ref> / "*" )
659  <x:ref>byte-range</x:ref>          = <x:ref>first-byte-pos</x:ref> "-" <x:ref>last-byte-pos</x:ref>
660  <x:ref>unsatisfied-range</x:ref>   = "*/" <x:ref>complete-length</x:ref>
661                         
662  <x:ref>complete-length</x:ref>     = 1*<x:ref>DIGIT</x:ref>
663 
664  <x:ref>other-content-range</x:ref> = <x:ref>other-range-unit</x:ref> <x:ref>SP</x:ref> <x:ref>other-range-resp</x:ref>
665  <x:ref>other-range-resp</x:ref>    = *<x:ref>CHAR</x:ref>
666</artwork></figure>
667<t>  
668   If a <x:ref>206 (Partial Content)</x:ref> response contains a
669   <x:ref>Content-Range</x:ref> header field with a <x:ref>range unit</x:ref>
670   (<xref target="range.units"/>) that the recipient does not understand, the
671   recipient &MUST-NOT; attempt to recombine it with a stored representation.
672   A proxy that receives such a message &SHOULD; forward it downstream.
673</t>
674<t>
675   For byte ranges, a sender &SHOULD; indicate the complete length of the
676   representation from which the range has been extracted, unless the complete
677   length is unknown or difficult to determine. An asterisk character ("*") in
678   place of the complete-length indicates that the representation length was
679   unknown when the header field was generated.
680</t>
681<t>
682   The following example illustrates when the complete length of the selected
683   representation is known by the sender to be 1234 bytes:
684</t>
685<figure><artwork type="example">
686  Content-Range: bytes 42-1233/1234
687</artwork></figure>
688<t>
689   and this second example illustrates when the complete length is unknown:
690</t>
691<figure><artwork type="example">
692  Content-Range: bytes 42-1233/*
693</artwork></figure>
694<t>
695   A Content-Range field value is invalid if it contains a
696   <x:ref>byte-range-resp</x:ref> that has a <x:ref>last-byte-pos</x:ref>
697   value less than its <x:ref>first-byte-pos</x:ref> value, or a
698   <x:ref>complete-length</x:ref> value less than or equal to its
699   <x:ref>last-byte-pos</x:ref> value. The recipient of an invalid
700   <x:ref>Content-Range</x:ref> &MUST-NOT; attempt to recombine the received
701   content with a stored representation.
702</t>
703<t>
704   A server generating a <x:ref>416 (Range Not Satisfiable)</x:ref> response
705   to a byte range request &SHOULD; send a Content-Range header field with an
706   <x:ref>unsatisfied-range</x:ref> value, as in the following example:
707</t>
708<figure><artwork type="example">
709  Content-Range: bytes */1234
710</artwork></figure>
711<t>
712   The complete-length in a 416 response indicates the current length of the
713   selected representation.
714</t>
715<t>
716   The "Content-Range" header field has no meaning for status codes that do
717   not explicitly describe its semantic. For this specification, only the
718   <x:ref>206 (Partial Content)</x:ref> and
719   <x:ref>416 (Range Not Satisfiable)</x:ref> status codes describe a meaning
720   for Content-Range.
721</t>
722<t>
723   The following are examples of Content-Range values in which the
724   selected representation contains a total of 1234 bytes:
725   <list style="symbols">
726      <t>
727        The first 500 bytes:
728<figure><artwork type="example" x:indent-with="   ">
729  Content-Range: bytes 0-499/1234
730</artwork></figure>
731      </t>   
732      <t>
733        The second 500 bytes:
734<figure><artwork type="example" x:indent-with="   ">
735  Content-Range: bytes 500-999/1234
736</artwork></figure>
737      </t>   
738      <t>
739        All except for the first 500 bytes:
740<figure><artwork type="example" x:indent-with="   ">
741  Content-Range: bytes 500-1233/1234
742</artwork></figure>
743      </t>   
744      <t>
745        The last 500 bytes:
746<figure><artwork type="example" x:indent-with="   ">
747  Content-Range: bytes 734-1233/1234
748</artwork></figure>
749      </t>   
750   </list>
751</t>
752</section>
753
754<section title="Combining Ranges" anchor="combining.byte.ranges">
755<t>
756   A response might transfer only a subrange of a representation if the
757   connection closed prematurely or if the request used one or more Range
758   specifications.  After several such transfers, a client might have
759   received several ranges of the same representation.  These ranges can only
760   be safely combined if they all have in common the same strong validator
761   (&weak-and-strong-validators;).
762</t>
763<t>
764   A client that has received multiple partial responses to GET requests on a
765   target resource &MAY; combine those responses into a larger continuous
766   range if they share the same strong validator.
767</t>
768<t>
769   If the most recent response is an incomplete <x:ref>200 (OK)</x:ref>
770   response, then the header fields of that response are used for any
771   combined response and replace those of the matching stored responses.
772</t>
773<t>
774   If the most recent response is a <x:ref>206 (Partial Content)</x:ref>
775   response and at least one of the matching stored responses is a
776   <x:ref>200 (OK)</x:ref>, then the combined response header fields consist
777   of the most recent 200 response's header fields. If all of the matching
778   stored responses are 206 responses, then the stored response with the most
779   recent header fields is used as the source of header fields for the
780   combined response, except that the client &MUST; use other header fields
781   provided in the new response, aside from <x:ref>Content-Range</x:ref>, to
782   replace all instances of the corresponding header fields in the stored
783   response.
784</t>
785<t>
786   The combined response message body consists of the union of partial
787   content ranges in the new response and each of the selected responses.
788   If the union consists of the entire range of the representation, then the
789   client &MUST; process the combined response as if it were a complete
790   <x:ref>200 (OK)</x:ref> response, including a <x:ref>Content-Length</x:ref>
791   header field that reflects the complete length.
792   Otherwise, the client &MUST; process the set of continuous ranges as one of
793   the following:
794   an incomplete <x:ref>200 (OK)</x:ref> response if the combined response is
795   a prefix of the representation,
796   a single <x:ref>206 (Partial Content)</x:ref> response containing a
797   multipart/byteranges body, or
798   multiple <x:ref>206 (Partial Content)</x:ref> responses, each with one
799   continuous range that is indicated by a <x:ref>Content-Range</x:ref> header
800   field.
801</t>
802</section>
803
804<section title="416 Range Not Satisfiable" anchor="status.416">
805  <iref primary="true" item="416 Range Not Satisfiable (status code)" x:for-anchor=""/>
806  <x:anchor-alias value="416 (Range Not Satisfiable)"/>
807<t>
808   The <x:dfn>416 (Range Not Satisfiable)</x:dfn> status code indicates that
809   none of the ranges in the request's <x:ref>Range</x:ref> header field
810   (<xref target="header.range"/>) overlap the current extent of the selected
811   resource or that the set of ranges requested has been rejected due to
812   invalid ranges or an excessive request of small or overlapping ranges.
813</t>
814<t>
815   For byte ranges, failing to overlap the current extent means that the
816   <x:ref>first-byte-pos</x:ref> of all of the <x:ref>byte-range-spec</x:ref>
817   values were greater than the current length of the selected representation.
818   When this status code is generated in response to a byte range request, the
819   sender &SHOULD; generate a <x:ref>Content-Range</x:ref> header field
820   specifying the current length of the selected representation
821   (<xref target="header.content-range"/>).
822</t>
823<figure>
824<preamble>For example:</preamble>
825<artwork type="message/http; msgtype=&#34;response&#34;" x:indent-with="  ">
826HTTP/1.1 416 Range Not Satisfiable
827Date: Fri, 20 Jan 2012 15:41:54 GMT
828Content-Range: bytes */47022
829</artwork></figure>
830<x:note>
831  <t>
832    &Note; Because servers are free to ignore <x:ref>Range</x:ref>, many
833    implementations will simply respond with the entire selected representation
834    in a <x:ref>200 (OK)</x:ref> response. That is partly because
835    most clients are prepared to receive a <x:ref>200 (OK)</x:ref> to
836    complete the task (albeit less efficiently) and partly because clients
837    might not stop making an invalid partial request until they have received
838    a complete representation. Thus, clients cannot depend on receiving a
839    <x:ref>416 (Range Not Satisfiable)</x:ref> response even when it is most
840    appropriate.
841  </t>
842</x:note>
843</section>
844</section>
845
846<section title="IANA Considerations" anchor="IANA.considerations">
847
848<section title="Range Unit Registry" anchor="range.unit.registry">
849<t>
850   The HTTP Range Unit Registry defines the name space for the range
851   unit names and refers to their corresponding specifications.
852   The registry will be created and maintained at (the suggested URI)
853   <eref target="http://www.iana.org/assignments/http-parameters"/>.
854</t>
855
856<section title="Procedure" anchor="range.unit.registry.procedure">
857<t>
858   Registration of an HTTP Range Unit &MUST; include the following fields:
859   <list style="symbols">
860     <t>Name</t>
861     <t>Description</t>
862     <t>Pointer to specification text</t>
863   </list>
864</t>
865<t>
866  Values to be added to this name space require IETF Review
867  (see <xref target="RFC5226" x:fmt="," x:sec="4.1"/>).
868</t>
869</section>
870
871<section title="Registrations" anchor="range.unit.registration">
872<t>
873   The initial HTTP Range Unit Registry shall contain the registrations
874   below:
875</t>
876<texttable align="left" suppress-title="true" anchor="iana.range.units.table">
877   <ttcol>Range Unit Name</ttcol>
878   <ttcol>Description</ttcol>
879   <ttcol>Reference</ttcol>
880
881   <c>bytes</c>
882   <c>a range of octets</c>
883   <c><xref target="byte.ranges"/></c>
884
885   <c>none</c>
886   <c>reserved as keyword, indicating no ranges are supported</c>
887   <c><xref target="header.accept-ranges"/></c>
888</texttable>
889<t>
890   The change controller is: "IETF (iesg@ietf.org) - Internet Engineering Task Force".
891</t>
892</section>
893</section>
894
895<section title="Status Code Registration" anchor="status.code.registration">
896<t>
897   The HTTP Status Code Registry located at <eref target="http://www.iana.org/assignments/http-status-codes"/>
898   shall be updated with the registrations below:
899</t>
900<?BEGININC p5-range.iana-status-codes ?>
901<!--AUTOGENERATED FROM extract-status-code-defs.xslt, do not edit manually-->
902<texttable align="left" suppress-title="true" anchor="iana.status.code.registration.table">
903   <ttcol>Value</ttcol>
904   <ttcol>Description</ttcol>
905   <ttcol>Reference</ttcol>
906   <c>206</c>
907   <c>Partial Content</c>
908   <c>
909      <xref target="status.206"/>
910   </c>
911   <c>416</c>
912   <c>Range Not Satisfiable</c>
913   <c>
914      <xref target="status.416"/>
915   </c>
916</texttable>
917<!--(END)-->
918<?ENDINC p5-range.iana-status-codes ?>
919</section>
920
921<section title="Header Field Registration" anchor="header.field.registration">
922<t>
923   HTTP header fields are registered within the Message Header Field Registry
924   maintained at
925   <eref target="http://www.iana.org/assignments/message-headers/message-header-index.html"/>.
926</t>
927<t>
928   This document defines the following HTTP header fields, so their
929   associated registry entries shall be updated according to the permanent
930   registrations below (see <xref target="BCP90"/>):
931</t>
932<?BEGININC p5-range.iana-headers ?>
933<!--AUTOGENERATED FROM extract-header-defs.xslt, do not edit manually-->
934<texttable align="left" suppress-title="true" anchor="iana.header.registration.table">
935   <ttcol>Header Field Name</ttcol>
936   <ttcol>Protocol</ttcol>
937   <ttcol>Status</ttcol>
938   <ttcol>Reference</ttcol>
939
940   <c>Accept-Ranges</c>
941   <c>http</c>
942   <c>standard</c>
943   <c>
944      <xref target="header.accept-ranges"/>
945   </c>
946   <c>Content-Range</c>
947   <c>http</c>
948   <c>standard</c>
949   <c>
950      <xref target="header.content-range"/>
951   </c>
952   <c>If-Range</c>
953   <c>http</c>
954   <c>standard</c>
955   <c>
956      <xref target="header.if-range"/>
957   </c>
958   <c>Range</c>
959   <c>http</c>
960   <c>standard</c>
961   <c>
962      <xref target="header.range"/>
963   </c>
964</texttable>
965<!--(END)-->
966<?ENDINC p5-range.iana-headers ?>
967<t>
968   The change controller is: "IETF (iesg@ietf.org) - Internet Engineering Task Force".
969</t>
970</section>
971
972<section title="Internet Media Type Registration" anchor="internet.media.type.http">
973<t>
974   IANA maintains the registry of Internet media types <xref target="BCP13"/> at
975   <eref target="http://www.iana.org/assignments/media-types"/>.
976</t>
977<t>
978   This document serves as the specification for the Internet media type
979   "multipart/byteranges". The following is to be registered with
980   IANA.
981</t>
982<section title="Internet Media Type multipart/byteranges" anchor="internet.media.type.multipart.byteranges.reg">
983<iref item="Media Type" subitem="multipart/byteranges" primary="true"/>
984<iref item="multipart/byteranges Media Type" primary="true"/>
985<t>
986  <list style="hanging" x:indent="12em">
987    <t hangText="Type name:">
988      multipart
989    </t>
990    <t hangText="Subtype name:">
991      byteranges
992    </t>
993    <t hangText="Required parameters:">
994      boundary
995    </t>
996    <t hangText="Optional parameters:">
997      N/A
998    </t>
999    <t hangText="Encoding considerations:">
1000      only "7bit", "8bit", or "binary" are permitted
1001    </t>
1002    <t hangText="Security considerations:">
1003      see <xref target="security.considerations"/>
1004    </t>
1005    <t hangText="Interoperability considerations:">
1006      N/A
1007    </t>
1008    <t hangText="Published specification:">
1009      This specification (see <xref target="internet.media.type.multipart.byteranges"/>).
1010    </t>
1011    <t hangText="Applications that use this media type:">
1012      HTTP components supporting multiple ranges in a single request.
1013    </t>
1014    <t hangText="Fragment identifier considerations:">
1015      N/A
1016    </t>
1017    <t hangText="Additional information:">
1018      <list style="hanging">
1019        <t hangText="Deprecated alias names for this type:">N/A</t>
1020        <t hangText="Magic number(s):">N/A</t>
1021        <t hangText="File extension(s):">N/A</t>
1022        <t hangText="Macintosh file type code(s):">N/A</t>
1023      </list>
1024    </t>
1025    <t hangText="Person and email address to contact for further information:">
1026      See Authors Section.
1027    </t>
1028    <t hangText="Intended usage:">
1029      COMMON
1030    </t>
1031    <t hangText="Restrictions on usage:">
1032      N/A
1033    </t>
1034    <t hangText="Author:">
1035      See Authors Section.
1036    </t>
1037    <t hangText="Change controller:">
1038      IESG
1039    </t>
1040  </list>
1041</t>
1042</section>
1043</section>
1044
1045</section>
1046
1047<section title="Security Considerations" anchor="security.considerations">
1048<t>
1049   This section is meant to inform developers, information providers, and
1050   users of known security concerns specific to the HTTP/1.1 range
1051   request mechanisms. More general security considerations are addressed
1052   in HTTP messaging &messaging; and semantics &semantics;.
1053</t>
1054<t>
1055   The list of considerations below is not exhaustive &mdash; security
1056   analysis in an ongoing activity. Various organizations, such as the
1057   "Open Web Application Security Project" (OWASP,
1058   <eref target="https://www.owasp.org/"/>), provide information about current
1059   research.
1060</t>
1061
1062<section title="Denial of Service Attacks using Range" anchor="overlapping.ranges">
1063<t>
1064   Unconstrained multiple range requests are susceptible to denial of service
1065   attacks because the effort required to request many overlapping ranges of
1066   the same data is tiny compared to the time, memory, and bandwidth consumed
1067   by attempting to serve the requested data in many parts.
1068   Servers ought to ignore, coalesce, or reject egregious range requests, such
1069   as requests for more than two overlapping ranges or for many small ranges
1070   in a single set, particularly when the ranges are requested out of order
1071   for no apparent reason. Multipart range requests are not designed to
1072   support random access.
1073</t>
1074</section>
1075</section>
1076
1077<section title="Acknowledgments" anchor="acks">
1078<t>
1079  See &acks;.
1080</t>
1081</section>
1082</middle>
1083<back>
1084
1085<references title="Normative References">
1086
1087<reference anchor="Part1">
1088  <front>
1089    <title>Hypertext Transfer Protocol (HTTP/1.1): Message Syntax and Routing</title>
1090    <author initials="R." surname="Fielding" fullname="Roy T. Fielding" role="editor">
1091      <organization abbrev="Adobe">Adobe Systems Incorporated</organization>
1092      <address><email>fielding@gbiv.com</email></address>
1093    </author>
1094    <author initials="J. F." surname="Reschke" fullname="Julian F. Reschke" role="editor">
1095      <organization abbrev="greenbytes">greenbytes GmbH</organization>
1096      <address><email>julian.reschke@greenbytes.de</email></address>
1097    </author>
1098    <date month="&ID-MONTH;" year="&ID-YEAR;"/>
1099  </front>
1100  <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-p1-messaging-&ID-VERSION;"/>
1101  <x:source href="p1-messaging.xml" basename="p1-messaging">
1102    <x:defines>Content-Length</x:defines>
1103  </x:source>
1104</reference>
1105
1106<reference anchor="Part2">
1107  <front>
1108    <title>Hypertext Transfer Protocol (HTTP/1.1): Semantics and Content</title>
1109    <author initials="R." surname="Fielding" fullname="Roy T. Fielding" role="editor">
1110      <organization abbrev="Adobe">Adobe Systems Incorporated</organization>
1111      <address><email>fielding@gbiv.com</email></address>
1112    </author>
1113    <author initials="J. F." surname="Reschke" fullname="Julian F. Reschke" role="editor">
1114      <organization abbrev="greenbytes">greenbytes GmbH</organization>
1115      <address><email>julian.reschke@greenbytes.de</email></address>
1116    </author>
1117    <date month="&ID-MONTH;" year="&ID-YEAR;"/>
1118  </front>
1119  <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-p2-semantics-&ID-VERSION;"/>
1120  <x:source href="p2-semantics.xml" basename="p2-semantics">
1121    <x:defines>200 (OK)</x:defines>
1122    <x:defines>410 (Gone)</x:defines>
1123    <x:defines>Content-Location</x:defines>
1124    <x:defines>Content-Type</x:defines>
1125    <x:defines>Date</x:defines>
1126    <x:defines>Location</x:defines>
1127    <x:defines>Vary</x:defines>
1128  </x:source>
1129</reference>
1130
1131<reference anchor="Part4">
1132  <front>
1133    <title>Hypertext Transfer Protocol (HTTP/1.1): Conditional Requests</title>
1134    <author initials="R." surname="Fielding" fullname="Roy T. Fielding" role="editor">
1135      <organization abbrev="Adobe">Adobe Systems Incorporated</organization>
1136      <address><email>fielding@gbiv.com</email></address>
1137    </author>
1138    <author initials="J. F." surname="Reschke" fullname="Julian F. Reschke" role="editor">
1139      <organization abbrev="greenbytes">greenbytes GmbH</organization>
1140      <address><email>julian.reschke@greenbytes.de</email></address>
1141    </author>
1142    <date month="&ID-MONTH;" year="&ID-YEAR;"/>
1143  </front>
1144  <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-p4-conditional-&ID-VERSION;"/>
1145  <x:source href="p4-conditional.xml" basename="p4-conditional">
1146    <x:defines>304 (Not Modified)</x:defines>
1147    <x:defines>ETag</x:defines>
1148    <x:defines>If-Match</x:defines>
1149    <x:defines>If-Modified-Since</x:defines>
1150    <x:defines>If-None-Match</x:defines>
1151    <x:defines>If-Unmodified-Since</x:defines>
1152    <x:defines>Last-Modified</x:defines>
1153  </x:source>
1154</reference>
1155
1156<reference anchor="Part6">
1157  <front>
1158    <title>Hypertext Transfer Protocol (HTTP/1.1): Caching</title>
1159    <author initials="R." surname="Fielding" fullname="Roy T. Fielding" role="editor">
1160      <organization abbrev="Adobe">Adobe Systems Incorporated</organization>
1161      <address><email>fielding@gbiv.com</email></address>
1162    </author>
1163    <author initials="M." surname="Nottingham" fullname="Mark Nottingham" role="editor">
1164      <organization>Akamai</organization>
1165      <address><email>mnot@mnot.net</email></address>
1166    </author>
1167    <author initials="J. F." surname="Reschke" fullname="Julian F. Reschke" role="editor">
1168      <organization abbrev="greenbytes">greenbytes GmbH</organization>
1169      <address><email>julian.reschke@greenbytes.de</email></address>
1170    </author>
1171    <date month="&ID-MONTH;" year="&ID-YEAR;"/>
1172  </front>
1173  <seriesInfo name="Internet-Draft" value="draft-ietf-httpbis-p6-cache-&ID-VERSION;"/>
1174  <x:source href="p6-cache.xml" basename="p6-cache">
1175    <x:defines>Cache-Control</x:defines>
1176    <x:defines>Expires</x:defines>
1177  </x:source>
1178</reference>
1179
1180<reference anchor="RFC2046">
1181  <front>
1182    <title abbrev="Media Types">Multipurpose Internet Mail Extensions (MIME) Part Two: Media Types</title>
1183    <author initials="N." surname="Freed" fullname="Ned Freed">
1184      <organization>Innosoft International, Inc.</organization>
1185      <address><email>ned@innosoft.com</email></address>
1186    </author>
1187    <author initials="N." surname="Borenstein" fullname="Nathaniel S. Borenstein">
1188      <organization>First Virtual Holdings</organization>
1189      <address><email>nsb@nsb.fv.com</email></address>
1190    </author>
1191    <date month="November" year="1996"/>
1192  </front>
1193  <seriesInfo name="RFC" value="2046"/>
1194</reference>
1195
1196<reference anchor="RFC2119">
1197  <front>
1198    <title>Key words for use in RFCs to Indicate Requirement Levels</title>
1199    <author initials="S." surname="Bradner" fullname="Scott Bradner">
1200      <organization>Harvard University</organization>
1201      <address><email>sob@harvard.edu</email></address>
1202    </author>
1203    <date month="March" year="1997"/>
1204  </front>
1205  <seriesInfo name="BCP" value="14"/>
1206  <seriesInfo name="RFC" value="2119"/>
1207</reference>
1208
1209<reference anchor="RFC5234">
1210  <front>
1211    <title abbrev="ABNF for Syntax Specifications">Augmented BNF for Syntax Specifications: ABNF</title>
1212    <author initials="D." surname="Crocker" fullname="Dave Crocker" role="editor">
1213      <organization>Brandenburg InternetWorking</organization>
1214      <address>
1215        <email>dcrocker@bbiw.net</email>
1216      </address> 
1217    </author>
1218    <author initials="P." surname="Overell" fullname="Paul Overell">
1219      <organization>THUS plc.</organization>
1220      <address>
1221        <email>paul.overell@thus.net</email>
1222      </address>
1223    </author>
1224    <date month="January" year="2008"/>
1225  </front>
1226  <seriesInfo name="STD" value="68"/>
1227  <seriesInfo name="RFC" value="5234"/>
1228</reference>
1229
1230</references>
1231
1232<references title="Informative References">
1233
1234<reference anchor="RFC2616">
1235  <front>
1236    <title>Hypertext Transfer Protocol -- HTTP/1.1</title>
1237    <author initials="R." surname="Fielding" fullname="R. Fielding">
1238      <organization>University of California, Irvine</organization>
1239      <address><email>fielding@ics.uci.edu</email></address>
1240    </author>
1241    <author initials="J." surname="Gettys" fullname="J. Gettys">
1242      <organization>W3C</organization>
1243      <address><email>jg@w3.org</email></address>
1244    </author>
1245    <author initials="J." surname="Mogul" fullname="J. Mogul">
1246      <organization>Compaq Computer Corporation</organization>
1247      <address><email>mogul@wrl.dec.com</email></address>
1248    </author>
1249    <author initials="H." surname="Frystyk" fullname="H. Frystyk">
1250      <organization>MIT Laboratory for Computer Science</organization>
1251      <address><email>frystyk@w3.org</email></address>
1252    </author>
1253    <author initials="L." surname="Masinter" fullname="L. Masinter">
1254      <organization>Xerox Corporation</organization>
1255      <address><email>masinter@parc.xerox.com</email></address>
1256    </author>
1257    <author initials="P." surname="Leach" fullname="P. Leach">
1258      <organization>Microsoft Corporation</organization>
1259      <address><email>paulle@microsoft.com</email></address>
1260    </author>
1261    <author initials="T." surname="Berners-Lee" fullname="T. Berners-Lee">
1262      <organization>W3C</organization>
1263      <address><email>timbl@w3.org</email></address>
1264    </author>
1265    <date month="June" year="1999"/>
1266  </front>
1267  <seriesInfo name="RFC" value="2616"/>
1268</reference>
1269
1270<reference anchor='BCP90'>
1271  <front>
1272    <title>Registration Procedures for Message Header Fields</title>
1273    <author initials='G.' surname='Klyne' fullname='G. Klyne'>
1274      <organization>Nine by Nine</organization>
1275      <address><email>GK-IETF@ninebynine.org</email></address>
1276    </author>
1277    <author initials='M.' surname='Nottingham' fullname='M. Nottingham'>
1278      <organization>BEA Systems</organization>
1279      <address><email>mnot@pobox.com</email></address>
1280    </author>
1281    <author initials='J.' surname='Mogul' fullname='J. Mogul'>
1282      <organization>HP Labs</organization>
1283      <address><email>JeffMogul@acm.org</email></address>
1284    </author>
1285    <date year='2004' month='September' />
1286  </front>
1287  <seriesInfo name='BCP' value='90' />
1288  <seriesInfo name='RFC' value='3864' />
1289</reference>
1290
1291<reference anchor="BCP13">
1292  <front>
1293    <title>Media Type Specifications and Registration Procedures</title>
1294    <author initials="N." surname="Freed" fullname="Ned Freed">
1295      <organization>Oracle</organization>
1296      <address>
1297        <email>ned+ietf@mrochek.com</email>
1298      </address>
1299    </author>
1300    <author initials="J." surname="Klensin" fullname="John C. Klensin">
1301      <address>
1302        <email>john+ietf@jck.com</email>
1303      </address>
1304    </author>
1305    <author initials="T." surname="Hansen" fullname="Tony Hansen">
1306      <organization>AT&amp;T Laboratories</organization>
1307      <address>
1308        <email>tony+mtsuffix@maillennium.att.com</email>
1309      </address>
1310    </author>
1311    <date year="2013" month="January"/>
1312  </front>
1313  <seriesInfo name="BCP" value="13"/>
1314  <seriesInfo name="RFC" value="6838"/>
1315</reference>
1316
1317<reference anchor='RFC5226'>
1318  <front>
1319    <title>Guidelines for Writing an IANA Considerations Section in RFCs</title>
1320    <author initials='T.' surname='Narten' fullname='T. Narten'>
1321      <organization>IBM</organization>
1322      <address><email>narten@us.ibm.com</email></address>
1323    </author>
1324    <author initials='H.' surname='Alvestrand' fullname='H. Alvestrand'>
1325      <organization>Google</organization>
1326      <address><email>Harald@Alvestrand.no</email></address>
1327    </author>
1328    <date year='2008' month='May' />
1329  </front>
1330  <seriesInfo name='BCP' value='26' />
1331  <seriesInfo name='RFC' value='5226' />
1332</reference>
1333
1334</references>
1335
1336<section title="Internet Media Type multipart/byteranges" anchor="internet.media.type.multipart.byteranges">
1337<iref item="Media Type" subitem="multipart/byteranges" primary="true"/>
1338<iref item="multipart/byteranges Media Type" primary="true"/>
1339<t>
1340   When a <x:ref>206 (Partial Content)</x:ref> response message includes the
1341   content of multiple ranges, they are transmitted as body parts in a
1342   multipart message body (<xref target="RFC2046" x:fmt="," x:sec="5.1"/>)
1343   with the media type of "multipart/byteranges".
1344</t>
1345<t>
1346   The multipart/byteranges media type includes one or more body parts, each
1347   with its own <x:ref>Content-Type</x:ref> and <x:ref>Content-Range</x:ref>
1348   fields. The required boundary parameter specifies the boundary string used
1349   to separate each body part.
1350</t>
1351<t>
1352  Implementation Notes:
1353  <list style="numbers">
1354      <t>Additional CRLFs might precede the first boundary string in the body.</t>
1355
1356      <t>Although <xref target="RFC2046"/> permits the boundary string to be
1357         quoted, some existing implementations handle a quoted boundary
1358         string incorrectly.</t>
1359
1360      <t>A number of clients and servers were coded to an early draft
1361         of the byteranges specification that used a media type of
1362         multipart/x-byteranges<iref item="multipart/x-byteranges Media Type"/><iref item="Media Type" subitem="multipart/x-byteranges"/>,
1363         which is almost (but not quite) compatible with this type.</t>
1364  </list>
1365</t>
1366<t>
1367   Despite the name, the "multipart/byteranges" media type is not limited to
1368   byte ranges. The following example uses an "exampleunit" range unit:
1369</t>
1370<figure><artwork type="message/http; msgtype=&#34;response&#34;" x:indent-with="  ">
1371HTTP/1.1 206 Partial Content
1372Date: Tue, 14 Nov 1995 06:25:24 GMT
1373Last-Modified: Tue, 14 July 04:58:08 GMT
1374Content-Length: 2331785
1375Content-Type: multipart/byteranges; boundary=THIS_STRING_SEPARATES
1376
1377--THIS_STRING_SEPARATES
1378Content-Type: video/example
1379Content-Range: exampleunit 1.2-4.3/25
1380
1381...the first range...
1382--THIS_STRING_SEPARATES
1383Content-Type: video/example
1384Content-Range: exampleunit 11.2-14.3/25
1385
1386...the second range
1387--THIS_STRING_SEPARATES--
1388</artwork>
1389</figure>
1390</section>
1391
1392<section title="Changes from RFC 2616" anchor="changes.from.rfc.2616">
1393<t>
1394  Servers are given more leeway in how they respond to a range request,
1395  in order to mitigate abuse by malicious (or just greedy) clients.
1396  (<xref target="header.range"/>)
1397</t>
1398<t>
1399  A weak validator cannot be used in a <x:ref>206</x:ref> response.
1400  (<xref target="status.206"/>)
1401</t>
1402<t>
1403  The Content-Range header field only has meaning when the status code
1404  explicitly defines its use.
1405  (<xref target="header.content-range" />)
1406</t>
1407<t>
1408  This specification introduces a Range Unit Registry.
1409  (<xref target="range.unit.registry"/>)
1410</t>
1411<t>
1412  multipart/byteranges can consist of a single part.
1413  (<xref target="internet.media.type.multipart.byteranges"/>)
1414</t>
1415</section>
1416
1417<section title="Imported ABNF" anchor="imported.abnf">
1418  <x:anchor-alias value="ALPHA"/>
1419  <x:anchor-alias value="CHAR"/>
1420  <x:anchor-alias value="CR"/>
1421  <x:anchor-alias value="DIGIT"/>
1422  <x:anchor-alias value="LF"/>
1423  <x:anchor-alias value="OCTET"/>
1424  <x:anchor-alias value="SP"/>
1425  <x:anchor-alias value="VCHAR"/>
1426  <x:anchor-alias value="token"/>
1427  <x:anchor-alias value="OWS"/>
1428  <x:anchor-alias value="HTTP-date"/>
1429  <x:anchor-alias value="entity-tag"/>
1430<t>
1431  The following core rules are included by
1432  reference, as defined in <xref target="RFC5234" x:fmt="of" x:sec="B.1"/>:
1433  ALPHA (letters), CR (carriage return), CRLF (CR LF), CTL (controls),
1434  DIGIT (decimal 0-9), DQUOTE (double quote),
1435  HEXDIG (hexadecimal 0-9/A-F/a-f), LF (line feed),
1436  OCTET (any 8-bit sequence of data), SP (space), and
1437  VCHAR (any visible US-ASCII character).
1438</t>
1439<t>
1440  Note that all rules derived from <x:ref>token</x:ref> are to
1441  be compared case-insensitively, like <x:ref>range-unit</x:ref> and
1442  <x:ref>acceptable-ranges</x:ref>.
1443</t>
1444<t>
1445  The rules below are defined in <xref target="Part1"/>:
1446</t>
1447<figure><artwork type="abnf2616">
1448  <x:ref>OWS</x:ref>        = &lt;OWS, defined in &whitespace;&gt;
1449  <x:ref>token</x:ref>      = &lt;token, defined in &field-components;&gt;
1450</artwork></figure>
1451<t>
1452  The rules below are defined in other parts:
1453</t>
1454<figure><artwork type="abnf2616">
1455  <x:ref>HTTP-date</x:ref>  = &lt;HTTP-date, defined in &http-date;&gt;
1456  <x:ref>entity-tag</x:ref> = &lt;entity-tag, defined in &entity-tags;&gt;
1457</artwork></figure>
1458</section>
1459
1460<?BEGININC p5-range.abnf-appendix ?>
1461<section xmlns:x="http://purl.org/net/xml2rfc/ext" title="Collected ABNF" anchor="collected.abnf">
1462<t>
1463  In the collected ABNF below, list rules are expanded as per <xref target="Part1" x:rel="#notation"/>.
1464</t><figure>
1465<artwork type="abnf" name="p5-range.parsed-abnf">
1466<x:ref>Accept-Ranges</x:ref> = acceptable-ranges
1467
1468<x:ref>Content-Range</x:ref> = byte-content-range / other-content-range
1469
1470<x:ref>HTTP-date</x:ref> = &lt;HTTP-date, defined in [Part2], Section 7.1.1.1&gt;
1471
1472<x:ref>If-Range</x:ref> = entity-tag / HTTP-date
1473
1474<x:ref>OWS</x:ref> = &lt;OWS, defined in [Part1], Section 3.2.3&gt;
1475
1476<x:ref>Range</x:ref> = byte-ranges-specifier / other-ranges-specifier
1477
1478<x:ref>acceptable-ranges</x:ref> = ( *( "," OWS ) range-unit *( OWS "," [ OWS
1479 range-unit ] ) ) / "none"
1480
1481<x:ref>byte-content-range</x:ref> = bytes-unit SP ( byte-range-resp /
1482 unsatisfied-range )
1483<x:ref>byte-range</x:ref> = first-byte-pos "-" last-byte-pos
1484<x:ref>byte-range-resp</x:ref> = byte-range "/" ( complete-length / "*" )
1485<x:ref>byte-range-set</x:ref> = *( "," OWS ) ( byte-range-spec /
1486 suffix-byte-range-spec ) *( OWS "," [ OWS ( byte-range-spec /
1487 suffix-byte-range-spec ) ] )
1488<x:ref>byte-range-spec</x:ref> = first-byte-pos "-" [ last-byte-pos ]
1489<x:ref>byte-ranges-specifier</x:ref> = bytes-unit "=" byte-range-set
1490<x:ref>bytes-unit</x:ref> = "bytes"
1491
1492<x:ref>complete-length</x:ref> = 1*DIGIT
1493
1494<x:ref>entity-tag</x:ref> = &lt;entity-tag, defined in [Part4], Section 2.3&gt;
1495
1496<x:ref>first-byte-pos</x:ref> = 1*DIGIT
1497
1498<x:ref>last-byte-pos</x:ref> = 1*DIGIT
1499
1500<x:ref>other-content-range</x:ref> = other-range-unit SP other-range-resp
1501<x:ref>other-range-resp</x:ref> = *CHAR
1502<x:ref>other-range-set</x:ref> = 1*VCHAR
1503<x:ref>other-range-unit</x:ref> = token
1504<x:ref>other-ranges-specifier</x:ref> = other-range-unit "=" other-range-set
1505
1506<x:ref>range-unit</x:ref> = bytes-unit / other-range-unit
1507
1508<x:ref>suffix-byte-range-spec</x:ref> = "-" suffix-length
1509<x:ref>suffix-length</x:ref> = 1*DIGIT
1510
1511<x:ref>token</x:ref> = &lt;token, defined in [Part1], Section 3.2.6&gt;
1512
1513<x:ref>unsatisfied-range</x:ref> = "*/" complete-length
1514</artwork>
1515</figure>
1516</section>
1517<?ENDINC p5-range.abnf-appendix ?>
1518
1519
1520<section title="Change Log (to be removed by RFC Editor before publication)" anchor="change.log">
1521<t>
1522  Changes up to the IETF Last Call draft are summarized
1523  in <eref target="http://tools.ietf.org/html/draft-ietf-httpbis-p5-range-24#appendix-E"/>.
1524</t>
1525
1526<section title="Since draft-ietf-httpbis-p5-range-24" anchor="changes.since.24">
1527<t>
1528  Closed issues:
1529  <list style="symbols">
1530    <t>
1531      <eref target="http://tools.ietf.org/wg/httpbis/trac/ticket/506"/>:
1532      "APPSDIR review of draft-ietf-httpbis-p5-range-24"
1533    </t>
1534    <t>
1535      <eref target="http://tools.ietf.org/wg/httpbis/trac/ticket/507"/>:
1536      "integer value parsing"
1537    </t>
1538    <t>
1539      <eref target="http://tools.ietf.org/wg/httpbis/trac/ticket/508"/>:
1540      "broken sentence in description of 206"
1541    </t>
1542  </list>
1543</t>
1544</section>
1545
1546<section title="Since draft-ietf-httpbis-p5-range-25" anchor="changes.since.25">
1547<t>
1548  Closed issues:
1549  <list style="symbols">
1550    <t>
1551      <eref target="http://tools.ietf.org/wg/httpbis/trac/ticket/526"/>:
1552      "check media type registration templates"
1553    </t>
1554    <t>
1555      <eref target="http://tools.ietf.org/wg/httpbis/trac/ticket/527"/>:
1556      "use of CHAR for other-range-set"
1557    </t>
1558    <t>
1559      <eref target="http://tools.ietf.org/wg/httpbis/trac/ticket/538"/>:
1560      "add 'stateless' to Abstract"
1561    </t>
1562    <t>
1563      <eref target="http://tools.ietf.org/wg/httpbis/trac/ticket/542"/>:
1564      "improve introduction of list rule"
1565    </t>
1566    <t>
1567      <eref target="http://tools.ietf.org/wg/httpbis/trac/ticket/549"/>:
1568      "augment security considerations with pointers to current research"
1569    </t>
1570  </list>
1571</t>
1572</section>
1573</section>
1574
1575</back>
1576</rfc>
Note: See TracBrowser for help on using the repository browser.