Skip to content

Commit 3be61d4

Browse files
CORS: more information for server developers
Fixes #1102. Co-authored-by: Michael[tm] Smith <[email protected]>
1 parent 9bfe9e7 commit 3be61d4

File tree

1 file changed

+36
-11
lines changed

1 file changed

+36
-11
lines changed

fetch.bs

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2879,15 +2879,14 @@ element, a <a>CORS-preflight request</a> is performed, to ensure <a for=/>reques
28792879
<h4 id=http-requests>HTTP requests</h4>
28802880

28812881
<p>A <dfn export>CORS request</dfn> is an HTTP request that includes an
2882-
`<a http-header><code>Origin</code></a>` header. It cannot be reliably identified as participating in
2883-
the <a>CORS protocol</a> as the `<a http-header><code>Origin</code></a>` header is also included for
2884-
all <a for=/>requests</a> whose <a for=request>method</a> is neither `<code>GET</code>` nor
2882+
`<a http-header><code>Origin</code></a>` header. It cannot be reliably identified as participating
2883+
in the <a>CORS protocol</a> as the `<a http-header><code>Origin</code></a>` header is also included
2884+
for all <a for=/>requests</a> whose <a for=request>method</a> is neither `<code>GET</code>` nor
28852885
`<code>HEAD</code>`.
28862886

2887-
<p>A <dfn id=cors-preflight-request export>CORS-preflight request</dfn> is a <a>CORS request</a> that checks to see
2888-
if the <a>CORS protocol</a> is understood. It uses `<code>OPTIONS</code>` as
2889-
<a for=/>method</a> and includes these
2890-
<a for=/>headers</a>:
2887+
<p>A <dfn id=cors-preflight-request export>CORS-preflight request</dfn> is a <a>CORS request</a>
2888+
that checks to see if the <a>CORS protocol</a> is understood. It uses `<code>OPTIONS</code>` as
2889+
<a for=/>method</a> and includes these <a for=/>headers</a>:
28912890

28922891
<dl>
28932892
<dt>`<dfn export http-header id=http-access-control-request-method><code>Access-Control-Request-Method</code></dfn>`
@@ -2958,10 +2957,35 @@ if the <a>CORS protocol</a> is understood. It uses `<code>OPTIONS</code>` as
29582957

29592958
<hr>
29602959

2961-
<p>In case a server does not wish to participate in the <a>CORS protocol</a>, its HTTP response to
2962-
the <a lt="CORS request">CORS</a> or <a>CORS-preflight request</a> must not include any of the above
2963-
<a for=/>headers</a>. The server is encouraged to use the 403 <a for=/>status</a> in such HTTP
2964-
responses.
2960+
<p>A successful HTTP response, i.e., one where the server developer intends to share it, to a
2961+
<a>CORS request</a> can use any <a for=/>status</a>, as long as it includes the <a for=/>headers</a>
2962+
stated above with <a for=header>values</a> matching up with the request.
2963+
2964+
<p>A successful HTTP response to a <a>CORS-preflight request</a> is similar, except it is restricted
2965+
to an <a for=/>ok status</a>, e.g., 200 or 204.
2966+
2967+
<p>Any other kind of HTTP response is not successful and will either end up not being shared or fail
2968+
the <a>CORS-preflight request</a>. Be aware that any work the server performs might nonetheless leak
2969+
through side channels, such as timing. If server developers wish to denote this explicitly, the 403
2970+
<a for=/>status</a> can be used, coupled with omitting the relevant <a for=/>headers</a>.
2971+
2972+
<p class=note>If desired, “failure” could also be shared, but that would make it a successful HTTP
2973+
response. That is why for a successful HTTP response to a <a>CORS request</a> that is not a
2974+
<a>CORS-preflight requests</a> the <a for=/>status</a> can be anything, including 403.
2975+
2976+
<p>Ultimately server developers have a lot of freedom in how they handle HTTP responses and these
2977+
tactics can differ between the response to the <a>CORS-preflight request</a> and the
2978+
<a>CORS request</a> that follows it:
2979+
2980+
<ul>
2981+
<li><p>They can provide a static response. This can be helpful when working with caching
2982+
intermediaries. A static response can both be successful and not successful depending on the
2983+
<a>CORS request</a>. This is okay.
2984+
2985+
<li><p>They can provide a dynamic response, tuned to <a>CORS request</a>. This can be helpful when
2986+
the response body is to be tailored to a specific origin or a response needs to have credentials
2987+
and be successful for a set of origins.
2988+
</ul>
29652989

29662990

29672991
<h4 id=http-new-header-syntax>HTTP new-header syntax</h4>
@@ -8086,6 +8110,7 @@ Raphael Kubo da Costa,
80868110
Robert Linder,
80878111
Rondinelly,
80888112
Rory Hewitt,
8113+
Ross A. Baker,
80898114
Ryan Sleevi,
80908115
Samy Kamkar,
80918116
Sébastien Cevey,

0 commit comments

Comments
 (0)