From 2c939cb4848a83d396d5e59ed64fe78f09c6d0a4 Mon Sep 17 00:00:00 2001 From: Guohui Deng Date: Wed, 11 Dec 2024 15:38:31 -0700 Subject: [PATCH 01/10] Add Content Encoding response header to fetch. --- fetch.bs | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/fetch.bs b/fetch.bs index 5cbfef674..572db72cf 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 02/10] 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 572db72cf..ae5f361c2 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 03/10] Remove a trailing space. --- fetch.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fetch.bs b/fetch.bs index ae5f361c2..3b4e18347 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 04/10] 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 3b4e18347..1c6f3f508 --- 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. From 94ecd4c65defe97e4ed73d52730a89c8195bda02 Mon Sep 17 00:00:00 2001 From: Guohui Deng Date: Tue, 14 Jan 2025 14:11:06 -0700 Subject: [PATCH 05/10] Fix indentation and the "let" in the middle of sentence. --- fetch.bs | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/fetch.bs b/fetch.bs index 1c6f3f508..11ea71c4c 100755 --- a/fetch.bs +++ b/fetch.bs @@ -5041,11 +5041,13 @@ steps:

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

  • Let coding be the empty string. +

  • Let accept-coding be the result of getting - `Accept-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., no encoding is used, - let coding be + set coding to the selected encoding option; otherwise, i.e., no encoding is used, + set coding to "identity".

  • @@ -5152,11 +5154,13 @@ steps:
  • Let mimeType be dataURLStruct's MIME type, serialized. +

  • Let coding be the empty string. +

  • Let accept-coding be the result of getting - `Accept-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., no encoding is used, - let coding be + set coding to the selected encoding option; otherwise, i.e., no encoding is used, + set coding to "identity".

  • Return a new response whose status message is From a00761414a5e328f277c609e44e552f73be90fea Mon Sep 17 00:00:00 2001 From: Guohui Deng Date: Tue, 21 Jan 2025 16:22:32 -0700 Subject: [PATCH 06/10] Fix a number of issues: 1) formatting; 2) "gzip, GZIP" is ok for they case-insensitive match. 3) there is a mistake saying that the "contentEncoding" consists of digits; 4) no longer returns "contentEncoding" for data url. --- fetch.bs | 32 ++++++++++---------------------- 1 file changed, 10 insertions(+), 22 deletions(-) diff --git a/fetch.bs b/fetch.bs index fd1545211..c2562d132 100755 --- a/fetch.bs +++ b/fetch.bs @@ -3973,12 +3973,10 @@ extract an encoding type from a header list headers

    If candidateValue is null, then set candidateValue to value. -

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

  • Otherwise, if value is not an ASCII case-insensitive match for + candidateValue, return failure. -

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

  • Return candidateValue, interpreted as a string. @@ -5047,12 +5045,12 @@ steps:

  • Let coding be the empty string. -

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

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

  • If request's header list @@ -5158,20 +5156,10 @@ steps:

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

  • Let coding be the empty string. - -

  • Let accept-coding be the result of getting - `Accept-Encoding` from request's header list. - If accept-encoding is not null and the server selects one of the encoding options, - set coding to the selected encoding option; otherwise, i.e., no encoding is used, - set coding to - "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. + mimeType) », and body is dataURLStruct's + body as a body. From 46c10a9ebf21f129dbfc5fc6e30015aa5e31e050 Mon Sep 17 00:00:00 2001 From: Guohui Deng Date: Wed, 22 Jan 2025 11:37:42 -0700 Subject: [PATCH 07/10] Remove spurious new lines and correct a paragraph That's on the client side getting the reponse header. --- fetch.bs | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/fetch.bs b/fetch.bs index c2562d132..475bcb3fd 100755 --- a/fetch.bs +++ b/fetch.bs @@ -5043,14 +5043,8 @@ steps:

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

  • Let coding be the empty string. - -

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

  • Let contentEncoding be the result of getting + `Content-Encoding` from request's header list.

  • If request's header list @@ -5068,7 +5062,7 @@ steps:

  • Set response's header list to « (`Content-Length`, serializedFullLength), (`Content-Type`, type), - (`Content-Encoding`, coding) ». + (`Content-Encoding`, contentEncoding) ». @@ -5138,8 +5132,7 @@ steps:

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

  • Return response. @@ -5160,7 +5153,6 @@ steps: `OK`, header list is « (`Content-Type`, mimeType) », and body is dataURLStruct's body as a body. -

    "file" From a96300830a9e4e1df2bc78649498717c114e85f8 Mon Sep 17 00:00:00 2001 From: Guohui Deng Date: Wed, 22 Jan 2025 15:19:38 -0700 Subject: [PATCH 08/10] Simply Just add the content encoding to body info. --- fetch.bs | 45 +++++---------------------------------------- 1 file changed, 5 insertions(+), 40 deletions(-) diff --git a/fetch.bs b/fetch.bs index 475bcb3fd..3cee4f467 100755 --- a/fetch.bs +++ b/fetch.bs @@ -3948,39 +3948,6 @@ 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 an ASCII case-insensitive match for - candidateValue, return failure. -

      - -
    5. Return candidateValue, interpreted as a string. -

    -
    -

    `X-Content-Type-Options` header

    The @@ -5043,9 +5010,6 @@ steps:

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

  • Let contentEncoding be the result of getting - `Content-Encoding` from request's header list. -

  • If request's header list does not contain `Range`: @@ -5061,9 +5025,7 @@ steps:

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

  • @@ -5132,7 +5094,7 @@ steps:
  • Set response's header list to « (`Content-Length`, serializedSlicedLength), (`Content-Type`, type), (`Content-Range`, - contentRange), (`Content-Encoding`, contentEncoding) ». + contentRange) ».

  • Return response. @@ -6359,6 +6321,9 @@ optional boolean forceNewConnection (default false), run these steps:

  • Let codings be the result of extracting header list values given `Content-Encoding` and response's header list. +

  • Set response's body info's + content encoding to codings. +

  • Increase response's body info's encoded size by bytes's length. From 16f1d1f5c3aa911873a87fa8789acc5b4bd85b75 Mon Sep 17 00:00:00 2001 From: Guohui Deng Date: Thu, 23 Jan 2025 13:46:38 -0700 Subject: [PATCH 09/10] Fix: content-encoding not prohibited header. restore a new line. --- fetch.bs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fetch.bs b/fetch.bs index 3cee4f467..919470138 100755 --- a/fetch.bs +++ b/fetch.bs @@ -1178,7 +1178,6 @@ is a byte-case-insensitive match for one of

  • `Access-Control-Request-Headers`
  • `Access-Control-Request-Method`
  • `Connection` -
  • `Content-Encoding`
  • `Content-Length`
  • `Cookie`
  • `Cookie2` @@ -3948,6 +3947,7 @@ Content-Type: +

    `X-Content-Type-Options` header

    The From c5c0f55f25c880f93aa1b1c27a33a3bfa47201c1 Mon Sep 17 00:00:00 2001 From: Guohui Deng Date: Wed, 29 Jan 2025 11:12:14 -0700 Subject: [PATCH 10/10] content-encoding should be a list of strings. --- fetch.bs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/fetch.bs b/fetch.bs index 919470138..88dcc50b5 100755 --- a/fetch.bs +++ b/fetch.bs @@ -370,8 +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. +
    content encoding (default « ») +
    A list of strings.