diff --git a/fetch.bs b/fetch.bs index 19a1918c9..0496eb073 100644 --- a/fetch.bs +++ b/fetch.bs @@ -15,7 +15,7 @@ Markup Shorthands: css off !Commits: [SNAPSHOT-LINK] !Commits: @fetchstandard !Translation (non-normative): 日本語 -Translate IDs: typedefdef-bodyinit bodyinit,typedefdef-responsebodyinit responsebodyinit,dictdef-requestinit requestinit,typedefdef-requestinfo requestinfo,enumdef-requesttype requesttype,enumdef-requestdestination requestdestination,enumdef-requestmode requestmode,enumdef-requestcredentials requestcredentials,enumdef-requestcache requestcache,enumdef-requestredirect requestredirect,dictdef-responseinit responseinit,enumdef-responsetype responsetype +Translate IDs: typedefdef-bodyinit bodyinit,dictdef-requestinit requestinit,typedefdef-requestinfo requestinfo,enumdef-requesttype requesttype,enumdef-requestdestination requestdestination,enumdef-requestmode requestmode,enumdef-requestcredentials requestcredentials,enumdef-requestcache requestcache,enumdef-requestredirect requestredirect,dictdef-responseinit responseinit,enumdef-responsetype responsetype @@ -559,13 +559,16 @@ user-agent-defined value for the

A body consists of:

A body body is said to be @@ -3018,6 +3021,10 @@ in addition to HTTP fetch above. includes credentials, then return a network error. +

  • If actualResponse's status is not 303, + request's body is non-null, and request's + body's source is null, then return a network error. +

  • If CORS flag is set and actualResponse's location URL @@ -3042,6 +3049,15 @@ in addition to HTTP fetch above. to `GET` and request's body to null. +

  • +

    If request's body is non-null, then set request's + body to the first part of extracting + request's body's source. + +

    request's body's source's + nullity has already been checked. The extracting operation cannot + throw as it was called for the same source before. +

  • Append actualResponse's location URL to request's url list. @@ -3069,17 +3085,34 @@ steps: authentication-fetch flag.

      +
    1. Let httpRequest be null. + +

    2. If request's window is "no-window" and + request's redirect mode is "error", then set + httpRequest to request. +

    3. -

      Let httpRequest be request if - request's window is "no-window" - and request's redirect mode is - "error", and the result of cloning - request otherwise. +

      Otherwise, run these substeps: + +

        +
      1. Set httpRequest to a copy of request except for its + body. + +

      2. Let body be request's body. -

        A request is typically cloned as it needs to be possible to - add headers and read its - body without affecting request. As - request is reused with redirects, authentication, and proxy authentication. +

      3. Set httpRequest's body to body. + +

      4. If body is non-null, then set request's body to a + new body whose stream is null and whose source is + body's source. +

      + +

      request is copied as httpRequest here as we need + to be able to add headers to httpRequest and read its body without + affecting request. Namely, request can be reused with redirects, + authentication, and proxy authentication. We copy rather than clone in order to reduce memory + consumption. In case request's body's source is + null, redirects and authentication will end up failing the fetch.

    4. Let credentials flag be set if one of @@ -3102,10 +3135,10 @@ steps: `0`. -

    5. If httpRequest's body is non-null, set +

    6. If httpRequest's body is non-null and httpRequest's + body's source is non-null, then set contentLengthValue to httpRequest's body's total bytes, UTF-8 encoded. -

    7. If contentLengthValue is non-null, append @@ -3113,7 +3146,7 @@ steps: httpRequest's header list. -

    8. +
    9. If contentLengthValue is non-null, httpRequest's keepalive flag is set, and contentLengthValue is greater than a user-agent-defined maximum, then return a network error. @@ -3122,7 +3155,6 @@ steps: allowed to outlive the environment settings object and contain a body, have a bounded size and are not allowed to stay alive indefinitely. -

    10. If httpRequest's referrer is a URL, then append `Referer`/httpRequest's referrer, serialized and UTF-8 encoded, to @@ -3360,6 +3392,22 @@ steps:

    11. Needs testing: multiple `WWW-Authenticate` headers, missing, parsing issues. +

    12. +

      If request's body is non-null, then run these subsubsteps: + +

        +
      1. If request's body's source is null, + then return a network error. + +

      2. +

        Set request's body to the first part of + extracting request's body's + source. + +

        The extracting operation cannot + throw as it was called for the same source before. +

      +
    13. If request's use-URL-credentials flag is unset or @@ -3441,6 +3489,12 @@ steps:

    14. If connection is failure, return a network error. +

    15. If connection is not an HTTP/2 connection, request's + body is non-null, and request's body's + source is null, then append + `Transfer-Encoding`/`chunked` to request's + header list. +

    16. Let response be the result of making an HTTP request over connection using request with the following caveats: @@ -3468,6 +3522,10 @@ steps: therefore response represents both a response and an HTTP response here. +

      If request's header list contains + `Transfer-Encoding`/`chunked` and response is transferred + via HTTP/1.0 or older, then return a network error. +

      If the HTTP request results in a TLS client certificate dialog, run these substeps:

        @@ -4218,9 +4276,7 @@ method, when invoked, must run these steps:

        Body mixin

        -typedef (Blob or BufferSource or FormData or URLSearchParams or USVString) BodyInit;
        -
        -typedef (BodyInit or ReadableStream) ResponseBodyInit;
        +typedef (Blob or BufferSource or FormData or URLSearchParams or ReadableStream or USVString) BodyInit;

        To extract a body and a `Content-Type` value from @@ -4233,7 +4289,9 @@ typedef (BodyInit or ReadableStream) ResponseBodyInit;

      1. Let Content-Type be null. -

      2. Let action be null. +

      3. Let action be null. + +

      4. Let source be null.

      5. Switch on object's type: @@ -4246,6 +4304,8 @@ typedef (BodyInit or ReadableStream) ResponseBodyInit;

        If object's {{Blob/type}} attribute is not the empty byte sequence, set Content-Type to its value. +

        Set source to object. +

        BufferSource

        Enqueue a Uint8Array object @@ -4254,6 +4314,8 @@ typedef (BodyInit or ReadableStream) ResponseBodyInit; stream. If that threw an exception, error stream with that exception. +

        Set source to object. +

        {{FormData}}

        Set action to an action that runs the @@ -4266,6 +4328,8 @@ typedef (BodyInit or ReadableStream) ResponseBodyInit; multipart/form-data boundary string generated by the multipart/form-data encoding algorithm. +

        Set source to object. +

        {{URLSearchParams}}

        Set action to an action that runs the @@ -4277,12 +4341,16 @@ typedef (BodyInit or ReadableStream) ResponseBodyInit;

        Set Content-Type to `application/x-www-form-urlencoded;charset=UTF-8`. +

        Set source to object. +

        USVString

        Set action to an action that runs UTF-8 encode on object.

        Set Content-Type to `text/plain;charset=UTF-8`. +

        Set source to object. +

        {{ReadableStream}}

        Set stream to object. @@ -4306,8 +4374,8 @@ typedef (BodyInit or ReadableStream) ResponseBodyInit; close stream.

      -
    17. Let body be a body whose - stream is stream. +

    18. Let body be a body whose stream is + stream and whose source is source.

    19. Return body and Content-Type.

    @@ -4827,6 +4895,18 @@ constructor must run these steps: {{Headers}} object. Rethrow any exception. +
  • +

    If inputBody is non-null and inputBody's source is + null, then run these substeps: + +

      +
    1. If r's request's mode is neither + "same-origin" nor "cors", then throw a TypeError. + +

    2. Set r's request's + use-CORS-preflight flag. +

    +
  • Set r's request's body to inputBody. @@ -4948,7 +5028,7 @@ run these steps:

    Response class

    -
    [Constructor(optional ResponseBodyInit? body = null, optional ResponseInit init),
    +
    [Constructor(optional BodyInit? body = null, optional ResponseInit init),
      Exposed=(Window,Worker)]
     interface Response {
       [NewObject] static Response error();