Skip to content

Commit 4175080

Browse files
authored
Allow enctype to be specified (#54)
* Allow enctype to be specified POST supports "application/x-www-form-urlencoded" and "multipart/form-data". resolves #47 * enctype ignored for GET
1 parent 2c378e8 commit 4175080

File tree

1 file changed

+44
-2
lines changed

1 file changed

+44
-2
lines changed

index.html

Lines changed: 44 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ <h2>
200200
dictionary ShareTarget {
201201
required USVString action;
202202
DOMString method = "GET";
203+
DOMString enctype = "application/x-www-form-urlencoded";
203204
required ShareTargetParams params;
204205
};
205206

@@ -260,6 +261,19 @@ <h3>
260261
developer warning</a> that the method is not supported, and return
261262
<code>undefined</code>.
262263
</li>
264+
<li>If <var>share target</var>["<a data-link-for=
265+
"ShareTarget">method</a>"] is an <a data-cite=
266+
"!INFRA#ascii-case-insensitive">ASCII case-insensitive</a> match for
267+
the string <code>"POST"</code> and <var>share
268+
target</var>["<a data-link-for="ShareTarget">enctype</a>"] is neither
269+
an <a data-cite="!INFRA#ascii-case-insensitive">ASCII
270+
case-insensitive</a> match for the strings
271+
<code>"application/x-www-form-urlencoded"</code> nor
272+
<code>"multipart/form-data"</code>, <a data-cite=
273+
"!appmanifest#dfn-issue-a-developer-warning">issue a developer
274+
warning</a> that the enctype is not supported, and return
275+
<code>undefined</code>.
276+
</li>
263277
<li>Let <var>action</var> be the result of <a data-cite=
264278
"!URL#concept-url-parser">parsing</a> the <a data-cite=
265279
"!URL#concept-url">URL</a> <var>share
@@ -301,6 +315,11 @@ <h3>
301315
"https://tools.ietf.org/html/rfc7231#section-4">method</a> for the
302316
<a data-link-for="web share targets">web share target</a>.
303317
</p>
318+
<p>
319+
The <dfn>enctype</dfn> member specifies how the share data is encoded
320+
in the body of a <code>POST</code> request. It is ignored when
321+
<a>method</a> is <code>"GET"</code>.
322+
</p>
304323
<p>
305324
The <dfn>params</dfn> member contains a <a>ShareTargetParams</a>
306325
dictionary.
@@ -489,6 +508,10 @@ <h3>
489508
<var>manifest</var>["<a>share_target</a>"]["<a data-link-for=
490509
"ShareTarget">method</a>"].
491510
</li>
511+
<li>Let <var>enctype</var> be
512+
<var>manifest</var>["<a>share_target</a>"]["<a data-link-for=
513+
"ShareTarget">enctype</a>"].
514+
</li>
492515
<li>If <var>method</var> is <code>"GET"</code>:
493516
<ol>
494517
<li>Let <var>query</var> be the result of running the
@@ -504,7 +527,26 @@ <h3>
504527
</li>
505528
</ol>
506529
</li>
507-
<li>Otherwise, if <var>method</var> is <code>"POST"</code>:
530+
<li>Otherwise, if <var>method</var> is <code>"POST"</code> and <var>
531+
enctype</var> is <code>"application/x-www-form-urlencoded"</code>:
532+
<ol>
533+
<li>Let <var>body</var> be the result of running the
534+
<a data-cite="!URL#concept-urlencoded-serializer"><code>application/x-www-form-urlencoded</code>
535+
serializer</a> with <var>entry list</var> and no encoding
536+
override.
537+
</li>
538+
<li>Set <var>body</var> to the result of <a data-cite=
539+
"!Encoding#utf-8-encode">encoding</a> <var>body</var>.
540+
</li>
541+
<li>
542+
<a data-cite="!FETCH/#concept-header-list-append">Append</a>
543+
<code>"Content-Type"</code>/<code>"application/x-www-form-urlencoded"</code>
544+
to <var>header list</var>.
545+
</li>
546+
</ol>
547+
</li>
548+
<li>Otherwise, if <var>method</var> is <code>"POST"</code> and <var>
549+
enctype</var> is <code>"multipart/form-data"</code>:
508550
<ol>
509551
<li>Let <var>body</var> be the result of running the
510552
<a data-cite="!HTML#multipart/form-data-encoding-algorithm"><code>
@@ -522,7 +564,7 @@ <h3>
522564
</li>
523565
<li>
524566
<a data-cite="!FETCH/#concept-header-list-append">Append</a>
525-
<code>Content-Type</code>/<var>MIME type</var> to <var>header
567+
<code>"Content-Type"</code>/<var>MIME type</var> to <var>header
526568
list</var>.
527569
</li>
528570
</ol>

0 commit comments

Comments
 (0)