diff --git a/index.bs b/index.bs index ed6e19c7..41b4d359 100644 --- a/index.bs +++ b/index.bs @@ -6876,11 +6876,40 @@ To match collector for navigable given |collector| and |navigable|: +
+To clone network request body given [=/request=] |request|: + +Note: This hook is intended to be triggered by the fetch spec when the request body has been safely extracted. +See step 9 of https://fetch.spec.whatwg.org/#concept-fetch + +1. If |request|'s [=request/body=] is null, return. + +1. For each |session| in [=active BiDi sessions=]: + + 1. If |session|'s [=network collectors=] is not [=list/empty=]: + + 1. Let |collected data| be a [=network data=] with + [=network-data/bytes=] set to null, + [=network-data/cloned body=] set to [=body/clone=] of |request|'s [=request/body=], + [=network-data/collectors=] set to an empty list, + [=network-data/pending=] set to true, + [=network-data/request=] set to |request|'s [=request id=], + [=network-data/size=] set to null, + [=network-data/type=] set to "response". + + 1. [=list/Append=] |collected data| to [=collected network data=]. + + 1. Return. + +
+
To clone network response body given |request| and |response body|: Note: This hook is intended to be triggered by the fetch spec when the response is set. +1. If |response body| is null, return. + 1. For each |session| in [=active BiDi sessions=]: 1. If |session|'s [=network collectors=] is not [=list/empty=]: @@ -6925,12 +6954,27 @@ To maybe abort network response body collection given |request|:
+
+To maybe collect network request body given |request|: + +1. Let |collected data| be [=get collected data=] with |request|'s [=request id=] and "request". + +1. If |collected data| is null, return. + + NOTE: This might happen if there are no collectors setup when the request is created, + and [=clone network request body=] does not clone the corresponding body. + Or if the body was null in the first place. + +1. [=Maybe collect network data=] with |request|, |collected data|, null and "request". + +
+
To maybe collect network response body given |request| and |response|: 1. If |response|'s [=response/status=] is a [=redirect status=], return. - Note: For redirects, only the final response body is stored. + NOTE: For redirects, only the final response body is stored. 1. Let |collected data| be [=get collected data=] with |request|'s [=request id=] and "response". @@ -6938,6 +6982,24 @@ To maybe collect network response body given |request| and |response| NOTE: This might happen if there are no collectors setup when the response is created, and [=clone network response body=] does not clone the corresponding body. + Or if the body was null in the first place. + +1. Let |size| be |response|'s [=response body info=]'s [=encoded size=]. + + NOTE: There is a discrepancy between the fact that the bytes retrieved from the + fetch stream correspond to the decoded data, but the encoded (network) size is + used in order to calculate size limits. Implementations might decide to use a storage + model such that it uses less size than storing the decoded data, as long as the data + returned to clients in getData is identical to the decoded data. The potential + tradeoff between storage and performance is up to the implementation. + +1. [=Maybe collect network data=] with |request|, |collected data|, |size| and "response". + +
+ +
+To maybe collect network data given [=/request=] |request|, +[=network data=] |collected data|, js-uint |size| and [=network.DataType=] |data type|: 1. Set |collected data|'s pending to false. @@ -6947,7 +7009,7 @@ To maybe collect network response body given |request| and |response| 1. [=list/Remove=] |collected data| from [=collected network data=]. - 1. [=Resume=] with "network data collected" and (|request|'s [=request id=], "response"). + 1. [=Resume=] with "network data collected" and (|request|'s [=request id=], |data type|). 1. Return. @@ -6963,7 +7025,7 @@ To maybe collect network response body given |request| and |response| 1. For each |collector| in |session|'s [=network collectors=]: - 1. If |collector|'s [=network-collector/data types=] [=list/contains=] "response" and if + 1. If |collector|'s [=network-collector/data types=] [=list/contains=] |data type| and if [=match collector for navigable=] with |collector| and |top-level navigable|: 1. [=list/Append=] |collector| to |collectors|. @@ -6972,28 +7034,19 @@ To maybe collect network response body given |request| and |response| 1. [=list/Remove=] |collected data| from [=collected network data=]. - 1. [=Resume=] with "network data collected" and (|request|'s [=request id=], "response"). + 1. [=Resume=] with "network data collected" and (|request|'s [=request id=], |data type|). 1. Return. 1. Let |bytes| be null. -1. Let |size| be null. - 1. Let |processBody| given |nullOrBytes| be this step: 1. If |nullOrBytes| is not null: 1. Set |bytes| to [=serialize protocol bytes=] with |nullOrBytes|. - 1. Set |size| to |response|'s [=response body info=]'s [=encoded size=]. - - Note: There is a discrepancy between the fact that the bytes retrieved from the - fetch stream correspond to the decoded data, but the encoded (network) size is - used in order to calculate size limits. Implementations might decide to use a storage - model such that it uses less size than storing the decoded data, as long as the data - returned to clients in getData is identical to the decoded data. The potential - tradeoff between storage and performance is up to the implementation. + 1. If |size| is null, set |size| to |bytes|' [=byte sequence/length=]. 1. Let |processBodyError| be this step: Do nothing. @@ -7016,7 +7069,7 @@ To maybe collect network response body given |request| and |response| 1. Otherwise, [=list/remove=] |collected data| from [=collected network data=]. -1. [=Resume=] with "network data collected" and (|request|'s [=request id=], "response"). +1. [=Resume=] with "network data collected" and (|request|'s [=request id=], |data type|).
@@ -7524,7 +7577,7 @@ To serialize cookie header given |protocol cookie|: {^Remote end definition^} and {^local end definition^}
-network.DataType = "response"
+network.DataType = "request" / "response"
 
The network.DataType type represents the different types of network data @@ -9666,6 +9719,8 @@ request sent steps given |request|: are assumed to be valid at this stage; any error accessing the proxy will be reported as a network error when handling the request. +1. [=Maybe collect network request body=] with |request|. + 1. If [=before request sent map=] does not contain |request|, set [=before request sent map=][|request|] to a new set.