yutakahirano / fetch-with-streams

Fetch API integrated with Streams.
66 stars 8 forks source link

Expose the writable end #2

Closed domenic closed 9 years ago

domenic commented 9 years ago

As discussed in https://github.com/slightlyoff/ServiceWorker/issues/413, it would be good to be able to do

var request = new Request({
  method: "POST",
  bodyWriter: function (writableStream) {
    writableStream.write(c);
  }
});

var c = request.body.read();

That is, the creator of the stream should have access to the write side of the stream.

A few notes:

domenic commented 9 years ago

(Edited the OP from request.body.stream.read() to request.body.read() to reflect 81b6cf1d3282b0ffaa295dea982f2b45f862778d + the fact that Body is a mixin, which I forgot.)

tyoshino commented 9 years ago

Assign to @domenic per comments at f4609c95c4743a16f2192aa37386a746f02e2bd3?

domenic commented 9 years ago

I did the PR in #3 but then reconsidered. The current approach is good, I think, so we can close this.