@@ -6876,11 +6876,40 @@ To <dfn>match collector for navigable</dfn> given |collector| and |navigable|:
68766876
68776877</div>
68786878
6879+ <div algorithm>
6880+ To <dfn export>clone network request body</dfn> given |request|:
6881+
6882+ Note: This hook is intended to be triggered by the fetch spec when the request body has been safely extracted.
6883+ See step 9 of https://fetch.spec.whatwg.org/#concept-fetch
6884+
6885+ 1. If |request|'s [=request/body=] is null, return.
6886+
6887+ 1. For each |session| in [=active BiDi sessions=] :
6888+
6889+ 1. If |session|'s [=network collectors=] is not [=list/empty=] :
6890+
6891+ 1. Let |collected data| be a [=network data=] with
6892+ [=network-data/bytes=] set to null,
6893+ [=network-data/cloned body=] set to [=body/clone=] of |request|'s [=request/body=] ,
6894+ [=network-data/collectors=] set to an empty list,
6895+ [=network-data/pending=] set to true,
6896+ [=network-data/request=] set to |request|'s [=request id=] ,
6897+ [=network-data/size=] set to null,
6898+ [=network-data/type=] set to "response".
6899+
6900+ 1. [=list/Append=] |collected data| to [=collected network data=] .
6901+
6902+ 1. Return.
6903+
6904+ </div>
6905+
68796906<div algorithm>
68806907To <dfn export>clone network response body</dfn> given |request| and |response body|:
68816908
68826909Note: This hook is intended to be triggered by the fetch spec when the response is set.
68836910
6911+ 1. If |response body| is null, return.
6912+
688469131. For each |session| in [=active BiDi sessions=] :
68856914
68866915 1. If |session|'s [=network collectors=] is not [=list/empty=] :
@@ -6925,19 +6954,51 @@ To <dfn>maybe abort network response body collection</dfn> given |request|:
69256954
69266955</div>
69276956
6957+ <div algorithm>
6958+ To <dfn>maybe collect network request body</dfn> given |request|:
6959+
6960+ 1. Let |collected data| be [=get collected data=] with |request|'s [=request id=] and "request".
6961+
6962+ 1. If |collected data| is null, return.
6963+
6964+ NOTE: This might happen if there are no collectors setup when the request is created,
6965+ and [=clone network request body=] does not clone the corresponding body.
6966+ Or if the body was null in the first place.
6967+
6968+ 1. [=Maybe collect network data=] with |request|, |collected data|, null and "request".
6969+
6970+ </div>
6971+
69286972<div algorithm>
69296973To <dfn>maybe collect network response body</dfn> given |request| and |response|:
69306974
693169751. If |response|'s [=response/status=] is a [=redirect status=] , return.
69326976
6933- Note : For redirects, only the final response body is stored.
6977+ NOTE : For redirects, only the final response body is stored.
69346978
693569791. Let |collected data| be [=get collected data=] with |request|'s [=request id=] and "response".
69366980
693769811. If |collected data| is null, return.
69386982
69396983 NOTE: This might happen if there are no collectors setup when the response is created,
69406984 and [=clone network response body=] does not clone the corresponding body.
6985+ Or if the body was null in the first place.
6986+
6987+ 1. Let |size| be |response|'s [=response body info=]' s [=encoded size=] .
6988+
6989+ NOTE: There is a discrepancy between the fact that the bytes retrieved from the
6990+ fetch stream correspond to the decoded data, but the encoded (network) size is
6991+ used in order to calculate size limits. Implementations might decide to use a storage
6992+ model such that it uses less size than storing the decoded data, as long as the data
6993+ returned to clients in getData is identical to the decoded data. The potential
6994+ tradeoff between storage and performance is up to the implementation.
6995+
6996+ 1. [=Maybe collect network data=] with |request|, |collected data|, |size| and "response".
6997+
6998+ </div>
6999+
7000+ <div algorithm>
7001+ To <dfn>maybe collect network data</dfn> given |request|, |collected data|, |size| and |data type|:
69417002
694270031. Set |collected data|'s <code> pending</code> to false.
69437004
@@ -6947,7 +7008,7 @@ To <dfn>maybe collect network response body</dfn> given |request| and |response|
69477008
69487009 1. [=list/Remove=] |collected data| from [=collected network data=] .
69497010
6950- 1. [=Resume=] with "<code> network data collected</code> " and (|request|'s [=request id=] , "response" ).
7011+ 1. [=Resume=] with "<code> network data collected</code> " and (|request|'s [=request id=] , |data type| ).
69517012
69527013 1. Return.
69537014
@@ -6963,7 +7024,7 @@ To <dfn>maybe collect network response body</dfn> given |request| and |response|
69637024
69647025 1. For each |collector| in |session|'s [=network collectors=] :
69657026
6966- 1. If |collector|'s [=network-collector/data types=] [=list/contains=] "response" and if
7027+ 1. If |collector|'s [=network-collector/data types=] [=list/contains=] |data type| and if
69677028 [=match collector for navigable=] with |collector| and |top-level navigable|:
69687029
69697030 1. [=list/Append=] |collector| to |collectors|.
@@ -6972,28 +7033,19 @@ To <dfn>maybe collect network response body</dfn> given |request| and |response|
69727033
69737034 1. [=list/Remove=] |collected data| from [=collected network data=] .
69747035
6975- 1. [=Resume=] with "<code> network data collected</code> " and (|request|'s [=request id=] , "response" ).
7036+ 1. [=Resume=] with "<code> network data collected</code> " and (|request|'s [=request id=] , |data type| ).
69767037
69777038 1. Return.
69787039
697970401. Let |bytes| be null.
69807041
6981- 1. Let |size| be null.
6982-
698370421. Let |processBody| given |nullOrBytes| be this step:
69847043
69857044 1. If |nullOrBytes| is not null:
69867045
69877046 1. Set |bytes| to [=serialize protocol bytes=] with |nullOrBytes|.
69887047
6989- 1. Set |size| to |response|'s [=response body info=]' s [=encoded size=] .
6990-
6991- Note: There is a discrepancy between the fact that the bytes retrieved from the
6992- fetch stream correspond to the decoded data, but the encoded (network) size is
6993- used in order to calculate size limits. Implementations might decide to use a storage
6994- model such that it uses less size than storing the decoded data, as long as the data
6995- returned to clients in getData is identical to the decoded data. The potential
6996- tradeoff between storage and performance is up to the implementation.
7048+ 1. If |size| is null, set |size| to |bytes|' [=byte sequence/length=] .
69977049
699870501. Let |processBodyError| be this step: Do nothing.
69997051
@@ -7016,7 +7068,7 @@ To <dfn>maybe collect network response body</dfn> given |request| and |response|
70167068
70177069 1. Otherwise, [=list/remove=] |collected data| from [=collected network data=] .
70187070
7019- 1. [=Resume=] with "<code> network data collected</code> " and (|request|'s [=request id=] , "response" ).
7071+ 1. [=Resume=] with "<code> network data collected</code> " and (|request|'s [=request id=] , |data type| ).
70207072
70217073</div>
70227074
@@ -7524,7 +7576,7 @@ To <dfn>serialize cookie header</dfn> given |protocol cookie|:
75247576{^Remote end definition^} and {^local end definition^}
75257577
75267578<pre class="cddl" data-cddl-module="local-cddl,remote-cddl">
7527- network.DataType = "response"
7579+ network.DataType = "request" / " response"
75287580</pre>
75297581
75307582The <code> <dfn>network.DataType</dfn> </code> type represents the different types of network data
@@ -9666,6 +9718,8 @@ request sent</dfn> steps given |request|:
96669718 are assumed to be valid at this stage; any error accessing the proxy will
96679719 be reported as a network error when handling the request.
96689720
9721+ 1. [=Maybe collect network request body=] with |request|.
9722+
966997231. If [=before request sent map=] does not contain |request|, set [=before
96709724 request sent map=] [|request|] to a new set.
96719725
0 commit comments