Closed Bug 1500879 Opened 7 years ago Closed 7 years ago

Fetch should not consume Request/Response with null-body

Categories

(Core :: DOM: Core & HTML, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
mozilla65
Tracking Status
firefox65 --- fixed

People

(Reporter: baku, Assigned: baku)

Details

Attachments

(1 file)

Attachment #9018997 - Flags: review?(bugmail)
Priority: -- → P2
Comment on attachment 9018997 [details] [diff] [review] fetch_empty.patch Review of attachment 9018997 [details] [diff] [review]: ----------------------------------------------------------------- Please add a commit message, something like the following. The extra context of a commit message like this and a slightly more spec-explaining comment like the below would have made it much easier to address this review. I'll try and be better in the future about providing an immediate "r-" like :smaug and others do instead of trying to figure the patch out myself. The fetch spec treats null bodies specially. Their Body cannot become disturbed or locked and a fresh empty ReadableStream is returned whenever an attempt is made to consume the body. We currently fail a number of WPT tests in this area because we do mark the body consumed as exposed via bodyUsed. ::: dom/fetch/Fetch.cpp @@ +1238,5 @@ > aRv.ThrowTypeError<MSG_FETCH_BODY_CONSUMED_ERROR>(); > return nullptr; > } > > + // By spec, if the body is null, we have to create an empty ReadableStream. This comment could be a little more illuminating given the unusual behavior of the spec around null bodies. I'd suggest something like the following. null bodies are a special-case in the fetch spec. The Body mix-in can only be "disturbed" or "locked" if its associated "body" is non-null. Additionally, the Body min-in's "consume body" algorithm explicitly creates a fresh empty ReadableStream object in step 2. This means that `bodyUsed` will never return true for a null body. To this end, we create a fresh (empty) body every time a request is made and consume its body here, without marking this FetchBody consumed via SetBodyUsed.
Attachment #9018997 - Flags: review?(bugmail) → review+
Pushed by amarchesini@mozilla.com: https://hg.mozilla.org/integration/mozilla-inbound/rev/01232c002d2d Fetch should not consume Request/Response with null-body, r=asuth
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla65
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: