Skip to content

Commit

Permalink
Clarify package data algorithm for FormData
Browse files Browse the repository at this point in the history
Fixes #392.
  • Loading branch information
eehakkin authored and annevk committed Dec 16, 2016
1 parent eb89fcd commit e03ee6f
Showing 1 changed file with 28 additions and 8 deletions.
36 changes: 28 additions & 8 deletions fetch.bs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ Translate IDs: typedefdef-bodyinit bodyinit,typedefdef-responsebodyinit response
<script src=https://resources.whatwg.org/dfn.js defer id=head></script>

<pre class=anchors>
url:https://xhr.spec.whatwg.org/#concept-formdata-entry;spec:XHR;type:dfn;text:entries
url:https://xhr.spec.whatwg.org/#concept-formdata-entry;spec:xhr;type:dfn;
text:entry
text:entries
url:https://tools.ietf.org/html/rfc7230#section-3.1.1;text:method;type:dfn;spec:http
url: https://tools.ietf.org/html/rfc7230#section-3.2;text:field-name;type:dfn;spec:http
url: https://tools.ietf.org/html/rfc7230#section-3.2;text:field-content; type:dfn;spec:http
Expand Down Expand Up @@ -4360,16 +4362,34 @@ runs the associated steps:
run these substeps:

<ol>
<li><p>Parse <var>bytes</var>, using the value of the `<code>boundary</code>` parameter from
<var>MIME type</var> and <a>utf-8</a> as encoding, per the rules set forth in
<cite>Returning Values from Forms: multipart/form-data</cite>.
[[!RFC7578]]
<li>
<p>Parse <var>bytes</var>, using the value of the `<code>boundary</code>` parameter from
<var>MIME type</var>, per the rules set forth in
<cite>Returning Values from Forms: multipart/form-data</cite>. [[!RFC7578]]</p>

<p>Each part whose `<code>Content-Disposition</code>` header contains a `<code>filename</code>`
parameter must be parsed into an <a>entry</a> whose value is a {{File}} whose content is the
content of the part. The {{File/name}} attribute of the {{File}} must have the value of the
`<code>filename</code>` parameter of the part. The {{Blob/type}} attribute of the {{File}} must
have the value of the `<code>Content-Type</code>` header of the part if the part has such
header, and `<code>text/plain</code>` (the default defined by [[!RFC7578]] section 4.4)
otherwise.</p>

<p>Each part whose `<code>Content-Disposition</code>` header does not contain a
`<code>filename</code>` parameter must be parsed into an <a>entry</a> whose value is the
<a>UTF-8 decoded</a> content of the part. <span class=note>This is done regardless of the
presence or the value of a `<code>Content-Type</code>` header and regardless of the presence or
the value of a `<code>charset</code>` parameter.</span></p>

<p class=note>A part whose `<code>Content-Disposition</code>` header contains a
`<code>name</code>` parameter whose value is `<code>_charset_</code>` is parsed like any other
part. It does not change the encoding.</p>
</li>

<li><p>If that fails for some reason, then <a>throw</a> a <code>TypeError</code>.

<li><p>Return a new {{FormData}} object, appending each entry,
resulting from the parsing operation, to
<a>entries</a>.
<li><p>Return a new {{FormData}} object, appending each <a>entry</a>, resulting from the parsing
operation, to <a>entries</a>.
</ol>

<p class=XXX>The above is a rough approximation of what is needed for
Expand Down

0 comments on commit e03ee6f

Please sign in to comment.