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

Formalize reading bodies #1172

Merged
merged 3 commits into from
Feb 24, 2021
Merged

Formalize reading bodies #1172

merged 3 commits into from
Feb 24, 2021

Conversation

annevk
Copy link
Member

@annevk annevk commented Feb 17, 2021

Closes #661.


Preview | Diff

@annevk annevk added the do not merge yet Pull request must not be merged per rationale in comment label Feb 17, 2021
fetch.bs Show resolved Hide resolved
@annevk
Copy link
Member Author

annevk commented Feb 18, 2021

I think this is getting somewhere, but:

  • Need to read through it all once again to make sure I haven't dropped anything. (I would still appreciate some review to ensure it's on the right track. And also for ideas on how to address the bits that are still awkward, e.g., request's done flag.)
  • Create a PR for SRI as this changes the handshake between the specifications: Let Fetch be in charge of extracting the bytes w3c/webappsec-subresource-integrity#97
  • Update this PR to use the new exported term from SRI (waiting for SRI to land prolly as it'll break the build)
  • Create a PR for XHR as this should remove all direct Streams dependencies from it (minus one errored check that might warrant some futher investigation in the future): Use Fetch's body read algorithms xhr#313

It makes things more verbose for sure, but overall I think that is probably worth it. Early takes from @yutakahirano and @jakearchibald would also be welcome with regards to that.

fetch.bs Outdated Show resolved Hide resolved
annevk added a commit to w3c/webappsec-subresource-integrity that referenced this pull request Feb 19, 2021
Corresponding Fetch PR: whatwg/fetch#1172.

Closes #63. Helps with #83.
Copy link
Member

@yutakahirano yutakahirano left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall this looks good.

fetch.bs Outdated Show resolved Hide resolved
Copy link
Member

@domenic domenic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with editorial suggestions

fetch.bs Outdated Show resolved Hide resolved
fetch.bs Outdated Show resolved Hide resolved
fetch.bs Outdated Show resolved Hide resolved
fetch.bs Outdated Show resolved Hide resolved
<li><p>Set <var>request</var>'s <a for=request>body</a> to <var>body</var>.
</ol>
<li><p>If <var>request</var>'s <a for=request>body</a> is a <a for=/>byte sequence</a>, then set
<var>request</var>'s <a for=request>body</a> to the first return value of
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"the first return value" seems pretty unusual; why not just "the result of"? Here and below.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It returns two values. I'm aligning it with text elsewhere that uses this terminology.

fetch.bs Outdated Show resolved Hide resolved
fetch.bs Outdated Show resolved Hide resolved
@annevk
Copy link
Member Author

annevk commented Feb 20, 2021

Thanks, I addressed those comments. I also updated the first commit to include a longer description of the changes.

annevk added a commit to w3c/webappsec-subresource-integrity that referenced this pull request Feb 22, 2021
Corresponding Fetch PR: whatwg/fetch#1172.

Closes #63. Helps with #83.
This refactoring allows specifications building on top of Fetch to
avoid having to directly integrate with Streams. It makes these
changes:

* body's transmitted bytes is removed. body's total bytes will likely
  be removed in #604.
* body's done and wait concepts are removed.
* It introduces three primitives to read a body: incrementally read
  (process each chunk), fully read (get all), and
  fully reading body as promise (get all as promise).
* Removed transmit request body in favor of HTTP-network fetch using
  incrementally read directly to transmit the request body.
* Fetch's processRequestBody and processRequestEndOfBody are no longer
  passed a request. The former is passed the chunk length for progress
  reporting. (Needed by XMLHttpRequest.)
* Fetch's processResponseEndOfBody when passed will now cause the body
  to be fully read and will pass the result in the second argument.
  (This means that callers can no longer read the body themselves.)
* Subresource Integrity changed slightly with Fetch handing it the
  bytes and integrity metadata and no longer a response. Essentially
  fetch fully reads the body, does the check, and then creates a new
  body from the same bytes to hand to the caller.

Subresoruce Integrity PR: w3c/webappsec-subresource-integrity#97.

XMLHttpRequest PR: whatwg/xhr#313.

Closes #661.
@annevk annevk removed the do not merge yet Pull request must not be merged per rationale in comment label Feb 24, 2021
@annevk annevk merged commit 6ad9998 into main Feb 24, 2021
@annevk annevk deleted the annevk/read-body branch February 24, 2021 12:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

Getting all bytes in a body
3 participants