From 2c939cb4848a83d396d5e59ed64fe78f09c6d0a4 Mon Sep 17 00:00:00 2001 From: Guohui Deng Date: Wed, 11 Dec 2024 15:38:31 -0700 Subject: [PATCH 1/4] Add Content Encoding response header to fetch. --- fetch.bs | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/fetch.bs b/fetch.bs index 5cbfef67..572db72c 100644 --- a/fetch.bs +++ b/fetch.bs @@ -370,6 +370,8 @@ following items: [[RESOURCE-TIMING]] [[NAVIGATION-TIMING]]
A number.
content type (default the empty string)
An ASCII string. +
content encoding (default the empty string) +
An ASCII string.
@@ -1132,6 +1134,7 @@ a byte-case-insensitive match for one of
  • `Content-Language`
  • `Content-Length`
  • `Content-Type` +
  • `Content-Encoding`
  • `Expires`
  • `Last-Modified`
  • `Pragma` @@ -1147,6 +1150,7 @@ is a byte-case-insensitive match for one of
  • `Accept-Language`
  • `Content-Language`
  • `Content-Type` +
  • `Content-Encoding`
    @@ -3946,6 +3950,40 @@ Content-Type:
  • +

    `Content-Encoding` header

    + +

    The `Content-Encoding` header is largely defined in HTTP. Its processing model is +defined here as the model defined in HTTP is not compatible with web content. [[HTTP]] + +

    +

    To +extract an encoding type from a header list headers, run these steps: + +

      +
    1. Let values be the result of + getting, decoding, and splitting `Content-Encoding` from + headers. + +

    2. If values is null, then return null. + +

    3. Let candidateValue be null. + +

    4. +

      For each value of values: + +

        +
      1. If candidateValue is null, then set candidateValue to + value. + +

      2. Otherwise, if value is not candidateValue, return failure. +

      + +
    5. If candidateValue is the empty string or has a code point that is + not an ASCII digit, then return null. + +

    6. Return candidateValue, interpreted as a string. +

    +

    `X-Content-Type-Options` header

    @@ -9127,6 +9165,7 @@ Gavin Carothers, Glenn Maynard, Graham Klyne, Gregory Terzian, +Guohui Deng, Hal Lockhart, Hallvord R. M. Steen, Harris Hancock, From dc2b573104ee9f92144ab1f4a0e32e38e4fe190a Mon Sep 17 00:00:00 2001 From: Guohui Deng Date: Thu, 12 Dec 2024 15:03:12 -0700 Subject: [PATCH 2/4] Add more about content-encoding And some corrections. --- fetch.bs | 44 +++++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/fetch.bs b/fetch.bs index 572db72c..ae5f361c 100644 --- a/fetch.bs +++ b/fetch.bs @@ -1134,7 +1134,6 @@ a byte-case-insensitive match for one of
  • `Content-Language`
  • `Content-Length`
  • `Content-Type` -
  • `Content-Encoding`
  • `Expires`
  • `Last-Modified`
  • `Pragma` @@ -1150,7 +1149,6 @@ is a byte-case-insensitive match for one of
  • `Accept-Language`
  • `Content-Language`
  • `Content-Type` -
  • `Content-Encoding`
    @@ -1180,6 +1178,7 @@ is a byte-case-insensitive match for one of
  • `Access-Control-Request-Headers`
  • `Access-Control-Request-Method`
  • `Connection` +
  • `Content-Encoding`
  • `Content-Length`
  • `Cookie`
  • `Cookie2` @@ -5042,6 +5041,12 @@ steps:
  • Let type be blob's {{Blob/type}}. +

  • Let accept-coding be the result of getting + `Content-Encoding` from request's header list. + If accept-encoding is not null and the server selects one of the encoding options, + let coding be the selected encoding option; otherwise, i.e., let coding + be null. +

  • If request's header list does not contain `Range`: @@ -5058,6 +5063,10 @@ steps:

  • Set response's header list to « (`Content-Length`, serializedFullLength), (`Content-Type`, type) ». + +

  • If coding is non-null, append (`Content-Encoding`, + coding) to response's header list. +

  • @@ -5127,6 +5136,9 @@ steps: (`Content-Length`, serializedSlicedLength), (`Content-Type`, type), (`Content-Range`, contentRange) ». + +
  • If coding is non-null, append (`Content-Encoding`, + coding) to response's header list.

  • Return response. @@ -5143,10 +5155,28 @@ steps:

  • Let mimeType be dataURLStruct's MIME type, serialized. -

  • Return a new response whose status message is - `OK`, header list is « (`Content-Type`, - mimeType) », and body is dataURLStruct's - body as a body. +

  • Let accept-coding be the result of getting + `Content-Encoding` from request's header list. + If accept-encoding is not null and the server selects one of the encoding options, + let coding be the selected encoding option; otherwise, i.e., let coding + be null. +

  • Let response be a new response. + +

  • Set response's status message to + OK`. + +

  • Set response's header list to « + (`Content-Type`, mimeType)». + +

  • If coding is non-null, append + (`Content-Encoding`, coding) to response's + header list. + +

  • Set response's body to dataURLStruct's + body + +

  • Return response. +

    "file" @@ -9165,7 +9195,7 @@ Gavin Carothers, Glenn Maynard, Graham Klyne, Gregory Terzian, -Guohui Deng, +Guohui Deng(邓国辉), Hal Lockhart, Hallvord R. M. Steen, Harris Hancock, From 7647a50a7ea4439ee19696f679de657ec97ff399 Mon Sep 17 00:00:00 2001 From: Guohui Deng Date: Fri, 13 Dec 2024 10:10:38 -0700 Subject: [PATCH 3/4] Remove a trailing space. --- fetch.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fetch.bs b/fetch.bs index ae5f361c..3b4e1834 100644 --- a/fetch.bs +++ b/fetch.bs @@ -5168,7 +5168,7 @@ steps:
  • Set response's header list to « (`Content-Type`, mimeType)». -

  • If coding is non-null, append +

  • If coding is non-null, append (`Content-Encoding`, coding) to response's header list. From f7bdfa950870cd978832dcbd03e79fbfae549201 Mon Sep 17 00:00:00 2001 From: Guohui Deng Date: Mon, 16 Dec 2024 14:48:34 -0700 Subject: [PATCH 4/4] content-encoding always available --- fetch.bs | 46 +++++++++++++++++----------------------------- 1 file changed, 17 insertions(+), 29 deletions(-) mode change 100644 => 100755 fetch.bs diff --git a/fetch.bs b/fetch.bs old mode 100644 new mode 100755 index 3b4e1834..1c6f3f50 --- a/fetch.bs +++ b/fetch.bs @@ -5042,10 +5042,11 @@ steps:

  • Let type be blob's {{Blob/type}}.

  • Let accept-coding be the result of getting - `Content-Encoding` from request's header list. + `Accept-Encoding` from request's header list. If accept-encoding is not null and the server selects one of the encoding options, - let coding be the selected encoding option; otherwise, i.e., let coding - be null. + let coding be the selected encoding option; otherwise, i.e., no encoding is used, + let coding be + "identity".

  • If request's header list @@ -5062,10 +5063,8 @@ steps:

  • Set response's header list to « (`Content-Length`, serializedFullLength), - (`Content-Type`, type) ». - -

  • If coding is non-null, append (`Content-Encoding`, - coding) to response's header list. + (`Content-Type`, type), + (`Content-Encoding`, coding) ». @@ -5135,10 +5134,8 @@ steps:

  • Set response's header list to « (`Content-Length`, serializedSlicedLength), (`Content-Type`, type), (`Content-Range`, - contentRange) ». + contentRange), (`Content-Encoding`, coding) ». -

  • If coding is non-null, append (`Content-Encoding`, - coding) to response's header list.

  • Return response. @@ -5156,26 +5153,17 @@ steps: MIME type, serialized.

  • Let accept-coding be the result of getting - `Content-Encoding` from request's header list. + `Accept-Encoding` from request's header list. If accept-encoding is not null and the server selects one of the encoding options, - let coding be the selected encoding option; otherwise, i.e., let coding - be null. -

  • Let response be a new response. - -

  • Set response's status message to - OK`. - -

  • Set response's header list to « - (`Content-Type`, mimeType)». - -

  • If coding is non-null, append - (`Content-Encoding`, coding) to response's - header list. - -

  • Set response's body to dataURLStruct's - body - -

  • Return response. + let coding be the selected encoding option; otherwise, i.e., no encoding is used, + let coding be + "identity". + +

  • Return a new response whose status message is + `OK`, header list is « (`Content-Type`, + mimeType), (`Content-Encoding`, coding) », and + body is dataURLStruct's + body as a body.