diff --git a/fetch.bs b/fetch.bs index 3081acbdf..a5cec60f5 100644 --- a/fetch.bs +++ b/fetch.bs @@ -3747,7 +3747,8 @@ defined here as the model defined in HTTP is not compatible with web content. [[

To extract a MIME type -from a header list headers, run these steps: +from a header list headers, run these steps. They return failure or a +MIME type.

  1. Let charset be null. @@ -4773,7 +4774,7 @@ steps: extracting a MIME type from response's header list. -

  2. If mimeType is non-null, then set bodyInfo's +

  3. If mimeType is not failure, then set bodyInfo's content type to the result of minimizing a supported MIME type given mimeType.

@@ -7138,10 +7139,6 @@ HTML, will likely not be exposed here. Rather, an HTML parser API might accept a due course. -

Objects including the {{Body}} interface mixin need to define an associated -MIME type algorithm which takes no arguments and -returns failure or a MIME type. -

Objects including the {{Body}} interface mixin have an associated body (null or a body). @@ -7177,6 +7174,28 @@ returns failure or a MIME type.


+
+

To get the MIME type, given a {{Request}} or +{{Response}} object requestOrResponse: + +

    +
  1. Let headers be null. + +

  2. If requestOrResponse is a {{Request}} object, then set headers to + requestOrResponse's request's header list. + +

  3. Otherwise, set headers to requestOrResponse's + response's header list. + +

  4. Let mimeType be the result of extracting a MIME type + from headers. + +

  5. If mimeType is failure, then return null. + +

  6. Return mimeType. +

+
+

The body getter steps are to return null if this's body is null; otherwise this's body's @@ -7233,69 +7252,76 @@ of running consume body with this and the following step

The blob() method steps are to return the result of running consume body with this and the following step given a byte sequence bytes: return a {{Blob}} whose contents are bytes -and whose {{Blob/type}} attribute is this's MIME type. +and whose {{Blob/type}} attribute is the result of get the MIME type with +this. +

The formData() method steps are to return the result of running consume body with this and the following step given a -byte sequence bytes: switch on this's MIME type's -essence and run the corresponding steps: +byte sequence bytes: -

-
"multipart/form-data", -
-
    -
  1. -

    Parse bytes, using the value of the `boundary` parameter from - this's MIME type, per the rules set forth in - Returning Values from Forms: multipart/form-data. [[!RFC7578]]

    - -

    Each part whose `Content-Disposition` header contains a `filename` - parameter must be parsed into an entry whose value is a {{File}} object - whose contents are the contents of the part. The {{File/name}} attribute of the {{File}} object - must have the value of the `filename` parameter of the part. The {{Blob/type}} - attribute of the {{File}} object must have the value of the `Content-Type` header - of the part if the part has such header, and `text/plain` (the default defined by - [[!RFC7578]] section 4.4) otherwise.

    - -

    Each part whose `Content-Disposition` header does not contain a - `filename` parameter must be parsed into an entry whose - value is the UTF-8 decoded without BOM content of the part. - This is done regardless of the presence or the value of a - `Content-Type` header and regardless of the presence or the value of a - `charset` parameter.

    - -

    A part whose `Content-Disposition` header contains a - `name` parameter whose value is `_charset_` is parsed like any other - part. It does not change the encoding.

    -
  2. - -
  3. If that fails for some reason, then throw a {{TypeError}}. - -

  4. Return a new {{FormData}} object, appending each entry, resulting - from the parsing operation, to its entry list. -

+
    +
  1. Let mimeType be the result of get the MIME type with this. -

    The above is a rough approximation of what is needed for - `multipart/form-data`, a more detailed parsing specification is to be - written. Volunteers welcome. +

  2. +

    If mimeType is non-null, then switch on mimeType's + essence and run the corresponding steps: -

    "application/x-www-form-urlencoded", -
    -
      -
    1. Let entries be the result of parsing - bytes. +

      +
      "multipart/form-data" +
      +
        +
      1. +

        Parse bytes, using the value of the `boundary` parameter from + mimeType, per the rules set forth in + Returning Values from Forms: multipart/form-data. [[!RFC7578]] + +

        Each part whose `Content-Disposition` header contains a + `filename` parameter must be parsed into an entry whose + value is a {{File}} object whose contents are the contents of the part. The {{File/name}} + attribute of the {{File}} object must have the value of the `filename` parameter + of the part. The {{Blob/type}} attribute of the {{File}} object must have the value of the + `Content-Type` header of the part if the part has such header, and + `text/plain` (the default defined by [[!RFC7578]] section 4.4) otherwise. + +

        Each part whose `Content-Disposition` header does not contain a + `filename` parameter must be parsed into an entry whose + value is the UTF-8 decoded without BOM content of the + part. This is done regardless of the presence or the value of a + `Content-Type` header and regardless of the presence or the value of a + `charset` parameter. + +

        A part whose `Content-Disposition` header contains a + `name` parameter whose value is `_charset_` is parsed like any other + part. It does not change the encoding. + +

      2. If that fails for some reason, then throw a {{TypeError}}. + +

      3. Return a new {{FormData}} object, appending each entry, + resulting from the parsing operation, to its entry list. +

      -
    2. If entries is failure, then throw a {{TypeError}}. +

      The above is a rough approximation of what is needed for + `multipart/form-data`, a more detailed parsing specification is to be written. + Volunteers welcome. -

    3. Return a new {{FormData}} object whose entry list is - entries. -

    +
    "application/x-www-form-urlencoded" +
    +
      +
    1. Let entries be the result of parsing + bytes. -

      Otherwise -

      Throw a {{TypeError}}. -

+
  • If entries is failure, then throw a {{TypeError}}. + +

  • Return a new {{FormData}} object whose entry list is + entries. + + + +

  • Throw a {{TypeError}}. +

  • @@ -7387,10 +7413,6 @@ omitted from RequestMode as it cannot be used nor obser

    A {{Request}} object has an associated signal (null or an {{AbortSignal}} object), initially null. -

    A {{Request}} object's MIME type is to return the result of -extracting a MIME type from its request's -header list. -

    A {{Request}} object's body is its request's body. @@ -8078,10 +8100,6 @@ enum ResponseType { "basic", "cors", "default", "error", "opaque", "opaqueredire

    A {{Response}} object also has an associated headers (null or a {{Headers}} object), initially null. -

    A {{Response}} object's MIME type is to return the result of -extracting a MIME type from its response's -header list. -

    A {{Response}} object's body is its response's body. @@ -8978,6 +8996,7 @@ Brad Porter, Bryan Smith, Caitlin Potter, Cameron McCormack, +白丞祐 (Cheng-You Bai), Chirag S Kumar, Chris Needham, Chris Rebert,