Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Range header 'helper' produces incorrect header value #1265

Closed
whymarrh opened this issue Jul 4, 2021 · 2 comments
Closed

Range header 'helper' produces incorrect header value #1265

whymarrh opened this issue Jul 4, 2021 · 2 comments

Comments

@whymarrh
Copy link

whymarrh commented Jul 4, 2021

Snapshot: d20e8c9

The spec currently outlines the process for adding a Range header to a request:

To add a range header to a request request, with an integer first, and an optional integer last, run these steps:​

  1. Let rangeValue be `bytes `.
  2. Serialize and isomorphic encode first, and append the result to rangeValue.
  3. Append 0x2D (-) to rangeValue.
  4. If last is given, then serialize and isomorphic encode it, and append the result to rangeValue.
  5. Append `Range`/rangeValue to request’s header list.

As an example, if first and last had values of 3 and 5, I think this would result in a Range header value of bytes 3-5 when it should be bytes=3-5, with 0x3D (=) as the separator.

Per RFC 7233 §2.1:[1]

The "bytes" range unit is defined for expressing subranges of the data's octet sequence.

bytes-unit       = "bytes"

[…]

byte-ranges-specifier = bytes-unit "=" byte-range-set
byte-range-set  = 1#( byte-range-spec / suffix-byte-range-spec )

Examples of byte-ranges-specifier values:

  • The first 500 bytes (byte offsets 0-499, inclusive): bytes=0-499
  • The second 500 bytes (byte offsets 500-999, inclusive): bytes=500-999

It should be a simple enough fix, unless I'm missing something:

- <li><p>Let <var>rangeValue</var> be `<code>bytes </code>`.
+ <li><p>Let <var>rangeValue</var> be `<code>bytes=</code>`.

I'm willing to open a PR for this, if that would be useful.

@annevk
Copy link
Member

annevk commented Jul 19, 2021

If you can also sign https://participate.whatwg.org/agreement, that would be great!

cc @jakearchibald

@annevk
Copy link
Member

annevk commented Apr 4, 2022

This was fixed as part of #1312 in 6f37b51, but we forgot to note it in the final commit message.

@annevk annevk closed this as completed Apr 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants