diff --git a/xhr.bs b/xhr.bs index a0b11a3..b0c48ad 100644 --- a/xhr.bs +++ b/xhr.bs @@ -495,6 +495,7 @@ methods, when invoked, must run these steps: network error.
  • Set received bytes to the empty byte sequence.

  • Set response object to null. +

  • Set override MIME type to null.

  • @@ -1299,19 +1300,32 @@ transfer-encoding: chunked
  • Return mimeType. -

    The override MIME type is initially null and can get a value if -{{overrideMimeType()}} is invoked. Final MIME type is the +

    The override MIME type is initially null and can get a value +when {{overrideMimeType()}} is invoked. The final MIME type is the override MIME type unless that is null in which case it is the response MIME type. -

    The response charset is the value of -the charset parameter of the `Content-Type` header -or null if there was no `charset` parameter or the header could -not be parsed or was omitted. The -override charset is initially null and -can get a value if overrideMimeType() is invoked. -Final charset is the -override charset unless -that is null in which case it is the response charset. +

    The final charset is the return value of these steps: + +

      +
    1. Let label be null. + +

    2. If response MIME type's parameters["charset"] + exists, then set label to it. + +

    3. If override MIME type's parameters["charset"] + exists, then set label to it. + +

    4. If label is null, then return null. + +

    5. Let encoding be the result of getting an encoding from label. + +

    6. If encoding is failure, then return null. + +

    7. Return encoding. +

    + +

    The above steps intentionally do not use the final MIME type as it would yield +the wrong result.


    @@ -1336,7 +1350,7 @@ or null). Unless stated otherwise it is null.
    1. Set response object to a new {{Blob}} object representing received bytes with - {{Blob/type}} final MIME type. + {{Blob/type}} set to the final MIME type.

    2. Return response object.

    @@ -1348,11 +1362,11 @@ or null). Unless stated otherwise it is null.
  • If response's body is null, then return null. -

  • If final MIME type is not an HTML MIME type or an XML MIME type, then - return null. +

  • If the final MIME type is not an HTML MIME type or an XML MIME type, + then return null.

  • -

    If {{XMLHttpRequest/responseType}} is the empty string and final MIME type is an +

    If {{XMLHttpRequest/responseType}} is the empty string and the final MIME type is an HTML MIME type, then return null.

    This is restricted to @@ -1361,7 +1375,7 @@ or null). Unless stated otherwise it is null. content.

  • -

    If final MIME type is an HTML MIME type, then run these substeps: +

    If the final MIME type is an HTML MIME type, then:

    1. Let charset be the final charset. @@ -1406,7 +1420,7 @@ or null). Unless stated otherwise it is null. encoding to charset. -

    2. Set document's content type to final MIME type. +

    3. Set document's content type to the final MIME type.

    4. Set document's URL to @@ -1445,7 +1459,7 @@ or null). Unless stated otherwise it is null.

    5. Let charset be the final charset.

    6. -

      If {{XMLHttpRequest/responseType}} is the empty string, charset is null, and +

      If {{XMLHttpRequest/responseType}} is the empty string, charset is null, and the final MIME type is an XML MIME type, then use the rules set forth in the XML specifications to determine the encoding. Let charset be the determined encoding. [[!XML]] [[!XMLNS]] @@ -1474,28 +1488,25 @@ resources using utf-8.

      client . overrideMimeType(mime)
      -

      Acts as if the `Content-Type` header for response is mime. +

      Acts as if the `Content-Type` header value for response is mime. + (It does not actually change the header though.)

      Throws an "{{InvalidStateError!!exception}}" {{DOMException}} if state is loading or done.

      -

      The -overrideMimeType(mime) -method must run these steps: +

      The overrideMimeType(mime) method, +when invoked, must run these steps:

      1. If state is loading or done, then throw an "{{InvalidStateError!!exception}}" {{DOMException}}. -

      2. Set override MIME type to `application/octet-stream`. - -

      3. If mime is a parsable MIME type, then set override MIME type to its - MIME type portion. - +

      4. Set override MIME type to the result of parsing + mime. -

      5. If override MIME type has a `charset` parameter, then set - override charset to its value. +

      6. If override MIME type is failure, then set override MIME type to + application/octet-stream.