Bug 183703

Summary: [Fetch API] Allow used body replacement in Request constructor
Product: WebKit Reporter: Harris Hancock <harris>
Component: DOMAssignee: Chris Dumez <cdumez>
Status: RESOLVED FIXED    
Severity: Normal CC: achristensen, cdumez, ggaren, koivisto, webkit-bug-importer, youennf
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch youennf: review+

Harris Hancock
Reported 2018-03-16 11:03:51 PDT
Currently, the following code snippet replaces request's body as one would expect: let request = new Request(url, { method: "POST", body: "foo" }) request = new Request(request, { body: "bar" }) But this snippet, in which the author tries to replace a used body, throws a TypeError: let request = new Request(url, { method: "POST", body: "foo" }) await request.text() // disturb the body request = new Request(request, { body: "bar" }) // throws Since the second snippet is providing a new body to the constructor, there doesn't seem to be any technical need to throw. I have a pull request in to change this in the Fetch spec here: https://github.com/whatwg/fetch/pull/675 Accompanying WPT PR here: https://github.com/w3c/web-platform-tests/pull/9931
Attachments
Patch (4.06 KB, patch)
2019-03-29 16:30 PDT, Chris Dumez
youennf: review+
Radar WebKit Bug Importer
Comment 1 2019-03-29 10:26:43 PDT
Chris Dumez
Comment 2 2019-03-29 16:30:04 PDT
Chris Dumez
Comment 3 2019-04-02 11:39:02 PDT
ping review?
youenn fablet
Comment 4 2019-04-02 12:33:30 PDT
Comment on attachment 366323 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=366323&action=review > Source/WebCore/Modules/fetch/FetchRequest.cpp:241 > + return Exception {TypeError, "Request input is disturbed or locked."_s }; s/{T/{ T/
Chris Dumez
Comment 5 2019-04-02 13:48:26 PDT
Note You need to log in before you can comment on or make changes to this bug.