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

Replace byte stream with ReadableStream. #200

Merged
merged 1 commit into from
Feb 13, 2016

Conversation

yutakahirano
Copy link
Member

This change replaces byte streams used in request and response with ReadableStream. This change
also unifies some properties and operations which was defined separately in Request and Response
classes.

The change is based on
https://github.com/yutakahirano/fetch-with-streams/blob/master/body-readable-stream.md.
Depending specs need to be changed as well.

members as the <code title=concept-ReadableStream>ReadableStream</code> object has today.

<p>A <span title=concept-body>body</span> has an associated
<dfn title=concept-body-transmitted>transmitted</dfn> (an integer). Unless stated it is 0.
Copy link
Member

Choose a reason for hiding this comment

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

"Unless stated otherwise it is 0". Same 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.

Done.

@annevk
Copy link
Member

annevk commented Jan 21, 2016

This looks really great @yutakahirano. Apart from the above nits, I think whenever we allocate a Uint8Array and corresponding buffer, we need to account for that throwing. That could be a follow up if you want since I know we don't do it now either.

I would also greatly appreciate it if @domenic and @wanderview could have a look at this PR (search for Overview.src.html to get the diff you want to read).

@yutakahirano
Copy link
Member Author

Regarding OOM handling, I would create a separate PR.

@yutakahirano yutakahirano force-pushed the body-stream-refactoring branch from 8bf5455 to 5b90955 Compare January 29, 2016 11:47
@yutakahirano
Copy link
Member Author

I squashed the commits.
Are there any other comments?

@annevk
Copy link
Member

annevk commented Jan 29, 2016

@domenic said he would take a look, but I think he's been in meetings all week. I suspect he can review this on Monday. Would that be alright with you?

@yutakahirano
Copy link
Member Author

Yes, thanks!

<dfn title=concept-body-transmitted>transmitted</dfn> which is an integer and initially 0,
<dfn title=concept-body-length>length</dfn> which is an integer and initially 0, and
<dfn title=concept-body-error-flag>error flag</dfn> which is initially unset.
<p>A <dfn title=concept-body>body</dfn> consists of a
Copy link
Member

Choose a reason for hiding this comment

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

I think this would be slightly clearer like:

A body consists of:

  • A stream (a ReadableStream object), initially null (?).
  • A transmitted (an integer), initially 0.
  • A total bytes (an integer), initially 0.

And maybe s/transmitted/transmitted bytes/g?

Copy link
Member Author

Choose a reason for hiding this comment

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

Done.

Body's stream cannot be null and has no initial value. We always specify its stream explicitly when we create a body.

@yutakahirano yutakahirano force-pushed the body-stream-refactoring branch 2 times, most recently from d5fdeab to b924be8 Compare February 2, 2016 02:02
<p><span title=concept-enqueue-ReadableStream>Enqueue</span> a <code>Uint8Array</code>
object wrapping an <code>ArrayBuffer</code> containing <var>bytes</var> to <var>stream</var>.

<p class="note no-backref">This operation will not throw an exception.
Copy link
Member

Choose a reason for hiding this comment

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

Since this is false, we should not add this note.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed.

@yutakahirano yutakahirano force-pushed the body-stream-refactoring branch 3 times, most recently from 561421d to ea70963 Compare February 11, 2016 18:15
@annevk
Copy link
Member

annevk commented Feb 12, 2016

Wit those nits fixed I think this is ready to land. I'd appreciate if you could then fix XMLHttpRequest so that everything still makes some sense. If there's other things we'll just fix them as they come. Getting more eyes on all this Streams language is useful.

@annevk
Copy link
Member

annevk commented Feb 12, 2016

@yutakahirano I'm happy to merge this by the way. If you want to do it, please see the README for instructions. You're probably already familiar with it from Streams, we basically prefer a clean history with single commits for a change.

@annevk
Copy link
Member

annevk commented Feb 13, 2016

Unless someone tells me otherwise I plan to land this on Monday.

@yutakahirano yutakahirano force-pushed the body-stream-refactoring branch 2 times, most recently from eeb79df to 9ea3c2f Compare February 13, 2016 11:00
This change replaces byte streams used in request and response with ReadableStream. This change
also unifies some properties and operations which was defined separately in Request and Response
classes.

The change is based on
https://github.com/yutakahirano/fetch-with-streams/blob/master/body-readable-stream.md.
Depending specs need to be changed as well.
@yutakahirano yutakahirano force-pushed the body-stream-refactoring branch from 9ea3c2f to 35db942 Compare February 13, 2016 11:09
@yutakahirano yutakahirano merged commit 35db942 into master Feb 13, 2016
@yutakahirano
Copy link
Member Author

AI:

@yutakahirano
Copy link
Member Author

Thank you very much, reviewers!

@annevk
Copy link
Member

annevk commented Feb 13, 2016

What does AI mean? Something similar to TODO?

Thank your for working on this. It's greatly appreciated.

@yutakahirano
Copy link
Member Author

Yes, I meant TODO.

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.

4 participants