Re: [whatwg/fetch] Editorial: Add prose about constructing a request (PR #1585)

@jyasskin commented on this pull request.



> @@ -8385,6 +8388,69 @@ correctly. This section aims to give some advice.
 
 <p class=XXX>This is a work in progress.
 
+<h3 id=fetch-elsewhere-request>Populating a request</h3>
+
+<p>The first step in <a for=/>fetching</a> is to create a <a for=/>request</a>, and populate its
+multiple associated parameters.
+
+<p>Start by setting the <a for=/>request</a>'s <a for=request>URL</a> and <a for=request>method</a>,
+as defined by HTTP. If your `<code>POST</code>` or `<code>PUT</code>` <a for=/>request</a> needs a
+body, you can assign or stream it to <a for=/>request</a>'s <a for=request>body</a>. [[HTTP]]
+
+<p>Set your <a for=/>request</a>'s <a for=request>client</a> to the
+<a>environment settings object</a> you're operating in. Web-exposed APIs usually operate on
+<a>platform objects</a> (e.g. a <cite>Web IDL</cite> based API), which have a
+<a>relevant settings object</a>. For example, a <a for=/>request</a> associated with a DOM
+<a for=/>element</a> would set the <a for=/>request</a>'s <a for=request>client</a> to the element's
+<a>node document</a>'s <a>relevant settings object</a>. [[WEBIDL]]

For the first, I might be understanding something different by "web-exposed": the result doesn't get reported to Javascript running in a web page, but developers building websites will have their designs broken if it changes.

For the second, the relevant settings object's window may have closed by the time the fetch is sent, which means it can't use that as its *client*. Maybe the right answer is to start a Service Worker to exist while the fetch is running, so that can be the *client*, but the feature's designers need someone to tell them that, and help work through the tradeoffs.

For the third, the JS observer isn't really important, but there is a global available in the [algorithm's caller](https://w3c.github.io/reporting/#send-reports), so the use of `null` is just a bug. But the developers *thought* they didn't have one, maybe because the algorithm originally ran after the originating client closed. They should have a way to ask what to do, so someone knowledgeable can find them the right client.

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

Message ID: <whatwg/fetch/pull/1585/review/1237809520@github.com>

Received on Thursday, 5 January 2023 17:59:14 UTC