yutakahirano / fetch-with-streams

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

Why contentType? #1

Closed domenic closed 9 years ago

domenic commented 9 years ago

Current usage:

var request = new Request({
  method: "POST",
  body: {
    contentType: "text/plain",
    stream: myReadableStream
  }
});

Why not

var request = new Request({
  method: "POST",
  headers: new Headers(["Content-Type", "text/plain"]),
  body: myReadableStream
});

?

domenic commented 9 years ago

After perusing the Fetch API this seems to be something I'm missing about the Fetch API in general, so /cc @annevk.

The closest analogue I can find is the BufferSource case, where if I'm reading the algorithm correctly the returned Content-Type is null. Should we do the same for a stream?

annevk commented 9 years ago

Fetch's Body mixin has MIME type as a convenience. That could probably be inlined now it is no longer on a distinct object.

yutakahirano commented 9 years ago

I removed contentType from BodyStreamInit. Now the operation just returns null as Content-Type.

domenic commented 9 years ago

Great! I will open a new issue with a spin-off improvement.

domenic commented 9 years ago

(It turns out my new issue is irrelevant given f4609c95c4743a16f2192aa37386a746f02e2bd3, so nevermind about that :) )