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

Fix body handling on the Request constructor #458

Merged
merged 3 commits into from
Jan 27, 2017
Merged

Conversation

yutakahirano
Copy link
Member

As Request.body is exposed, we need to specify how to handle the body property of the input Request more correctly. After

let r = new Request(request, ...);

successfully returns,

  • request.body should remain unchanged.
  • request.bodyUsed should be true.

Fixing yutakahirano/fetch-with-streams#60.

@yutakahirano
Copy link
Member Author

@domenic, can you take a look? I want to use a transform stream and pipeTo to avoid manual stream creation. Does it make sense to you?

I filed whatwg/streams#658 for this change.

Thanks!

@annevk annevk added the needs tests Moving the issue forward requires someone to write tests label Jan 17, 2017
@domenic
Copy link
Member

domenic commented Jan 17, 2017

This seems a little confusing to me because it mixes the conceptual level (linking to the model section for transform stream) with the concrete level (linking to the specific algorithm for pipeTo). Maybe it is OK because we are just saying "everyone knows what an identity transform stream is". But it's not 100% clear to me, e.g. what the error propagation behavior is.

So in other words, the intent seems good, but it might not be precise enough. I'm curious what @annevk thinks.

Maybe one direction would be to make things even more vague, e.g. not mention the pipeTo algorithm at all, but just kind of vaguely describe how to get rs from inputBody?

@annevk
Copy link
Member

annevk commented Jan 18, 2017

So my main problem is, what happens if the developer overrides pipeTo()? I guess you want to use some kind of safe pipeTo()? Maybe Streams should define a way to invoke that. If pipeTo() is safe, then invoking it with a conceptual stream is probably okay. But if pipeTo() needs to be abstracted anyway, we might as well abstract the identity transform stream too.

@domenic
Copy link
Member

domenic commented Jan 18, 2017

The idea would be to create an abstract op for pipeTo (whatwg/streams#658) so that calling it always calls the spec algorithm. Not sure where that falls on your safe vs. abstracted spectrum :)

@annevk
Copy link
Member

annevk commented Jan 18, 2017

Sorry I missed that. I think that's okay. Could Streams not also define an identity transform stream that can be passed to that algorithm? Perhaps with a note that it's only for use by specifications until someone figures out a use case to expose it to JavaScript?

@domenic
Copy link
Member

domenic commented Jan 18, 2017

Yeah, maybe that is the way to go. Then we can define error handling behavior more concretely.

We definitely have a use case for it, we just haven't yet specified all the underlying infrastructure (e.g. there are no algorithms for transform streams yet).

<a href=https://streams.spec.whatwg.org/#ts-model>transform stream</a> and
<a href=https://streams.spec.whatwg.org/#pipe-chains>piping</a> are precisely defined.
This makes <var>inputBody</var>'s <a for=body>stream</a> <a for=ReadableStream>locked</a> and
<a for=ReadableStream>disturbed</a> immediately.
Copy link
Member

Choose a reason for hiding this comment

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

I suggest we file an issue against Fetch to track this. And make this a class=XXX rather than a note.

Copy link
Member

Choose a reason for hiding this comment

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

And point to the issue here.

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.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks, this PR looks good to me now, but we will need tests per the new process.

@domenic
Copy link
Member

domenic commented Jan 23, 2017

So I am now a bit confused. Do we want streams to define these things in vague terms? Or is the vague phrasing here, linking to the vague "model" section of streams, good enough for now (until transform streams are defined)? It sounds like we don't need a pipeTo abstract operation anymore?

@annevk
Copy link
Member

annevk commented Jan 24, 2017

I think it's okay to be vague for now, but I don't want us to be vague forever, so I want some kind of tracking URL for making it less vague.

We also need tests for the overall change.

@yutakahirano
Copy link
Member Author

@yutakahirano yutakahirano force-pushed the new-stream-from-stream branch from 9aa9623 to a45131c Compare January 27, 2017 10:59
annevk pushed a commit to web-platform-tests/wpt that referenced this pull request Jan 27, 2017
@annevk annevk merged commit 55141d7 into master Jan 27, 2017
@annevk annevk deleted the new-stream-from-stream branch January 27, 2017 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs tests Moving the issue forward requires someone to write tests
Development

Successfully merging this pull request may close these issues.

3 participants