[whatwg/fetch] It is possible to construct a Request with a used body (#792)

Given some disturbed but unlocked ReadableStream `rs`, the following spec-conformant code will construct a Request object with a disturbed body:

```javascript
let rs = // a disturbed, unlocked ReadableStream
let request = new Request(url, { method: "POST", body: rs })
```

This works because Request's constructor, `Request(input, init)`, only throws if `input.body` is disturbed, but does not throw if `init.body` is disturbed.

This seems a little strange, because it means iteratively applying Request's constructor could throw upon the second invocation. An example would be in `fetch()`, which is required by the spec to pass its arguments to Request's constructor:

```javascript
// This will NOT throw, because fetch() invokes new Request(input, init).
await fetch(url, { method: "POST", body: rs })

// This WILL throw, because fetch() invokes new Request(input).
let request = new Request(url, { method: "POST", body: rs })
await fetch(request)
```

Should this be considered a bug?

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/whatwg/fetch/issues/792

Received on Thursday, 16 August 2018 22:41:09 UTC