Skip to content
This repository was archived by the owner on Nov 30, 2024. It is now read-only.

Commit 8f994ff

Browse files
andreubotellaEthan Arrowood
andauthored
Relax forbidden header restrictions for non-browser runtimes (#19)
* Relax forbidden header restrictions for non-browser runtimes Web browsers treat certain request and response headers as forbidden –forbidden request headers are impossible to set in requests, and forbidden response headers are always filtered off of even basic filtered response (i.e. responses for same-origin fetches). While some of these forbidden request headers make sense generally (for example, `Date`, `Host`, `Transfer-Encoding`), others don't make sense for implementers that don't support CORS or cookies. And the only forbidden response headers (`Set-Cookie` and `Set-Cookie2`) only make sense for implementers that support cookies. To allow different kinds of implementers with different requirements, this change adds a "conformance classes" section defining support for CORS and cookies. It then changes the definitions of forbidden request and response headers to depend on the user agent's conformance classes. * Update fetch.bs Co-authored-by: Ethan Arrowood <[email protected]> * Update fetch.bs Co-authored-by: Ethan Arrowood <[email protected]> --------- Co-authored-by: Ethan Arrowood <[email protected]>
1 parent bbb32fa commit 8f994ff

File tree

1 file changed

+63
-12
lines changed

1 file changed

+63
-12
lines changed

fetch.bs

Lines changed: 63 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,14 @@ server-side runtimes, and on the long term to upstream those changes into the WH
200200
<p>The changes from the WHATWG spec so far are:
201201

202202
<ul>
203-
<li><p>(none)
203+
<li><p>Added [[#conformance-classes]] to describe the various types of runtimes implementing this
204+
fork.
205+
206+
<li><p>Made the <a>forbidden request-header</a> and <a>forbidden response-header name</a>
207+
definitions dependent on whether the user agent <a>supports CORS</a> and
208+
<a lt="support cookies">cookies</a>. This affects the headers of <a>basic filtered responses</a>,
209+
as well as <a for=Headers lt=validate>validation</a> in {{Headers}} objects. The behavior for web
210+
browsers doesn't change.
204211
</ul>
205212

206213
<p class=XXX>Please update this list as new changes are added.
@@ -210,9 +217,6 @@ server-side runtimes, and on the long term to upstream those changes into the WH
210217
<ul>
211218
<li><p>Remove CORS restrictions for runtimes with no concept of origins.
212219

213-
<li><p>Specify how headers are filtered in {{Request}} and {{Response}} instances in various
214-
runtimes.
215-
216220
<li><p>Specify how relative URLs resolve in {{fetch}} and the {{Request}} constructor for runtimes
217221
without a concept of <a>API base URL</a>.
218222

@@ -269,6 +273,32 @@ exposes most of the networking functionality at a fairly low level of abstractio
269273

270274

271275

276+
<h2 id=conformance-classes>Conformance classes</h2>
277+
278+
<p>This specification applies to any <a spec="infra">user agent</a> that chooses to implement it.
279+
However, different types of user agent have different needs in regards to fetching, and so this
280+
specification defines different categories among which implementers might fall.
281+
282+
<p>A user agent implementing this specification:
283+
284+
<dl>
285+
<dt><dfn>supports CORS</dfn></dt>
286+
<dd>if it has a concept of an <a for=/>origin</a> which the current ECMAScript execution context
287+
runs in, and which defines a security boundary with code and data from other origins. [[!HTML]]
288+
[[ORIGIN]]
289+
290+
<dt><dfn>supports cookies</dfn></dt>
291+
<dd>if it supports the user agent requirements of [[!COOKIES]]. For the purposes of this
292+
specification, user agents which don't <a>support cookies</a> must act as if they were configured
293+
to block cookies for all requests and responses (see
294+
<a href=https://httpwg.org/specs/rfc6265.html#privacy-considerations>section 7</a> of
295+
[[!COOKIES]]).
296+
</dl>
297+
298+
<p class=note>Web browsers support both CORS and cookies.
299+
300+
301+
272302
<h2 id=infrastructure>Infrastructure</h2>
273303

274304
<p>This specification depends on the Infra Standard. [[!INFRA]]
@@ -1268,20 +1298,14 @@ is a <a>byte-case-insensitive</a> match for one of
12681298
<ul class=brief>
12691299
<li>`<code>Accept-Charset</code>`
12701300
<li>`<code>Accept-Encoding</code>`
1271-
<li>`<a http-header><code>Access-Control-Request-Headers</code></a>`
1272-
<li>`<a http-header><code>Access-Control-Request-Method</code></a>`
12731301
<li>`<code>Connection</code>`
12741302
<li>`<code>Content-Length</code>`
1275-
<li>`<code>Cookie</code>`
1276-
<li>`<code>Cookie2</code>`
12771303
<li>`<code>Date</code>`
12781304
<li>`<code>DNT</code>`
12791305
<li>`<code>Expect</code>`
12801306
<li>`<code>Host</code>`
12811307
<li>`<code>Keep-Alive</code>`
1282-
<li>`<a http-header><code>Origin</code></a>`
12831308
<li>`<code>Referer</code>`
1284-
<li>`<code>Set-Cookie</code>`
12851309
<li>`<code>TE</code>`
12861310
<li>`<code>Trailer</code>`
12871311
<li>`<code>Transfer-Encoding</code>`
@@ -1291,6 +1315,30 @@ is a <a>byte-case-insensitive</a> match for one of
12911315

12921316
<p>then return true.
12931317

1318+
<li>
1319+
<p>If the user agent <a>supports CORS</a> and <var>name</var> is a <a>byte-case-insensitive</a>
1320+
match for one of:
1321+
1322+
<ul class=brief>
1323+
<li>`<a http-header><code>Access-Control-Request-Headers</code></a>`
1324+
<li>`<a http-header><code>Access-Control-Request-Method</code></a>`
1325+
<li>`<a http-header><code>Origin</code></a>`
1326+
</ul>
1327+
1328+
<p>then return true.
1329+
1330+
<li>
1331+
<p>If the user agent <a>supports cookies</a> and <var>name</var> is a <a>byte-case-insensitive</a>
1332+
match for one of:
1333+
1334+
<ul class=brief>
1335+
<li>`<code>Cookie</code>`
1336+
<li>`<code>Cookie2</code>`
1337+
<li>`<code>Set-Cookie</code>`
1338+
</ul>
1339+
1340+
<p>then return true.
1341+
12941342
<li><p>If <var>name</var> when <a>byte-lowercased</a> <a for="byte sequence">starts with</a>
12951343
`<code>proxy-</code>` or `<code>sec-</code>`, then return true.
12961344

@@ -1330,13 +1378,16 @@ is a <a>byte-case-insensitive</a> match for one of
13301378
</div>
13311379
</div>
13321380

1333-
<p>A <dfn export>forbidden response-header name</dfn> is a <a for=/>header name</a> that is a
1334-
<a>byte-case-insensitive</a> match for one of:
1381+
<div algorithm>
1382+
<p>A <a for=/>header name</a> <var>name</var> is a <dfn export>forbidden response-header name</dfn>
1383+
if the user agent <a>supports cookies</a> and <var>name</var> is a <a>byte-case-insensitive</a>
1384+
match for one of:
13351385

13361386
<ul class=brief>
13371387
<li>`<code>Set-Cookie</code>`
13381388
<li>`<code>Set-Cookie2</code>`
13391389
</ul>
1390+
</div>
13401391

13411392
<p>A <dfn export>request-body-header name</dfn> is a <a for=/>header name</a> that is a
13421393
<a>byte-case-insensitive</a> match for one of:

0 commit comments

Comments
 (0)