- From: Anne van Kesteren <notifications@github.com>
- Date: Mon, 22 May 2023 02:59:49 -0700
- To: whatwg/fetch <fetch@noreply.github.com>
- Cc: Subscribed <subscribed@noreply.github.com>
- Message-ID: <whatwg/fetch/pull/1657/review/1436244287@github.com>
@annevk commented on this pull request. > <p>Objects including the {{Body}} interface mixin need to define an associated -<dfn id=concept-body-mime-type for=Body>MIME type</dfn> algorithm which takes no arguments and -returns failure or a <a for=/>MIME type</a>. +<dfn id=concept-body-mime-type for=Body>MIME type</dfn> algorithm which returns the result of +<a for=Body>get the MIME type</a> with <a>this</a>. I think we should remove this, no? Callers can use "get the MIME type" directly. > @@ -7168,6 +7168,24 @@ returns failure or a <a for=/>MIME type</a>. <hr> +<div algorithm> +<p>To <dfn id=concept-body-get-mime-type for=Body>get the MIME type</dfn>, given an object, <var>requestOrResponse</var>, including the +{{Body}} interface mixin, run these steps: Either > given an object that includes Body _objectThatIncludesBody_: or > given a Request or Response object _requestOrResponse_: The latter is probably best as the algorithm will have to branch on them as well. > @@ -7168,6 +7168,24 @@ returns failure or a <a for=/>MIME type</a>. <hr> +<div algorithm> +<p>To <dfn id=concept-body-get-mime-type for=Body>get the MIME type</dfn>, given an object, <var>requestOrResponse</var>, including the +{{Body}} interface mixin, run these steps: + +<ol> + <li><p>If <var>requestOrResponse</var>'s has an associated <a for=Headers>header list</a>, This needs to be something like: > 1. Let _headers_ be null. > 2. If _requestOrResponse_ is a Request object, then set _headers_ to _requestOrResponse_'s request's header list. > 3. Otherwise, set _headers_ to _requestOrResponse_'s response's header list. > 4. [Do something with _headers_.] > +<p>A {{Request}} object's <a for=Body>MIME type</a> is to <a for=Body>get the MIME type</a> with +<a>this</a>. We should be able to remove this completely. Same for the equivalent on Response. > + <li><p>Let <var>bodyWithType</var> be the result of <a for=BodyInit>extracting</a> <a>this</a>'s + <a for=Body>body</a>. + <li><p>Return <var>bodyWithType</var>'s <a for="body with type">type</a>. This shouldn't be needed. This already happens as part of constructing a Request or Response, no? > </div> <div algorithm> <p>The <dfn method for=Body><code>formData()</code></dfn> method steps are to return the result of running <a for=Body>consume body</a> with <a>this</a> and the following step given a -<a for=/>byte sequence</a> <var>bytes</var>: switch on <a>this</a>'s <a for=Body>MIME type</a>'s -<a for="MIME type">essence</a> and run the corresponding steps: +<a for=/>byte sequence</a> <var>bytes</var>: + +<ol> +<li><p>Let <var>mimeType</var> be the result of <a for=Body>get the MIME type</a> with <a>this</a>. +<li> + <p>Switch on <var>mimeType</var>'s <a for="MIME type">essence</a> and run the corresponding + steps: It looks like the text here was wrong before as MIME type can be null. So we probably need to pull the "Otherwise" branch forward and deal with that here. I guess it's fair if you want to leave that as a follow-up as you didn't introduce it. -- Reply to this email directly or view it on GitHub: https://github.com/whatwg/fetch/pull/1657#pullrequestreview-1436244287 You are receiving this because you are subscribed to this thread. Message ID: <whatwg/fetch/pull/1657/review/1436244287@github.com>
Received on Monday, 22 May 2023 09:59:55 UTC