From ba01f634d1d79f13566ec82172b2d9c4dfdb8655 Mon Sep 17 00:00:00 2001 From: Yutaka Hirano Date: Tue, 17 Jan 2017 19:25:51 +0900 Subject: [PATCH 1/3] initial --- fetch.bs | 37 ++++++++++++++----------------------- 1 file changed, 14 insertions(+), 23 deletions(-) diff --git a/fetch.bs b/fetch.bs index 0921ac1c3..b4384a30d 100644 --- a/fetch.bs +++ b/fetch.bs @@ -4925,34 +4925,25 @@ constructor must run these steps: body is non-null, run these substeps:
    -
  1. Let dummyStream be an empty - {{ReadableStream}} object. - -

  2. Set input's request's - body to a new body whose - stream is dummyStream. +

  3. +

    Let «ws, rs» be a + transform stream such that + from rs one can read exactly the same data written to ws. +

    ws is a {{WritableStream}} object and rs + is a {{ReadableStream}} object.

  4. -

    Let reader be the result of getting a reader - from dummyStream. +

    Call pipeTo on + input's request's body's + stream with ws.

    This operation will not throw an exception. -

  5. -

    Read all bytes from - dummyStream with reader. -

    This operation makes dummyStream disturbed. -

+
  • Set r's request's + body to a new body whose stream + is rs and whose source is input's + request's body's source. -

    These substeps are meant to produce the observable equivalent of - "piping" input's body's - stream into r. That is, input is - left with a body with a - {{ReadableStream}} object that is - disturbed and - locked, while the data readable from - r's body's - stream is now equal to what used to be input's, - if input's original body is non-null. +

  • Return r. From 49b0bb3a751cbadcda306b33f13aedc09bb915bb Mon Sep 17 00:00:00 2001 From: Yutaka Hirano Date: Tue, 17 Jan 2017 20:20:11 +0900 Subject: [PATCH 2/3] fix --- fetch.bs | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/fetch.bs b/fetch.bs index b4384a30d..93f4cfa05 100644 --- a/fetch.bs +++ b/fetch.bs @@ -4874,6 +4874,8 @@ constructor must run these steps: inputBody is non-null, and request's method is `GET` or `HEAD`, then throw a TypeError. +

  • Let body be inputBody. +

  • If init's body member is present and is non-null, run these substeps: @@ -4882,11 +4884,11 @@ constructor must run these steps:

  • Let Content-Type be null.

  • If init's keepalive member is present and is true, then set - inputBody and Content-Type to the result of + body and Content-Type to the result of extracting init's body member, with keepalive flag set. Rethrow any exceptions. -

  • Otherwise, set inputBody and Content-Type to the result of +

  • Otherwise, set body and Content-Type to the result of extracting init's body member. Rethrow any exceptions. @@ -4899,7 +4901,7 @@ constructor must run these steps:

  • -

    If inputBody is non-null and inputBody's source is +

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

      @@ -4910,19 +4912,10 @@ constructor must run these steps: use-CORS-preflight flag.
    -
  • Set r's request's - body to inputBody. -

  • Set r's MIME type to - the result of extracting a MIME type - from r's request's - header list. -

  • -

    If input is a {{Request}} object and - input's request's - body is non-null, run these substeps: +

    If inputBody is non-null, then run these substeps:

    1. @@ -4934,17 +4927,22 @@ constructor must run these steps:
    2. Call pipeTo on - input's request's body's - stream with ws. + inputBody's stream with ws.

      This operation will not throw an exception. -

    3. Set r's request's - body to a new body whose stream - is rs and whose source is input's - request's body's source. - +

    4. If inputBody is body, then set body to a new + body whose stream is rs, whose source + is inputBody's source and whose total bytes is + inputBody's total bytes.

    +
  • Set r's request's body to body. + +

  • Set r's MIME type to + the result of extracting a MIME type + from r's request's + header list. +

  • Return r. From a45131c745050074943a7bd3b963248f60f71a44 Mon Sep 17 00:00:00 2001 From: Yutaka Hirano Date: Thu, 19 Jan 2017 20:16:26 +0900 Subject: [PATCH 3/3] fix --- fetch.bs | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/fetch.bs b/fetch.bs index 93f4cfa05..ed361239e 100644 --- a/fetch.bs +++ b/fetch.bs @@ -4387,6 +4387,7 @@ typedef (Blob or BufferSource or FormData or URLSearchParams or ReadableStream o

    [NoInterfaceObject,
      Exposed=(Window,Worker)]
     interface Body {
    +  readonly attribute ReadableStream? body;
       readonly attribute boolean bodyUsed;
       [NewObject] Promise<ArrayBuffer> arrayBuffer();
       [NewObject] Promise<Blob> blob();
    @@ -4414,6 +4415,9 @@ non-null and its stream is
     non-null and its stream is
     locked.
     
    +

    The body attribute's getter must return null if +body is null and body's stream otherwise. +

    The bodyUsed attribute's getter must return true if disturbed, and false otherwise. @@ -4919,16 +4923,16 @@ constructor must run these steps:

    1. -

      Let «ws, rs» be a - transform stream such that - from rs one can read exactly the same data written to ws. -

      ws is a {{WritableStream}} object and rs - is a {{ReadableStream}} object. +

      Let rs bs a {{ReadableStream}} object from which one can read the exactly + same data as one could read from inputBody's stream. -

    2. -

      Call pipeTo on - inputBody's stream with ws. -

      This operation will not throw an exception. +

      This will be specified more precisely once + transform stream and + piping are precisely defined. + See the issue. + +

      This makes inputBody's stream + locked and disturbed immediately.

    3. If inputBody is body, then set body to a new body whose stream is rs, whose source @@ -5034,7 +5038,6 @@ interface Response { readonly attribute boolean ok; readonly attribute ByteString statusText; [SameObject] readonly attribute Headers headers; - readonly attribute ReadableStream? body; [SameObject] readonly attribute Promise<Headers> trailer; [NewObject] Response clone(); @@ -5215,10 +5218,6 @@ must return response's

      The headers attribute's getter must return the associated {{Headers}} object. -

      The body attribute's getter must return null if -the associated body is null and the associated -body's stream otherwise. -

      The trailer attribute's getter must return the associated trailer promise.