Bug 171552
| Summary: | [Fetch API] Response disturbed when trying to clone before consuming | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Peleg Rosenthal <peleg3> |
| Component: | WebKit Misc. | Assignee: | Nobody <webkit-unassigned> |
| Status: | NEW | ||
| Severity: | Normal | CC: | webkit-bug-importer, youennf |
| Priority: | P2 | Keywords: | InRadar |
| Version: | WebKit Nightly Build | ||
| Hardware: | Mac | ||
| OS: | OS X 10.11 | ||
Peleg Rosenthal
In latest nightly (r216067), evaluation of `response.body` leads to the response being "disturbed" when trying to clone it despite `body.locked` and `bodyUsed` being false.
Steps to reproduce:
1. open safari
2. go to https://google.com
3. open devtools
4. run the following:
fetch('/').then(r => { r.body; r.clone() })
What happens?
"TypeError: Cannot clone a disturbed Response" is thrown.
What's expected to happen?
Both FF and Chrome clone the response correctly if it hasn't been consumed yet.
JSBin here http://jsbin.com/marogokuna/1/edit?js,output
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Alexey Proskuryakov
This works in shipping Safari/WebKit. I can reproduce the failure in nightly.
Radar WebKit Bug Importer
<rdar://problem/31977099>
Peleg Rosenthal
Thanks Alexey, I'm actually able to reproduce this also in Safari 10.1 (12603.1.30.0.34)
The only difference is that I need to catch the rejection for it to surface:
fetch('/').then(r => { r.body; r.clone() }).catch(console.log)
Alexey Proskuryakov
Thank you for the correction!