@@ -6876,11 +6876,40 @@ To <dfn>match collector for navigable</dfn> given |collector| and |navigable|:
6876
6876
6877
6877
</div>
6878
6878
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
+
6879
6906
<div algorithm>
6880
6907
To <dfn export>clone network response body</dfn> given |request| and |response body|:
6881
6908
6882
6909
Note: This hook is intended to be triggered by the fetch spec when the response is set.
6883
6910
6911
+ 1. If |response body| is null, return.
6912
+
6884
6913
1. For each |session| in [=active BiDi sessions=] :
6885
6914
6886
6915
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|:
6925
6954
6926
6955
</div>
6927
6956
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
+
6928
6972
<div algorithm>
6929
6973
To <dfn>maybe collect network response body</dfn> given |request| and |response|:
6930
6974
6931
6975
1. If |response|'s [=response/status=] is a [=redirect status=] , return.
6932
6976
6933
- Note : For redirects, only the final response body is stored.
6977
+ NOTE : For redirects, only the final response body is stored.
6934
6978
6935
6979
1. Let |collected data| be [=get collected data=] with |request|'s [=request id=] and "response".
6936
6980
6937
6981
1. If |collected data| is null, return.
6938
6982
6939
6983
NOTE: This might happen if there are no collectors setup when the response is created,
6940
6984
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|:
6941
7002
6942
7003
1. Set |collected data|'s <code> pending</code> to false.
6943
7004
@@ -6947,7 +7008,7 @@ To <dfn>maybe collect network response body</dfn> given |request| and |response|
6947
7008
6948
7009
1. [=list/Remove=] |collected data| from [=collected network data=] .
6949
7010
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| ).
6951
7012
6952
7013
1. Return.
6953
7014
@@ -6963,7 +7024,7 @@ To <dfn>maybe collect network response body</dfn> given |request| and |response|
6963
7024
6964
7025
1. For each |collector| in |session|'s [=network collectors=] :
6965
7026
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
6967
7028
[=match collector for navigable=] with |collector| and |top-level navigable|:
6968
7029
6969
7030
1. [=list/Append=] |collector| to |collectors|.
@@ -6972,28 +7033,19 @@ To <dfn>maybe collect network response body</dfn> given |request| and |response|
6972
7033
6973
7034
1. [=list/Remove=] |collected data| from [=collected network data=] .
6974
7035
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| ).
6976
7037
6977
7038
1. Return.
6978
7039
6979
7040
1. Let |bytes| be null.
6980
7041
6981
- 1. Let |size| be null.
6982
-
6983
7042
1. Let |processBody| given |nullOrBytes| be this step:
6984
7043
6985
7044
1. If |nullOrBytes| is not null:
6986
7045
6987
7046
1. Set |bytes| to [=serialize protocol bytes=] with |nullOrBytes|.
6988
7047
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=] .
6997
7049
6998
7050
1. Let |processBodyError| be this step: Do nothing.
6999
7051
@@ -7016,7 +7068,7 @@ To <dfn>maybe collect network response body</dfn> given |request| and |response|
7016
7068
7017
7069
1. Otherwise, [=list/remove=] |collected data| from [=collected network data=] .
7018
7070
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| ).
7020
7072
7021
7073
</div>
7022
7074
@@ -7524,7 +7576,7 @@ To <dfn>serialize cookie header</dfn> given |protocol cookie|:
7524
7576
{^Remote end definition^} and {^local end definition^}
7525
7577
7526
7578
<pre class="cddl" data-cddl-module="local-cddl,remote-cddl">
7527
- network.DataType = "response"
7579
+ network.DataType = "request" / " response"
7528
7580
</pre>
7529
7581
7530
7582
The <code> <dfn>network.DataType</dfn> </code> type represents the different types of network data
@@ -9666,6 +9718,8 @@ request sent</dfn> steps given |request|:
9666
9718
are assumed to be valid at this stage; any error accessing the proxy will
9667
9719
be reported as a network error when handling the request.
9668
9720
9721
+ 1. [=Maybe collect network request body=] with |request|.
9722
+
9669
9723
1. If [=before request sent map=] does not contain |request|, set [=before
9670
9724
request sent map=] [|request|] to a new set.
9671
9725
0 commit comments