@@ -175,8 +175,34 @@ lt="authentication entry">authentication entries</a> (for HTTP authentication).
175
175
176
176
<dt> <dfn for="fetch params">task destination</dfn> (default null)
177
177
<dd> Null, a <a for=/>global object</a> , or a <a for=/>parallel queue</a> .
178
+ <dt> <dfn for="fetch params">timing info</dfn>
179
+ <dd> A <a for=/>fetch timing info</a> .
178
180
</dl>
179
181
182
+ <p> A <dfn>fetch timing info</dfn> is a <a for=/>struct</a> used to maintain timing information
183
+ later required by the resource timing and navigation timiing specs. It has the following <a for=struct>items</a> :
184
+ <dl>
185
+ <dt> <dfn for="fetch timing info">redirect start time</dfn> (default zero)
186
+ <dt> <dfn for="fetch timing info">redirect end time</dfn> (default zero)
187
+ <dt> <dfn for="fetch timing info">fetch start time</dfn> (default zero)
188
+ <dt> <dfn for="fetch timing info">response start time</dfn> (default zero)
189
+ <dt> <dfn for="fetch timing info">response end time</dfn> (default zero)
190
+ <dt> <dfn for="fetch timing info">alpn negotiated protocol</dfn> (default null)
191
+ <dd> Null or a string.
192
+
193
+ <dt> <dfn for="fetch timing info">worker start time</dfn> (default zero)
194
+ <dt> <dfn for="fetch timing info">domain lookup start time</dfn> (default zero)
195
+ <dt> <dfn for="fetch timing info">domain lookup end time</dfn> (default zero)
196
+ <dt> <dfn for="fetch timing info">connection start time</dfn> (default zero)
197
+ <dt> <dfn for="fetch timing info">connection end time</dfn> (default zero)
198
+ <dt> <dfn for="fetch timing info">secure connection start time</dfn> (default zero)
199
+ <dt> <dfn for="fetch timing info">request start time</dfn> (default zero)
200
+ <dt> <dfn for="fetch timing info">transfer size</dfn> (default zero)
201
+ <dt> <dfn for="fetch timing info">encoded body size</dfn> (default zero)
202
+ <dt> <dfn for="fetch timing info">decoded body size</dfn> (default zero)
203
+ </dl>
204
+
205
+
180
206
<p> To <dfn>queue a fetch task</dfn> , given an algorithm <var> algorithm</var> , a
181
207
<a for=/>global object</a> or a <a for=/>parallel queue</a> <var> taskDestination</var> , run these
182
208
steps:
@@ -1020,8 +1046,9 @@ worked on in <a href=https://github.com/whatwg/fetch/issues/1156>issue #1156</a>
1020
1046
1021
1047
<p> To <dfn export for=body>incrementally read</dfn> a <a for=/>body</a> <var> body</var> , given an
1022
1048
algorithm <var> processBodyChunk</var> , an algorithm <var> processEndOfBody</var> , an algorithm
1023
- <var> processBodyError</var> , and an optional null, <a for=/>parallel queue</a> , or
1024
- <a for=/>global object</a> <var> taskDestination</var> (default null), run these steps.
1049
+ <var> processBodyError</var> , an optional null, <a for=/>parallel queue</a> , or
1050
+ <a for=/>global object</a> <var> taskDestination</var> (default null), and an optional
1051
+ <a for=/>fetch timing info</a> <var> timingInfo</var> or null (default null), run these steps.
1025
1052
<var> processBodyChunk</var> must be an algorithm accepting a <a for=/>byte sequence</a> .
1026
1053
<var> processEndOfBody</var> must be an algorithm accepting no arguments. <var> processBodyError</var>
1027
1054
must be an algorithm accepting an exception.
@@ -1037,14 +1064,15 @@ must be an algorithm accepting an exception.
1037
1064
<p class=note> This operation will not throw an exception.
1038
1065
1039
1066
<li><p> Perform the <a>incrementally-read loop</a> given <var> reader</var> ,
1040
- <var> taskDestination</var> , <var> processBodyChunk</var> , <var> processEndOfBody</var> , and
1041
- <var> processBodyError</var> .
1067
+ <var> taskDestination</var> , <var> processBodyChunk</var> , <var> processEndOfBody</var> ,
1068
+ <var> processBodyError</var> and <var> timingInfo </var> .
1042
1069
</ol>
1043
1070
1044
1071
<p> To perform the <dfn>incrementally-read loop</dfn> , given a {{ReadableStreamDefaultReader}} object
1045
1072
<var> reader</var> , <a for=/>parallel queue</a> or <a for=/>global object</a>
1046
1073
<var> taskDestination</var> , algorithm <var> processBodyChunk</var> , algorithm
1047
- <var> processEndOfBody</var> , and algorithm <var> processBodyError</var> :
1074
+ <var> processEndOfBody</var> , algorithm <var> processBodyError</var> , and an optional
1075
+ <a for=/>fetch timing info</a> <var> timingInfo</var> or null (default null):
1048
1076
1049
1077
<ol>
1050
1078
<li>
@@ -1055,6 +1083,9 @@ must be an algorithm accepting an exception.
1055
1083
<dd>
1056
1084
<ol>
1057
1085
<li><p> Let <var> continueAlgorithm</var> be null.
1086
+ <li><p> If <var> timingInfo</var> is not null, and <var> timingInfo</var> 's
1087
+ <a for="fetch timing info">response start time</a> is not zero, set <var> timingInfo</var> 's
1088
+ <a for="fetch timing info">response start time</a> to the result of calling <a for=/>current time</a> .
1058
1089
1059
1090
<li><p> If <var> chunk</var> is not a {{Uint8Array}} object, then set
1060
1091
<var> continueAlgorithm</var> to this step: run <var> processBodyError</var> given a
@@ -1088,8 +1119,12 @@ must be an algorithm accepting an exception.
1088
1119
</ol>
1089
1120
1090
1121
<dt> <a for="read request">close steps</a>
1091
- <dd><ol><li><p> <a>Queue a fetch task</a> given <var> processEndOfBody</var> and
1092
- <var> taskDestination</var> .</ol>
1122
+ <dd><ol>
1123
+ <li><p> <a>Queue a fetch task</a> given <var> processEndOfBody</var> and
1124
+ <var> taskDestination</var> .
1125
+ <li><p> If <var> timingInfo</var> is not null, set <var> timingInfo</var> 's
1126
+ <a for="fetch timing info">response end time</a> to the result of calling <a for=/>current time</a> .
1127
+ </ol>
1093
1128
1094
1129
<dt> <a for="read request">error steps</a> , given <var> e</var>
1095
1130
<dd><ol><li><p> <a>Queue a fetch task</a> to run <var> processBodyError</var> given <var> e</var> ,
@@ -1136,6 +1171,9 @@ null), run these steps. <var>processBody</var> must be an algorithm accepting a
1136
1171
<var> reader</var> .
1137
1172
</ol>
1138
1173
1174
+ <p class=XXX> TODO: set <a for="fetch timing info">response start time</a> and <a for="fetch timing info">response end time</a>
1175
+ values for full reads. See <a href="https://github.com/w3c/resource-timing/issues/252">Issue 252</a> .
1176
+
1139
1177
<hr>
1140
1178
1141
1179
<p> To <dfn export>handle content codings</dfn> given <var> codings</var> and <var> bytes</var> , run
@@ -1902,7 +1940,6 @@ initially unset.
1902
1940
allowed on the resource fetched by looking at the flag of the response returned. Because the flag on
1903
1941
the response of a redirect has to be set if it was set for previous responses in the redirect chain,
1904
1942
this is also tracked internally using the request's <a for=request>timing allow failed flag</a> .
1905
-
1906
1943
<hr>
1907
1944
1908
1945
<p> A <a for=/>response</a> whose
@@ -2139,10 +2176,20 @@ identified by a <b>key</b> (a <a>network partition key</a>), an <b>origin</b> (a
2139
2176
<var> origin</var> . [[!HTTP]] [[!HTTP-SEMANTICS]] [[!HTTP-COND]] [[!HTTP-CACHING]] [[!HTTP-AUTH]]
2140
2177
[[!TLS]]
2141
2178
2179
+
2142
2180
<p> If <var> credentials</var> is false, then do <em> not</em> send a TLS client certificate.
2143
2181
2144
2182
<p> If establishing a connection does not succeed (e.g., a DNS, TCP, or TLS error), then return
2145
2183
failure.
2184
+
2185
+ <p class=XXX> TODO: set <a for="fetch timing info">alpn negotiated protocol</a> ,
2186
+ <a for="fetch timing info">connection start time</a> ,
2187
+ <a for="fetch timing info">connection end time</a> ,
2188
+ <a for="fetch timing info">domain lookup start time</a> ,
2189
+ <a for="fetch timing info">domain lookup end time</a> ,
2190
+ <a for="fetch timing info">request start time</a> ,
2191
+ and <a for="fetch timing info">secure connection start time</a> values here.
2192
+ See <a href="https://github.com/w3c/resource-timing/issues/252">Issue 252</a> .
2146
2193
</ol>
2147
2194
2148
2195
<li>
@@ -3272,6 +3319,7 @@ the request.
3272
3319
3273
3320
<li><p> Let <var> fetchParams</var> be a new <a for=/>fetch params</a> whose
3274
3321
<a for="fetch params">request</a> is <var> request</var> ,
3322
+ <a for="fetch params">timing info</a> is a new <a for=/>fetch timing info</a> ,
3275
3323
<a for="fetch params">process request body</a> is <var> processRequestBody</var> ,
3276
3324
<a for="fetch params">process request end-of-body</a> is <var> processRequestEndOfBody</var> ,
3277
3325
<a for="fetch params">process response</a> is <var> processResponse</var> ,
@@ -3348,6 +3396,8 @@ the request.
3348
3396
<li><p> Run <a>main fetch</a> given <var> fetchParams</var> .
3349
3397
</ol>
3350
3398
3399
+ <h3 id="sec-current-time">Current Time</h3>
3400
+ The <dfn>current time</dfn> is the present time given the <a for=/>global monotonic clock</a> .
3351
3401
3352
3402
<h3 id=main-fetch>Main fetch</h3>
3353
3403
@@ -3360,6 +3410,9 @@ steps:
3360
3410
3361
3411
<li><p> Let <var> response</var> be null.
3362
3412
3413
+ <li><p> Set <var> fetchParams</var> 's <a for="fetch params">timing info</a>' s <a for="fetch timing info">fetch start time</a>
3414
+ to the result of running <a for=/>current time</a> .
3415
+
3363
3416
<li><p> If <var> request</var> 's <a>local-URLs-only flag</a> is set and <var>request</var>' s
3364
3417
<a for=request>current URL</a> is not <a lt="is local">local</a> , then set <var> response</var> to a
3365
3418
<a>network error</a> .
@@ -3684,8 +3737,7 @@ steps:
3684
3737
3685
3738
<li><p> Wait for either <var> response</var> 's <a for=response>body</a> to be null, or
3686
3739
<var> response</var> 's <a for=response>body</a>' s <a for=body>stream</a> to be
3687
- <a for=ReadableStream>closed</a> or <a for=ReadableStream>errored</a> , and then set
3688
- <var> request</var> 's <a>done flag</a> .
3740
+ <a for=ReadableStream>closed</a> or <a for=ReadableStream>errored</a> , and set <var> request</var> 's <a>done flag</a> .
3689
3741
<!-- This is really bad and needs to be handled differently at some point. -->
3690
3742
</ol>
3691
3743
@@ -3812,6 +3864,8 @@ these steps:
3812
3864
3813
3865
<li><p> Let <var> actualResponse</var> be null.
3814
3866
3867
+ <li><p> Let <var> timingInfo</var> be <var> fetchParams</var> 's <a for="fetch params">timing info</a>
3868
+
3815
3869
<li>
3816
3870
<p> If <var> request</var> 's <a>service-workers mode</a> is "<code> all</code> ", then:
3817
3871
@@ -3821,6 +3875,8 @@ these steps:
3821
3875
3822
3876
<li><p> Set <var> response</var> to the result of invoking <a for=/>handle fetch</a> for
3823
3877
<var> requestForServiceWorker</var> . [[!HTML]] [[!SW]]
3878
+ <p class=XXX> TODO: set <a for="fetch timing info">worker start time</a> value.
3879
+ See <a href="https://github.com/w3c/resource-timing/issues/252">Issue 252</a> .
3824
3880
3825
3881
<li>
3826
3882
<p> If <var> response</var> is not null, then:
@@ -3952,8 +4008,9 @@ these steps:
3952
4008
<a for="filtered response">internal response</a> is <var> actualResponse</var> .
3953
4009
3954
4010
<dt> "<code> follow</code> "
3955
- <dd><p> Set <var> response</var> to the result of running <a>HTTP-redirect fetch</a> given
3956
- <var> fetchParams</var> and <var> response</var> .
4011
+ <dd><p> Set <var> timingInfo</var> 's <a for="fetch timing info">redirect start time</a> to
4012
+ <var> timingInfo</var> 's <a for="fetch timing info">fetch start time</a> , and set <var> response</var> to
4013
+ the result of running <a>HTTP-redirect fetch</a> given <var> fetchParams</var> and <var> response</var> .
3957
4014
</dl>
3958
4015
<!-- not resetting actualResponse since it's no longer used anyway -->
3959
4016
</ol>
@@ -4043,6 +4100,9 @@ run these steps:
4043
4100
<p class="note no-backref"><var> request</var> 's <a for=request>body</a>' s <a for=body>source</a> 's
4044
4101
nullity has already been checked.
4045
4102
4103
+ <li><p> Set <var> fetchParams</var> 's <a for="fetch params">timing info</a>' s <a for="fetch timing info">redirect end time</a>
4104
+ to the result of runnning <a for=/>current time</a> .
4105
+
4046
4106
<li><p> <a for=list>Append</a> <var> locationURL</var> to <var> request</var> 's
4047
4107
<a for=request>URL list</a> .
4048
4108
@@ -4720,8 +4780,9 @@ these steps:
4720
4780
</ol>
4721
4781
4722
4782
<li><p> <a for=body>Incrementally read</a> <var> request</var> 's <a for=request>body</a> given
4723
- <var> processBodyChunk</var> , <var> processEndOfBody</var> , <var> processBodyError</var> , and
4724
- <var> fetchParams</var> 's <a for="fetch params">task destination</a> .
4783
+ <var> processBodyChunk</var> , <var> processEndOfBody</var> , <var> processBodyError</var> ,
4784
+ <var> fetchParams</var> 's <a for="fetch params">task destination</a> , and
4785
+ <var> fetchParams</var> 's <a for="fetch params">timing info</a> .
4725
4786
<!-- This obtains a reader in parallel, but it's mostly fine since we already proxied the
4726
4787
input stream as part of the Request constructor. -->
4727
4788
</ol>
@@ -4820,17 +4881,30 @@ these steps:
4820
4881
4821
4882
<ol>
4822
4883
<li><p> Let <var> bytes</var> be the transmitted bytes.
4884
+ <li><p> Let <var> timingInfo</var> be the <var> fetchParams</var> 's <a for="fetch params">timing info</a> .
4823
4885
4824
4886
<li><p> Let <var> codings</var> be the result of <a>extracting header list values</a> given
4825
4887
`<code> Content-Encoding</code> ` and <var> response</var> 's <a for=response>header list</a> .
4826
4888
4889
+ <li><p> Set <var> timingInfo</var> 's <a for="fetch timing info">transfer size</a> to the result of
4890
+ adding <var> timingInfo</var> 's <a for="fetch timing info">transfer size</a> and <var> bytes</var> .
4891
+
4892
+ <p class=XXX> TODO: <a for="fetch timing info">transfer size</a> should also include the total size of the headers.
4893
+ See <a href="https://github.com/w3c/resource-timing/issues/252">Issue 252</a> .
4894
+
4895
+ <li><p> Set <var> timingInfo</var> 's <a for="fetch timing info">encoded body size</a> to the result of
4896
+ adding <var> timingInfo</var> 's <a for="fetch timing info">encoded body size</a> and <var> bytes</var> .
4897
+
4827
4898
<li>
4828
4899
<p> Set <var> bytes</var> to the result of <a lt="handle content codings">handling content
4829
4900
codings</a> given <var> codings</var> and <var> bytes</var> .
4830
4901
4831
4902
<p class="note no-backref"> This makes the `<code> Content-Length</code> ` <a for=/>header</a>
4832
4903
unreliable to the extent that it was reliable to begin with.
4833
4904
4905
+ <li><p> Set <var> timingInfo</var> 's <a for="fetch timing info">decoded body size</a> to the result of
4906
+ adding <var> timingInfo</var> 's <a for="fetch timing info">decoded body size</a> and <var> bytes</var> .
4907
+
4834
4908
<li><p> If <var> bytes</var> is failure, then <a lt=terminated for=fetch>terminate</a> the
4835
4909
ongoing fetch.
4836
4910
0 commit comments