Changeset 2140 for draft-ietf-httpbis/latest
- Timestamp:
- 20/01/13 14:20:32 (10 years ago)
- Location:
- draft-ietf-httpbis/latest
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
draft-ietf-httpbis/latest/p5-range.html
r2139 r2140 576 576 </ul> 577 577 </li> 578 <li><a href="#rfc.section.2">2.</a> <a href="#range.units">Range Units</a></li> 578 <li><a href="#rfc.section.2">2.</a> <a href="#range.units">Range Units</a><ul> 579 <li><a href="#rfc.section.2.1">2.1</a> <a href="#byte.ranges">Byte Ranges</a></li> 580 <li><a href="#rfc.section.2.2">2.2</a> <a href="#range.units.other">Other Range Units</a></li> 581 </ul> 582 </li> 579 583 <li><a href="#rfc.section.3">3.</a> <a href="#status.code.definitions">Status Code Definitions</a><ul> 580 584 <li><a href="#rfc.section.3.1">3.1</a> <a href="#status.206">206 Partial Content</a></li> … … 592 596 <li><a href="#rfc.section.5.3">5.3</a> <a href="#header.if-range">If-Range</a></li> 593 597 <li><a href="#rfc.section.5.4">5.4</a> <a href="#header.range">Range</a><ul> 594 <li><a href="#rfc.section.5.4.1">5.4.1</a> <a href="#byte.ranges">Byte Ranges</a></li> 595 <li><a href="#rfc.section.5.4.2">5.4.2</a> <a href="#range.retrieval.requests">Range Retrieval Requests</a></li> 598 <li><a href="#rfc.section.5.4.1">5.4.1</a> <a href="#range.retrieval.requests">Range Retrieval Requests</a></li> 596 599 </ul> 597 600 </li> … … 662 665 <a href="#range.units" class="smpl">bytes-unit</a> = "bytes" 663 666 <a href="#range.units" class="smpl">other-range-unit</a> = <a href="#imported.abnf" class="smpl">token</a> 664 </pre><p id="rfc.section.2.p.3">The only range unit defined by HTTP/1.1 is "bytes" (<a href="#byte.ranges" title="Byte Ranges">Section 5.4.1</a>). Additional units can be defined as described in <a href="#range.unit.registry" title="Range Unit Registry">Section 6.1</a>. 667 </pre><h2 id="rfc.section.2.1"><a href="#rfc.section.2.1">2.1</a> <a id="byte.ranges" href="#byte.ranges">Byte Ranges</a></h2> 668 <p id="rfc.section.2.1.p.1">Since all HTTP representations are transferred as sequences of bytes, the concept of a byte range is meaningful for any HTTP 669 representation. (However, not all clients and servers need to support byte-range operations.) 670 </p> 671 <p id="rfc.section.2.1.p.2">Byte range specifications in HTTP apply to the sequence of bytes in the representation data (not necessarily the same as the 672 message body). 673 </p> 674 <div id="rule.ranges-specifier"> 675 <p id="rfc.section.2.1.p.3"> A byte range operation <em class="bcp14">MAY</em> specify a single range of bytes, or a set of ranges within a single representation. 676 </p> 677 </div> 678 <div id="rfc.figure.u.2"></div><pre class="inline"><span id="rfc.iref.g.4"></span><span id="rfc.iref.g.5"></span><span id="rfc.iref.g.6"></span><span id="rfc.iref.g.7"></span><span id="rfc.iref.g.8"></span><span id="rfc.iref.g.9"></span> <a href="#rule.ranges-specifier" class="smpl">byte-ranges-specifier</a> = <a href="#range.units" class="smpl">bytes-unit</a> "=" <a href="#rule.ranges-specifier" class="smpl">byte-range-set</a> 679 <a href="#rule.ranges-specifier" class="smpl">byte-range-set</a> = 1#( <a href="#rule.ranges-specifier" class="smpl">byte-range-spec</a> / <a href="#rule.ranges-specifier" class="smpl">suffix-byte-range-spec</a> ) 680 <a href="#rule.ranges-specifier" class="smpl">byte-range-spec</a> = <a href="#rule.ranges-specifier" class="smpl">first-byte-pos</a> "-" [ <a href="#rule.ranges-specifier" class="smpl">last-byte-pos</a> ] 681 <a href="#rule.ranges-specifier" class="smpl">first-byte-pos</a> = 1*<a href="#imported.abnf" class="smpl">DIGIT</a> 682 <a href="#rule.ranges-specifier" class="smpl">last-byte-pos</a> = 1*<a href="#imported.abnf" class="smpl">DIGIT</a> 683 </pre><p id="rfc.section.2.1.p.5">The first-byte-pos value in a byte-range-spec gives the byte-offset of the first byte in a range. The last-byte-pos value 684 gives the byte-offset of the last byte in the range; that is, the byte positions specified are inclusive. Byte offsets start 685 at zero. 686 </p> 687 <p id="rfc.section.2.1.p.6">If the last-byte-pos value is present, it <em class="bcp14">MUST</em> be greater than or equal to the first-byte-pos in that byte-range-spec, or the byte-range-spec is syntactically invalid. The 688 recipient of a byte-range-set that includes one or more syntactically invalid byte-range-spec values <em class="bcp14">MUST</em> ignore the header field that includes that byte-range-set. 689 </p> 690 <p id="rfc.section.2.1.p.7">If the last-byte-pos value is absent, or if the value is greater than or equal to the current length of the representation 691 data, last-byte-pos is taken to be equal to one less than the current length of the representation in bytes. 692 </p> 693 <p id="rfc.section.2.1.p.8">By its choice of last-byte-pos, a client can limit the number of bytes retrieved without knowing the size of the representation.</p> 694 <div id="rfc.figure.u.3"></div><pre class="inline"><span id="rfc.iref.g.10"></span><span id="rfc.iref.g.11"></span> <a href="#rule.ranges-specifier" class="smpl">suffix-byte-range-spec</a> = "-" <a href="#rule.ranges-specifier" class="smpl">suffix-length</a> 695 <a href="#rule.ranges-specifier" class="smpl">suffix-length</a> = 1*<a href="#imported.abnf" class="smpl">DIGIT</a> 696 </pre><p id="rfc.section.2.1.p.10">A suffix-byte-range-spec is used to specify the suffix of the representation data, of a length given by the suffix-length 697 value. (That is, this form specifies the last N bytes of a representation.) If the representation is shorter than the specified 698 suffix-length, the entire representation is used. 699 </p> 700 <p id="rfc.section.2.1.p.11">If a syntactically valid byte-range-set includes at least one byte-range-spec whose first-byte-pos is less than the current 701 length of the representation, or at least one suffix-byte-range-spec with a non-zero suffix-length, then the byte-range-set 702 is satisfiable. Otherwise, the byte-range-set is unsatisfiable. If the byte-range-set is unsatisfiable, the server <em class="bcp14">SHOULD</em> send a response with a <a href="#status.416" class="smpl">416 (Range Not Satisfiable)</a> status code. Otherwise, the server <em class="bcp14">SHOULD</em> send a response with a <a href="#status.206" class="smpl">206 (Partial Content)</a> status code containing the satisfiable ranges of the representation. 703 </p> 704 <p id="rfc.section.2.1.p.12">In the byte range syntax, <a href="#rule.ranges-specifier" class="smpl">first-byte-pos</a>, <a href="#rule.ranges-specifier" class="smpl">last-byte-pos</a>, and <a href="#rule.ranges-specifier" class="smpl">suffix-length</a> are expressed as decimal number of octets. Since there is no predefined limit to the length of an HTTP payload, recipients <em class="bcp14">SHOULD</em> anticipate potentially large decimal numerals and prevent parsing errors due to integer conversion overflows. 705 </p> 706 <p id="rfc.section.2.1.p.13">Examples of byte-ranges-specifier values (assuming a representation of length 10000): </p> 707 <ul> 708 <li>The first 500 bytes (byte offsets 0-499, inclusive): 709 <div id="rfc.figure.u.4"></div><pre class="text"> bytes=0-499 710 </pre> </li> 711 <li>The second 500 bytes (byte offsets 500-999, inclusive): 712 <div id="rfc.figure.u.5"></div><pre class="text"> bytes=500-999 713 </pre> </li> 714 <li>The final 500 bytes (byte offsets 9500-9999, inclusive): 715 <div id="rfc.figure.u.6"></div><pre class="text"> bytes=-500 716 </pre> Or: <div id="rfc.figure.u.7"></div><pre class="text"> bytes=9500- 717 </pre> </li> 718 <li>The first and last bytes only (bytes 0 and 9999): 719 <div id="rfc.figure.u.8"></div><pre class="text"> bytes=0-0,-1 720 </pre> </li> 721 <li>Several legal but not canonical specifications of the second 500 bytes (byte offsets 500-999, inclusive): 722 <div id="rfc.figure.u.9"></div><pre class="text"> bytes=500-600,601-999 723 bytes=500-700,601-999 724 </pre> </li> 725 </ul> 726 <h2 id="rfc.section.2.2"><a href="#rfc.section.2.2">2.2</a> <a id="range.units.other" href="#range.units.other">Other Range Units</a></h2> 727 <p id="rfc.section.2.2.p.1">The only range unit defined by HTTP/1.1 is "bytes" (<a href="#byte.ranges" title="Byte Ranges">Section 2.1</a>). Additional units can be defined as described in <a href="#range.unit.registry" title="Range Unit Registry">Section 6.1</a>. 665 728 </p> 666 729 <h1 id="rfc.section.3"><a href="#rfc.section.3">3.</a> <a id="status.code.definitions" href="#status.code.definitions">Status Code Definitions</a></h1> 667 <div id="rfc.iref. 3"></div>730 <div id="rfc.iref.11"></div> 668 731 <h2 id="rfc.section.3.1"><a href="#rfc.section.3.1">3.1</a> <a id="status.206" href="#status.206">206 Partial Content</a></h2> 669 732 <p id="rfc.section.3.1.p.1">The <dfn>206 (Partial Content)</dfn> status code indicates that the server has fulfilled the partial GET request for the resource. The request <em class="bcp14">MUST</em> have included a <a href="#range.retrieval.requests" class="smpl">Range</a> header field (<a href="#header.range" id="rfc.xref.header.range.2" title="Range">Section 5.4</a>) indicating the desired range, and <em class="bcp14">MAY</em> have included an <a href="#header.if-range" class="smpl">If-Range</a> header field (<a href="#header.if-range" id="rfc.xref.header.if-range.1" title="If-Range">Section 5.3</a>) to make the request conditional. … … 682 745 <p id="rfc.section.3.1.p.4">Caches <em class="bcp14">MAY</em> use a heuristic (see <a href="p6-cache.html#heuristic.freshness" title="Calculating Heuristic Freshness">Section 4.1.2</a> of <a href="#Part6" id="rfc.xref.Part6.1"><cite title="Hypertext Transfer Protocol (HTTP/1.1): Caching">[Part6]</cite></a>) to determine freshness for 206 responses. 683 746 </p> 684 <div id="rfc.iref. 3"></div>747 <div id="rfc.iref.11"></div> 685 748 <h2 id="rfc.section.3.2"><a href="#rfc.section.3.2">3.2</a> <a id="status.416" href="#status.416">416 Range Not Satisfiable</a></h2> 686 749 <p id="rfc.section.3.2.p.1">The <dfn>416 (Range Not Satisfiable)</dfn> status code indicates that none of the ranges-specifier values in the request's <a href="#range.retrieval.requests" class="smpl">Range</a> header field (<a href="#header.range" id="rfc.xref.header.range.3" title="Range">Section 5.4</a>) overlap the current extent of the selected resource and the request did not include an <a href="#header.if-range" class="smpl">If-Range</a> header field (<a href="#header.if-range" id="rfc.xref.header.if-range.2" title="If-Range">Section 5.3</a>). (For byte-ranges, this means that the first-byte-pos of all of the byte-range-spec values were greater than the current … … 689 752 <p id="rfc.section.3.2.p.2">When this status code is sent in response to a byte-range request, the sender <em class="bcp14">SHOULD</em> generate a <a href="#header.content-range" class="smpl">Content-Range</a> header field specifying the current length of the selected representation (see <a href="#header.content-range" id="rfc.xref.header.content-range.3" title="Content-Range">Section 5.2</a>). 690 753 </p> 691 <div id="rfc.figure.u. 2"></div>754 <div id="rfc.figure.u.10"></div> 692 755 <p>For example:</p> <pre class="text">HTTP/1.1 416 Range Not Satisfiable 693 756 Date: Mon, 20 Jan 2012 15:41:54 GMT … … 705 768 a request for a set of ranges that overlap without any holes), this content is transmitted with a <a href="#header.content-range" class="smpl">Content-Range</a> header field, and a <a href="p1-messaging.html#header.content-length" class="smpl">Content-Length</a> header field showing the number of bytes actually transferred. For example, 706 769 </p> 707 <div id="rfc.figure.u. 3"></div><pre class="text">HTTP/1.1 206 Partial Content770 <div id="rfc.figure.u.11"></div><pre class="text">HTTP/1.1 206 Partial Content 708 771 Date: Wed, 15 Nov 1995 06:25:24 GMT 709 772 Last-Modified: Wed, 15 Nov 1995 04:58:08 GMT … … 745 808 <h2 id="rfc.section.5.1"><a href="#rfc.section.5.1">5.1</a> <a id="header.accept-ranges" href="#header.accept-ranges">Accept-Ranges</a></h2> 746 809 <p id="rfc.section.5.1.p.1">The "Accept-Ranges" header field allows a resource to indicate its acceptance of range requests.</p> 747 <div id="rfc.figure.u. 4"></div><pre class="inline"><span id="rfc.iref.g.4"></span><span id="rfc.iref.g.5"></span> <a href="#header.accept-ranges" class="smpl">Accept-Ranges</a> = <a href="#header.accept-ranges" class="smpl">acceptable-ranges</a>810 <div id="rfc.figure.u.12"></div><pre class="inline"><span id="rfc.iref.g.12"></span><span id="rfc.iref.g.13"></span> <a href="#header.accept-ranges" class="smpl">Accept-Ranges</a> = <a href="#header.accept-ranges" class="smpl">acceptable-ranges</a> 748 811 <a href="#header.accept-ranges" class="smpl">acceptable-ranges</a> = 1#<a href="#range.units" class="smpl">range-unit</a> / "none" 749 812 </pre><p id="rfc.section.5.1.p.3">Origin servers that accept byte-range requests <em class="bcp14">MAY</em> send 750 813 </p> 751 <div id="rfc.figure.u. 5"></div><pre class="text"> Accept-Ranges: bytes814 <div id="rfc.figure.u.13"></div><pre class="text"> Accept-Ranges: bytes 752 815 </pre><p id="rfc.section.5.1.p.5">but are not required to do so. Clients <em class="bcp14">MAY</em> generate range requests without having received this header field for the resource involved. Range units are defined in <a href="#range.units" title="Range Units">Section 2</a>. 753 816 </p> 754 817 <p id="rfc.section.5.1.p.6">Servers that do not accept any kind of range request for a resource <em class="bcp14">MAY</em> send 755 818 </p> 756 <div id="rfc.figure.u. 6"></div><pre class="text"> Accept-Ranges: none819 <div id="rfc.figure.u.14"></div><pre class="text"> Accept-Ranges: none 757 820 </pre><p id="rfc.section.5.1.p.8">to advise the client not to attempt a range request.</p> 758 821 <div id="rfc.iref.c.1"></div> … … 761 824 body is intended to be applied. 762 825 </p> 763 <div id="rfc.figure.u. 7"></div><pre class="inline"><span id="rfc.iref.g.6"></span><span id="rfc.iref.g.7"></span><span id="rfc.iref.g.8"></span><span id="rfc.iref.g.9"></span><span id="rfc.iref.g.10"></span><span id="rfc.iref.g.11"></span><span id="rfc.iref.g.12"></span><span id="rfc.iref.g.13"></span> <a href="#header.content-range" class="smpl">Content-Range</a> = <a href="#header.content-range" class="smpl">byte-content-range</a>826 <div id="rfc.figure.u.15"></div><pre class="inline"><span id="rfc.iref.g.14"></span><span id="rfc.iref.g.15"></span><span id="rfc.iref.g.16"></span><span id="rfc.iref.g.17"></span><span id="rfc.iref.g.18"></span><span id="rfc.iref.g.19"></span><span id="rfc.iref.g.20"></span><span id="rfc.iref.g.21"></span> <a href="#header.content-range" class="smpl">Content-Range</a> = <a href="#header.content-range" class="smpl">byte-content-range</a> 764 827 / <a href="#header.content-range" class="smpl">other-content-range</a> 765 828 … … 787 850 selected representation is known by the sender to be 1234 bytes: 788 851 </p> 789 <div id="rfc.figure.u. 8"></div><pre class="text"> Content-Range: bytes 42-1233/1234852 <div id="rfc.figure.u.16"></div><pre class="text"> Content-Range: bytes 42-1233/1234 790 853 </pre><p id="rfc.section.5.2.p.8">or this second example would apply when the complete length is unknown:</p> 791 <div id="rfc.figure.u. 9"></div><pre class="text"> Content-Range: bytes 42-1233/*854 <div id="rfc.figure.u.17"></div><pre class="text"> Content-Range: bytes 42-1233/* 792 855 </pre><p id="rfc.section.5.2.p.10">A server generating a <a href="#status.416" class="smpl">416 (Range Not Satisfiable)</a> response to a byte range request <em class="bcp14">SHOULD</em> send a Content-Range header field with an <a href="#header.content-range" class="smpl">unsatisfied-range</a> value, as in the following example: 793 856 </p> 794 <div id="rfc.figure.u.1 0"></div><pre class="text"> Content-Range: bytes */1234857 <div id="rfc.figure.u.18"></div><pre class="text"> Content-Range: bytes */1234 795 858 </pre><p id="rfc.section.5.2.p.12">The complete-length in a 416 response indicates the current length of the selected representation, which will be known by 796 859 the server generating the response because that is how it determined the range to be unsatisfiable. … … 802 865 <ul> 803 866 <li>The first 500 bytes: 804 <div id="rfc.figure.u.1 1"></div><pre class="text"> Content-Range: bytes 0-499/1234867 <div id="rfc.figure.u.19"></div><pre class="text"> Content-Range: bytes 0-499/1234 805 868 </pre> </li> 806 869 <li>The second 500 bytes: 807 <div id="rfc.figure.u. 12"></div><pre class="text"> Content-Range: bytes 500-999/1234870 <div id="rfc.figure.u.20"></div><pre class="text"> Content-Range: bytes 500-999/1234 808 871 </pre> </li> 809 872 <li>All except for the first 500 bytes: 810 <div id="rfc.figure.u. 13"></div><pre class="text"> Content-Range: bytes 500-1233/1234873 <div id="rfc.figure.u.21"></div><pre class="text"> Content-Range: bytes 500-1233/1234 811 874 </pre> </li> 812 875 <li>The last 500 bytes: 813 <div id="rfc.figure.u. 14"></div><pre class="text"> Content-Range: bytes 734-1233/1234876 <div id="rfc.figure.u.22"></div><pre class="text"> Content-Range: bytes 734-1233/1234 814 877 </pre> </li> 815 878 </ul> … … 823 886 is unchanged, send me the part(s) that I am requesting in Range; otherwise, send me the entire representation. 824 887 </p> 825 <div id="rfc.figure.u. 15"></div><pre class="inline"><span id="rfc.iref.g.14"></span> <a href="#header.if-range" class="smpl">If-Range</a> = <a href="#imported.abnf" class="smpl">entity-tag</a> / <a href="#imported.abnf" class="smpl">HTTP-date</a>888 <div id="rfc.figure.u.23"></div><pre class="inline"><span id="rfc.iref.g.22"></span> <a href="#header.if-range" class="smpl">If-Range</a> = <a href="#imported.abnf" class="smpl">entity-tag</a> / <a href="#imported.abnf" class="smpl">HTTP-date</a> 826 889 </pre><p id="rfc.section.5.3.p.4">Clients <em class="bcp14">MUST NOT</em> use an entity-tag marked as weak in an If-Range field value and <em class="bcp14">MUST NOT</em> use a <a href="p4-conditional.html#header.last-modified" class="smpl">Last-Modified</a> date in an If-Range field value unless it has no entity-tag for the representation and the Last-Modified date it does have 827 890 for the representation is strong in the sense defined by <a href="p4-conditional.html#lastmod.comparison" title="Comparison">Section 2.2.2</a> of <a href="#Part4" id="rfc.xref.Part4.3"><cite title="Hypertext Transfer Protocol (HTTP/1.1): Conditional Requests">[Part4]</cite></a>. … … 837 900 <div id="rfc.iref.r.1"></div> 838 901 <h2 id="rfc.section.5.4"><a href="#rfc.section.5.4">5.4</a> <a id="header.range" href="#header.range">Range</a></h2> 839 <h3 id="rfc.section.5.4.1"><a href="#rfc.section.5.4.1">5.4.1</a> <a id="byte.ranges" href="#byte.ranges">Byte Ranges</a></h3> 840 <p id="rfc.section.5.4.1.p.1">Since all HTTP representations are transferred as sequences of bytes, the concept of a byte range is meaningful for any HTTP 841 representation. (However, not all clients and servers need to support byte-range operations.) 842 </p> 843 <p id="rfc.section.5.4.1.p.2">Byte range specifications in HTTP apply to the sequence of bytes in the representation data (not necessarily the same as the 844 message body). 845 </p> 846 <div id="rule.ranges-specifier"> 847 <p id="rfc.section.5.4.1.p.3"> A byte range operation <em class="bcp14">MAY</em> specify a single range of bytes, or a set of ranges within a single representation. 848 </p> 849 </div> 850 <div id="rfc.figure.u.16"></div><pre class="inline"><span id="rfc.iref.g.15"></span><span id="rfc.iref.g.16"></span><span id="rfc.iref.g.17"></span><span id="rfc.iref.g.18"></span><span id="rfc.iref.g.19"></span><span id="rfc.iref.g.20"></span> <a href="#rule.ranges-specifier" class="smpl">byte-ranges-specifier</a> = <a href="#range.units" class="smpl">bytes-unit</a> "=" <a href="#rule.ranges-specifier" class="smpl">byte-range-set</a> 851 <a href="#rule.ranges-specifier" class="smpl">byte-range-set</a> = 1#( <a href="#rule.ranges-specifier" class="smpl">byte-range-spec</a> / <a href="#rule.ranges-specifier" class="smpl">suffix-byte-range-spec</a> ) 852 <a href="#rule.ranges-specifier" class="smpl">byte-range-spec</a> = <a href="#rule.ranges-specifier" class="smpl">first-byte-pos</a> "-" [ <a href="#rule.ranges-specifier" class="smpl">last-byte-pos</a> ] 853 <a href="#rule.ranges-specifier" class="smpl">first-byte-pos</a> = 1*<a href="#imported.abnf" class="smpl">DIGIT</a> 854 <a href="#rule.ranges-specifier" class="smpl">last-byte-pos</a> = 1*<a href="#imported.abnf" class="smpl">DIGIT</a> 855 </pre><p id="rfc.section.5.4.1.p.5">The first-byte-pos value in a byte-range-spec gives the byte-offset of the first byte in a range. The last-byte-pos value 856 gives the byte-offset of the last byte in the range; that is, the byte positions specified are inclusive. Byte offsets start 857 at zero. 858 </p> 859 <p id="rfc.section.5.4.1.p.6">If the last-byte-pos value is present, it <em class="bcp14">MUST</em> be greater than or equal to the first-byte-pos in that byte-range-spec, or the byte-range-spec is syntactically invalid. The 860 recipient of a byte-range-set that includes one or more syntactically invalid byte-range-spec values <em class="bcp14">MUST</em> ignore the header field that includes that byte-range-set. 861 </p> 862 <p id="rfc.section.5.4.1.p.7">If the last-byte-pos value is absent, or if the value is greater than or equal to the current length of the representation 863 data, last-byte-pos is taken to be equal to one less than the current length of the representation in bytes. 864 </p> 865 <p id="rfc.section.5.4.1.p.8">By its choice of last-byte-pos, a client can limit the number of bytes retrieved without knowing the size of the representation.</p> 866 <div id="rfc.figure.u.17"></div><pre class="inline"><span id="rfc.iref.g.21"></span><span id="rfc.iref.g.22"></span> <a href="#rule.ranges-specifier" class="smpl">suffix-byte-range-spec</a> = "-" <a href="#rule.ranges-specifier" class="smpl">suffix-length</a> 867 <a href="#rule.ranges-specifier" class="smpl">suffix-length</a> = 1*<a href="#imported.abnf" class="smpl">DIGIT</a> 868 </pre><p id="rfc.section.5.4.1.p.10">A suffix-byte-range-spec is used to specify the suffix of the representation data, of a length given by the suffix-length 869 value. (That is, this form specifies the last N bytes of a representation.) If the representation is shorter than the specified 870 suffix-length, the entire representation is used. 871 </p> 872 <p id="rfc.section.5.4.1.p.11">If a syntactically valid byte-range-set includes at least one byte-range-spec whose first-byte-pos is less than the current 873 length of the representation, or at least one suffix-byte-range-spec with a non-zero suffix-length, then the byte-range-set 874 is satisfiable. Otherwise, the byte-range-set is unsatisfiable. If the byte-range-set is unsatisfiable, the server <em class="bcp14">SHOULD</em> send a response with a <a href="#status.416" class="smpl">416 (Range Not Satisfiable)</a> status code. Otherwise, the server <em class="bcp14">SHOULD</em> send a response with a <a href="#status.206" class="smpl">206 (Partial Content)</a> status code containing the satisfiable ranges of the representation. 875 </p> 876 <p id="rfc.section.5.4.1.p.12">In the byte range syntax, <a href="#rule.ranges-specifier" class="smpl">first-byte-pos</a>, <a href="#rule.ranges-specifier" class="smpl">last-byte-pos</a>, and <a href="#rule.ranges-specifier" class="smpl">suffix-length</a> are expressed as decimal number of octets. Since there is no predefined limit to the length of an HTTP payload, recipients <em class="bcp14">SHOULD</em> anticipate potentially large decimal numerals and prevent parsing errors due to integer conversion overflows. 877 </p> 878 <p id="rfc.section.5.4.1.p.13">Examples of byte-ranges-specifier values (assuming a representation of length 10000): </p> 879 <ul> 880 <li>The first 500 bytes (byte offsets 0-499, inclusive): 881 <div id="rfc.figure.u.18"></div><pre class="text"> bytes=0-499 882 </pre> </li> 883 <li>The second 500 bytes (byte offsets 500-999, inclusive): 884 <div id="rfc.figure.u.19"></div><pre class="text"> bytes=500-999 885 </pre> </li> 886 <li>The final 500 bytes (byte offsets 9500-9999, inclusive): 887 <div id="rfc.figure.u.20"></div><pre class="text"> bytes=-500 888 </pre> Or: <div id="rfc.figure.u.21"></div><pre class="text"> bytes=9500- 889 </pre> </li> 890 <li>The first and last bytes only (bytes 0 and 9999): 891 <div id="rfc.figure.u.22"></div><pre class="text"> bytes=0-0,-1 892 </pre> </li> 893 <li>Several legal but not canonical specifications of the second 500 bytes (byte offsets 500-999, inclusive): 894 <div id="rfc.figure.u.23"></div><pre class="text"> bytes=500-600,601-999 895 bytes=500-700,601-999 896 </pre> </li> 897 </ul> 898 <h3 id="rfc.section.5.4.2"><a href="#rfc.section.5.4.2">5.4.2</a> <a id="range.retrieval.requests" href="#range.retrieval.requests">Range Retrieval Requests</a></h3> 899 <p id="rfc.section.5.4.2.p.1">The "Range" header field on a GET request modifies the method semantics to request transfer of only one or more sub-ranges 902 <h3 id="rfc.section.5.4.1"><a href="#rfc.section.5.4.1">5.4.1</a> <a id="range.retrieval.requests" href="#range.retrieval.requests">Range Retrieval Requests</a></h3> 903 <p id="rfc.section.5.4.1.p.1">The "Range" header field on a GET request modifies the method semantics to request transfer of only one or more sub-ranges 900 904 of the selected representation data in a successful response, rather than the entire representation data. 901 905 </p> … … 903 907 <a href="#range.retrieval.requests" class="smpl">other-ranges-specifier</a> = <a href="#range.units" class="smpl">other-range-unit</a> "=" <a href="#range.retrieval.requests" class="smpl">other-range-set</a> 904 908 <a href="#range.retrieval.requests" class="smpl">other-range-set</a> = 1*<a href="#imported.abnf" class="smpl">CHAR</a> 905 </pre><p id="rfc.section.5.4. 2.p.3">A server <em class="bcp14">MAY</em> ignore the Range header field. However, origin servers and intermediate caches ought to support byte ranges when possible,909 </pre><p id="rfc.section.5.4.1.p.3">A server <em class="bcp14">MAY</em> ignore the Range header field. However, origin servers and intermediate caches ought to support byte ranges when possible, 906 910 since Range supports efficient recovery from partially failed transfers and partial retrieval of large representations. A 907 911 server <em class="bcp14">MUST</em> ignore a Range header field received with a request method other than GET. 908 912 </p> 909 <p id="rfc.section.5.4. 2.p.4">An origin server <em class="bcp14">MUST</em> ignore a <a href="#range.retrieval.requests" class="smpl">Range</a> header field that contains a range unit it does not understand. A proxy <em class="bcp14">MAY</em> either discard a <a href="#range.retrieval.requests" class="smpl">Range</a> header field that contains a range unit it does not understand or pass it to the next inbound server when forwarding the request.910 </p> 911 <p id="rfc.section.5.4. 2.p.5">The Range header field is evaluated after evaluating the preconditions of <a href="#Part4" id="rfc.xref.Part4.5"><cite title="Hypertext Transfer Protocol (HTTP/1.1): Conditional Requests">[Part4]</cite></a> and only if the result of their evaluation is leading toward a <a href="p2-semantics.html#status.200" class="smpl">200 (OK)</a> response. In other words, Range is ignored when a conditional GET would result in a <a href="p4-conditional.html#status.304" class="smpl">304 (Not Modified)</a> response.912 </p> 913 <p id="rfc.section.5.4. 2.p.6">The If-Range header field (<a href="#header.if-range" id="rfc.xref.header.if-range.3" title="If-Range">Section 5.3</a>) can be used as a precondition to applying the Range header field.914 </p> 915 <p id="rfc.section.5.4. 2.p.7">If all of the preconditions are true, the server supports the Range header field for the target resource, the specified range(s)916 are syntactically correct (as defined in <a href="#byte.ranges" title="Byte Ranges">Section 5.4.1</a>), and at least one of the ranges has a non-empty intersection with the current selected representation extent, then the server <em class="bcp14">MAY</em> respond with a status code of <a href="#status.206" class="smpl">206 (Partial Content)</a> and a payload containing one or more partial representations that correspond to those requested, as defined in <a href="#range.response" title="Responses to a Range Request">Section 4</a>.913 <p id="rfc.section.5.4.1.p.4">An origin server <em class="bcp14">MUST</em> ignore a <a href="#range.retrieval.requests" class="smpl">Range</a> header field that contains a range unit it does not understand. A proxy <em class="bcp14">MAY</em> either discard a <a href="#range.retrieval.requests" class="smpl">Range</a> header field that contains a range unit it does not understand or pass it to the next inbound server when forwarding the request. 914 </p> 915 <p id="rfc.section.5.4.1.p.5">The Range header field is evaluated after evaluating the preconditions of <a href="#Part4" id="rfc.xref.Part4.5"><cite title="Hypertext Transfer Protocol (HTTP/1.1): Conditional Requests">[Part4]</cite></a> and only if the result of their evaluation is leading toward a <a href="p2-semantics.html#status.200" class="smpl">200 (OK)</a> response. In other words, Range is ignored when a conditional GET would result in a <a href="p4-conditional.html#status.304" class="smpl">304 (Not Modified)</a> response. 916 </p> 917 <p id="rfc.section.5.4.1.p.6">The If-Range header field (<a href="#header.if-range" id="rfc.xref.header.if-range.3" title="If-Range">Section 5.3</a>) can be used as a precondition to applying the Range header field. 918 </p> 919 <p id="rfc.section.5.4.1.p.7">If all of the preconditions are true, the server supports the Range header field for the target resource, the specified range(s) 920 are syntactically correct (as defined in <a href="#byte.ranges" title="Byte Ranges">Section 2.1</a>), and at least one of the ranges has a non-empty intersection with the current selected representation extent, then the server <em class="bcp14">MAY</em> respond with a status code of <a href="#status.206" class="smpl">206 (Partial Content)</a> and a payload containing one or more partial representations that correspond to those requested, as defined in <a href="#range.response" title="Responses to a Range Request">Section 4</a>. 917 921 </p> 918 922 <h1 id="rfc.section.6"><a href="#rfc.section.6">6.</a> <a id="IANA.considerations" href="#IANA.considerations">IANA Considerations</a></h1> … … 1325 1329 <ul class="ind"> 1326 1330 <li><a id="rfc.index.2" href="#rfc.index.2"><b>2</b></a><ul> 1327 <li>206 Partial Content (status code) <a href="#rfc.iref. 3"><b>3.1</b></a>, <a href="#rfc.xref.status.206.1">6.2</a>, <a href="#rfc.xref.status.206.2">B</a></li>1331 <li>206 Partial Content (status code) <a href="#rfc.iref.11"><b>3.1</b></a>, <a href="#rfc.xref.status.206.1">6.2</a>, <a href="#rfc.xref.status.206.2">B</a></li> 1328 1332 </ul> 1329 1333 </li> 1330 1334 <li><a id="rfc.index.4" href="#rfc.index.4"><b>4</b></a><ul> 1331 <li>416 Range Not Satisfiable (status code) <a href="#rfc.iref. 3"><b>3.2</b></a>, <a href="#rfc.xref.status.416.1">6.2</a></li>1335 <li>416 Range Not Satisfiable (status code) <a href="#rfc.iref.11"><b>3.2</b></a>, <a href="#rfc.xref.status.416.1">6.2</a></li> 1332 1336 </ul> 1333 1337 </li> … … 1348 1352 <li><tt>Grammar</tt> 1349 1353 <ul> 1350 <li><tt>Accept-Ranges</tt> <a href="#rfc.iref.g. 4"><b>5.1</b></a></li>1351 <li><tt>acceptable-ranges</tt> <a href="#rfc.iref.g. 5"><b>5.1</b></a></li>1352 <li><tt>byte-content-range</tt> <a href="#rfc.iref.g. 7"><b>5.2</b></a></li>1353 <li><tt>byte-range</tt> <a href="#rfc.iref.g. 9"><b>5.2</b></a></li>1354 <li><tt>byte-range-resp</tt> <a href="#rfc.iref.g. 8"><b>5.2</b></a></li>1355 <li><tt>byte-range-set</tt> <a href="#rfc.iref.g. 17"><b>5.4.1</b></a></li>1356 <li><tt>byte-range-spec</tt> <a href="#rfc.iref.g. 18"><b>5.4.1</b></a></li>1357 <li><tt>byte-ranges-specifier</tt> <a href="#rfc.iref.g. 16"><b>5.4.1</b></a></li>1354 <li><tt>Accept-Ranges</tt> <a href="#rfc.iref.g.12"><b>5.1</b></a></li> 1355 <li><tt>acceptable-ranges</tt> <a href="#rfc.iref.g.13"><b>5.1</b></a></li> 1356 <li><tt>byte-content-range</tt> <a href="#rfc.iref.g.15"><b>5.2</b></a></li> 1357 <li><tt>byte-range</tt> <a href="#rfc.iref.g.17"><b>5.2</b></a></li> 1358 <li><tt>byte-range-resp</tt> <a href="#rfc.iref.g.16"><b>5.2</b></a></li> 1359 <li><tt>byte-range-set</tt> <a href="#rfc.iref.g.6"><b>2.1</b></a></li> 1360 <li><tt>byte-range-spec</tt> <a href="#rfc.iref.g.7"><b>2.1</b></a></li> 1361 <li><tt>byte-ranges-specifier</tt> <a href="#rfc.iref.g.5"><b>2.1</b></a></li> 1358 1362 <li><tt>bytes-unit</tt> <a href="#rfc.iref.g.2"><b>2</b></a></li> 1359 <li><tt>complete-length</tt> <a href="#rfc.iref.g. 13"><b>5.2</b></a></li>1360 <li><tt>Content-Range</tt> <a href="#rfc.iref.g. 6"><b>5.2</b></a></li>1361 <li><tt>first-byte-pos</tt> <a href="#rfc.iref.g. 19"><b>5.4.1</b></a></li>1362 <li><tt>If-Range</tt> <a href="#rfc.iref.g. 14"><b>5.3</b></a></li>1363 <li><tt>last-byte-pos</tt> <a href="#rfc.iref.g. 20"><b>5.4.1</b></a></li>1364 <li><tt>other-content-range</tt> <a href="#rfc.iref.g.1 1"><b>5.2</b></a></li>1365 <li><tt>other-range-resp</tt> <a href="#rfc.iref.g. 12"><b>5.2</b></a></li>1363 <li><tt>complete-length</tt> <a href="#rfc.iref.g.21"><b>5.2</b></a></li> 1364 <li><tt>Content-Range</tt> <a href="#rfc.iref.g.14"><b>5.2</b></a></li> 1365 <li><tt>first-byte-pos</tt> <a href="#rfc.iref.g.8"><b>2.1</b></a></li> 1366 <li><tt>If-Range</tt> <a href="#rfc.iref.g.22"><b>5.3</b></a></li> 1367 <li><tt>last-byte-pos</tt> <a href="#rfc.iref.g.9"><b>2.1</b></a></li> 1368 <li><tt>other-content-range</tt> <a href="#rfc.iref.g.19"><b>5.2</b></a></li> 1369 <li><tt>other-range-resp</tt> <a href="#rfc.iref.g.20"><b>5.2</b></a></li> 1366 1370 <li><tt>other-range-unit</tt> <a href="#rfc.iref.g.3"><b>2</b></a></li> 1367 <li><tt>Range</tt> <a href="#rfc.iref.g.23"><b>5.4. 2</b></a></li>1371 <li><tt>Range</tt> <a href="#rfc.iref.g.23"><b>5.4.1</b></a></li> 1368 1372 <li><tt>range-unit</tt> <a href="#rfc.iref.g.1"><b>2</b></a></li> 1369 <li><tt>ranges-specifier</tt> <a href="#rfc.iref.g. 15"><b>5.4.1</b></a></li>1370 <li><tt>suffix-byte-range-spec</tt> <a href="#rfc.iref.g. 21"><b>5.4.1</b></a></li>1371 <li><tt>suffix-length</tt> <a href="#rfc.iref.g. 22"><b>5.4.1</b></a></li>1372 <li><tt>unsatisfied-range</tt> <a href="#rfc.iref.g.1 0"><b>5.2</b></a></li>1373 <li><tt>ranges-specifier</tt> <a href="#rfc.iref.g.4"><b>2.1</b></a></li> 1374 <li><tt>suffix-byte-range-spec</tt> <a href="#rfc.iref.g.10"><b>2.1</b></a></li> 1375 <li><tt>suffix-length</tt> <a href="#rfc.iref.g.11"><b>2.1</b></a></li> 1376 <li><tt>unsatisfied-range</tt> <a href="#rfc.iref.g.18"><b>5.2</b></a></li> 1373 1377 </ul> 1374 1378 </li> … … 1376 1380 </li> 1377 1381 <li><a id="rfc.index.I" href="#rfc.index.I"><b>I</b></a><ul> 1378 <li>If-Range header field <a href="#rfc.xref.header.if-range.1">3.1</a>, <a href="#rfc.xref.header.if-range.2">3.2</a>, <a href="#rfc.iref.i.1"><b>5.3</b></a>, <a href="#rfc.xref.header.if-range.3">5.4. 2</a>, <a href="#rfc.xref.header.if-range.4">6.3</a></li>1382 <li>If-Range header field <a href="#rfc.xref.header.if-range.1">3.1</a>, <a href="#rfc.xref.header.if-range.2">3.2</a>, <a href="#rfc.iref.i.1"><b>5.3</b></a>, <a href="#rfc.xref.header.if-range.3">5.4.1</a>, <a href="#rfc.xref.header.if-range.4">6.3</a></li> 1379 1383 </ul> 1380 1384 </li> … … 1403 1407 </ul> 1404 1408 </li> 1405 <li><em>Part4</em> <a href="#rfc.xref.Part4.1">4.2</a>, <a href="#rfc.xref.Part4.2">4.2</a>, <a href="#rfc.xref.Part4.3">5.3</a>, <a href="#rfc.xref.Part4.4">5.3</a>, <a href="#rfc.xref.Part4.5">5.4. 2</a>, <a href="#Part4"><b>9.1</b></a>, <a href="#rfc.xref.Part4.6">C</a><ul>1409 <li><em>Part4</em> <a href="#rfc.xref.Part4.1">4.2</a>, <a href="#rfc.xref.Part4.2">4.2</a>, <a href="#rfc.xref.Part4.3">5.3</a>, <a href="#rfc.xref.Part4.4">5.3</a>, <a href="#rfc.xref.Part4.5">5.4.1</a>, <a href="#Part4"><b>9.1</b></a>, <a href="#rfc.xref.Part4.6">C</a><ul> 1406 1410 <li><em>Section 2.2.2</em> <a href="#rfc.xref.Part4.2">4.2</a>, <a href="#rfc.xref.Part4.3">5.3</a>, <a href="#rfc.xref.Part4.4">5.3</a></li> 1407 1411 <li><em>Section 2.3</em> <a href="#rfc.xref.Part4.1">4.2</a>, <a href="#rfc.xref.Part4.6">C</a></li> -
draft-ietf-httpbis/latest/p5-range.xml
r2139 r2140 176 176 </t> 177 177 </section> 178 179 178 </section> 180 179 … … 199 198 <x:ref>other-range-unit</x:ref> = <x:ref>token</x:ref> 200 199 </artwork></figure> 200 201 <section title="Byte Ranges" anchor="byte.ranges"> 202 <t> 203 Since all HTTP representations are transferred as sequences 204 of bytes, the concept of a byte range is meaningful for any HTTP 205 representation. (However, not all clients and servers need to support byte-range 206 operations.) 207 </t> 208 <t> 209 Byte range specifications in HTTP apply to the sequence of bytes in 210 the representation data (not necessarily the same as the message body). 211 </t> 212 <t anchor="rule.ranges-specifier"> 213 <x:anchor-alias value="byte-range-set"/> 214 <x:anchor-alias value="byte-range-spec"/> 215 <x:anchor-alias value="byte-ranges-specifier"/> 216 <x:anchor-alias value="first-byte-pos"/> 217 <x:anchor-alias value="last-byte-pos"/> 218 <x:anchor-alias value="ranges-specifier"/> 219 <x:anchor-alias value="suffix-byte-range-spec"/> 220 <x:anchor-alias value="suffix-length"/> 221 A byte range operation &MAY; specify a single range of bytes, or a set 222 of ranges within a single representation. 223 </t> 224 <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"/> 225 <x:ref>byte-ranges-specifier</x:ref> = <x:ref>bytes-unit</x:ref> "=" <x:ref>byte-range-set</x:ref> 226 <x:ref>byte-range-set</x:ref> = 1#( <x:ref>byte-range-spec</x:ref> / <x:ref>suffix-byte-range-spec</x:ref> ) 227 <x:ref>byte-range-spec</x:ref> = <x:ref>first-byte-pos</x:ref> "-" [ <x:ref>last-byte-pos</x:ref> ] 228 <x:ref>first-byte-pos</x:ref> = 1*<x:ref>DIGIT</x:ref> 229 <x:ref>last-byte-pos</x:ref> = 1*<x:ref>DIGIT</x:ref> 230 </artwork></figure> 231 <t> 232 The first-byte-pos value in a byte-range-spec gives the byte-offset 233 of the first byte in a range. The last-byte-pos value gives the 234 byte-offset of the last byte in the range; that is, the byte 235 positions specified are inclusive. Byte offsets start at zero. 236 </t> 237 <t> 238 If the last-byte-pos value is present, it &MUST; be greater than or 239 equal to the first-byte-pos in that byte-range-spec, or the byte-range-spec 240 is syntactically invalid. The recipient of a byte-range-set 241 that includes one or more syntactically invalid byte-range-spec 242 values &MUST; ignore the header field that includes that byte-range-set. 243 </t> 244 <t> 245 If the last-byte-pos value is absent, or if the value is greater than 246 or equal to the current length of the representation data, last-byte-pos is 247 taken to be equal to one less than the current length of the representation 248 in bytes. 249 </t> 250 <t> 251 By its choice of last-byte-pos, a client can limit the number of 252 bytes retrieved without knowing the size of the representation. 253 </t> 254 <figure><artwork type="abnf2616"><iref primary="true" item="Grammar" subitem="suffix-byte-range-spec"/><iref primary="true" item="Grammar" subitem="suffix-length"/> 255 <x:ref>suffix-byte-range-spec</x:ref> = "-" <x:ref>suffix-length</x:ref> 256 <x:ref>suffix-length</x:ref> = 1*<x:ref>DIGIT</x:ref> 257 </artwork></figure> 258 <t> 259 A suffix-byte-range-spec is used to specify the suffix of the 260 representation data, of a length given by the suffix-length value. (That is, 261 this form specifies the last N bytes of a representation.) If the 262 representation is shorter than the specified suffix-length, the entire 263 representation is used. 264 </t> 265 <t> 266 If a syntactically valid byte-range-set includes at least one byte-range-spec 267 whose first-byte-pos is less than the current length of 268 the representation, or at least one suffix-byte-range-spec with a non-zero 269 suffix-length, then the byte-range-set is satisfiable. 270 Otherwise, the byte-range-set is unsatisfiable. If the byte-range-set 271 is unsatisfiable, the server &SHOULD; send a response with a 272 <x:ref>416 (Range Not Satisfiable)</x:ref> status code. Otherwise, the server 273 &SHOULD; send a response with a <x:ref>206 (Partial Content)</x:ref> status code 274 containing the satisfiable ranges of the representation. 275 </t> 276 <t> 277 In the byte range syntax, <x:ref>first-byte-pos</x:ref>, 278 <x:ref>last-byte-pos</x:ref>, and <x:ref>suffix-length</x:ref> are 279 expressed as decimal number of octets. Since there is no predefined limit 280 to the length of an HTTP payload, recipients &SHOULD; anticipate 281 potentially large decimal numerals and prevent parsing errors due to integer 282 conversion overflows. 283 </t> 284 <t> 285 Examples of byte-ranges-specifier values (assuming a representation of 286 length 10000): 287 <list style="symbols"> 288 <t>The first 500 bytes (byte offsets 0-499, inclusive): 289 <figure><artwork type="example" x:indent-with=" "> 290 bytes=0-499 291 </artwork></figure> 292 </t> 293 <t>The second 500 bytes (byte offsets 500-999, inclusive): 294 <figure><artwork type="example" x:indent-with=" "> 295 bytes=500-999 296 </artwork></figure> 297 </t> 298 <t>The final 500 bytes (byte offsets 9500-9999, inclusive): 299 <figure><artwork type="example" x:indent-with=" "> 300 bytes=-500 301 </artwork></figure> 302 Or: 303 <figure><artwork type="example" x:indent-with=" "> 304 bytes=9500- 305 </artwork></figure> 306 </t> 307 <t>The first and last bytes only (bytes 0 and 9999): 308 <figure><artwork type="example" x:indent-with=" "> 309 bytes=0-0,-1 310 </artwork></figure> 311 </t> 312 <t>Several legal but not canonical specifications of the second 500 313 bytes (byte offsets 500-999, inclusive): 314 <figure><artwork type="example" x:indent-with=" "> 315 bytes=500-600,601-999 316 bytes=500-700,601-999 317 </artwork></figure> 318 </t> 319 </list> 320 </t> 321 </section> 322 323 <section title="Other Range Units" anchor="range.units.other"> 201 324 <t> 202 325 The only range unit defined by HTTP/1.1 is "bytes" … … 204 327 in <xref target="range.unit.registry"/>. 205 328 </t> 206 329 </section> 207 330 </section> 208 331 … … 619 742 <section title="Range" anchor="header.range"> 620 743 <iref primary="true" item="Range header field" x:for-anchor=""/> 621 622 <section title="Byte Ranges" anchor="byte.ranges">623 <t>624 Since all HTTP representations are transferred as sequences625 of bytes, the concept of a byte range is meaningful for any HTTP626 representation. (However, not all clients and servers need to support byte-range627 operations.)628 </t>629 <t>630 Byte range specifications in HTTP apply to the sequence of bytes in631 the representation data (not necessarily the same as the message body).632 </t>633 <t anchor="rule.ranges-specifier">634 <x:anchor-alias value="byte-range-set"/>635 <x:anchor-alias value="byte-range-spec"/>636 <x:anchor-alias value="byte-ranges-specifier"/>637 <x:anchor-alias value="first-byte-pos"/>638 <x:anchor-alias value="last-byte-pos"/>639 <x:anchor-alias value="ranges-specifier"/>640 <x:anchor-alias value="suffix-byte-range-spec"/>641 <x:anchor-alias value="suffix-length"/>642 A byte range operation &MAY; specify a single range of bytes, or a set643 of ranges within a single representation.644 </t>645 <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"/>646 <x:ref>byte-ranges-specifier</x:ref> = <x:ref>bytes-unit</x:ref> "=" <x:ref>byte-range-set</x:ref>647 <x:ref>byte-range-set</x:ref> = 1#( <x:ref>byte-range-spec</x:ref> / <x:ref>suffix-byte-range-spec</x:ref> )648 <x:ref>byte-range-spec</x:ref> = <x:ref>first-byte-pos</x:ref> "-" [ <x:ref>last-byte-pos</x:ref> ]649 <x:ref>first-byte-pos</x:ref> = 1*<x:ref>DIGIT</x:ref>650 <x:ref>last-byte-pos</x:ref> = 1*<x:ref>DIGIT</x:ref>651 </artwork></figure>652 <t>653 The first-byte-pos value in a byte-range-spec gives the byte-offset654 of the first byte in a range. The last-byte-pos value gives the655 byte-offset of the last byte in the range; that is, the byte656 positions specified are inclusive. Byte offsets start at zero.657 </t>658 <t>659 If the last-byte-pos value is present, it &MUST; be greater than or660 equal to the first-byte-pos in that byte-range-spec, or the byte-range-spec661 is syntactically invalid. The recipient of a byte-range-set662 that includes one or more syntactically invalid byte-range-spec663 values &MUST; ignore the header field that includes that byte-range-set.664 </t>665 <t>666 If the last-byte-pos value is absent, or if the value is greater than667 or equal to the current length of the representation data, last-byte-pos is668 taken to be equal to one less than the current length of the representation669 in bytes.670 </t>671 <t>672 By its choice of last-byte-pos, a client can limit the number of673 bytes retrieved without knowing the size of the representation.674 </t>675 <figure><artwork type="abnf2616"><iref primary="true" item="Grammar" subitem="suffix-byte-range-spec"/><iref primary="true" item="Grammar" subitem="suffix-length"/>676 <x:ref>suffix-byte-range-spec</x:ref> = "-" <x:ref>suffix-length</x:ref>677 <x:ref>suffix-length</x:ref> = 1*<x:ref>DIGIT</x:ref>678 </artwork></figure>679 <t>680 A suffix-byte-range-spec is used to specify the suffix of the681 representation data, of a length given by the suffix-length value. (That is,682 this form specifies the last N bytes of a representation.) If the683 representation is shorter than the specified suffix-length, the entire684 representation is used.685 </t>686 <t>687 If a syntactically valid byte-range-set includes at least one byte-range-spec688 whose first-byte-pos is less than the current length of689 the representation, or at least one suffix-byte-range-spec with a non-zero690 suffix-length, then the byte-range-set is satisfiable.691 Otherwise, the byte-range-set is unsatisfiable. If the byte-range-set692 is unsatisfiable, the server &SHOULD; send a response with a693 <x:ref>416 (Range Not Satisfiable)</x:ref> status code. Otherwise, the server694 &SHOULD; send a response with a <x:ref>206 (Partial Content)</x:ref> status code695 containing the satisfiable ranges of the representation.696 </t>697 <t>698 In the byte range syntax, <x:ref>first-byte-pos</x:ref>,699 <x:ref>last-byte-pos</x:ref>, and <x:ref>suffix-length</x:ref> are700 expressed as decimal number of octets. Since there is no predefined limit701 to the length of an HTTP payload, recipients &SHOULD; anticipate702 potentially large decimal numerals and prevent parsing errors due to integer703 conversion overflows.704 </t>705 <t>706 Examples of byte-ranges-specifier values (assuming a representation of707 length 10000):708 <list style="symbols">709 <t>The first 500 bytes (byte offsets 0-499, inclusive):710 <figure><artwork type="example" x:indent-with=" ">711 bytes=0-499712 </artwork></figure>713 </t>714 <t>The second 500 bytes (byte offsets 500-999, inclusive):715 <figure><artwork type="example" x:indent-with=" ">716 bytes=500-999717 </artwork></figure>718 </t>719 <t>The final 500 bytes (byte offsets 9500-9999, inclusive):720 <figure><artwork type="example" x:indent-with=" ">721 bytes=-500722 </artwork></figure>723 Or:724 <figure><artwork type="example" x:indent-with=" ">725 bytes=9500-726 </artwork></figure>727 </t>728 <t>The first and last bytes only (bytes 0 and 9999):729 <figure><artwork type="example" x:indent-with=" ">730 bytes=0-0,-1731 </artwork></figure>732 </t>733 <t>Several legal but not canonical specifications of the second 500734 bytes (byte offsets 500-999, inclusive):735 <figure><artwork type="example" x:indent-with=" ">736 bytes=500-600,601-999737 bytes=500-700,601-999738 </artwork></figure>739 </t>740 </list>741 </t>742 </section>743 744 744 745 <section title="Range Retrieval Requests" anchor="range.retrieval.requests">
Note: See TracChangeset
for help on using the changeset viewer.