|
17 | 17 | }, {
|
18 | 18 | name: "Ilya Grigorik",
|
19 | 19 | url: "https://www.igvita.com/",
|
| 20 | + mailto: "igrigorik@gmail.com", |
20 | 21 | company: "Google",
|
21 | 22 | companyURL: "https://www.google.com/",
|
22 | 23 | w3cid: "56102"
|
|
67 | 68 |
|
68 | 69 | <section id='conformance'></section>
|
69 | 70 |
|
| 71 | +<section> |
70 | 72 | ### The `Server-Timing` Header Field
|
71 | 73 |
|
72 | 74 | The <dfn>Server-Timing header field</dfn> is used to communicate one or more metrics and descriptions for the given request-response cycle. The ABNF (Augmented Backus-Naur Form) [[RFC5234]] syntax for the [=Server-Timing header field=] is as follows:
|
|
106 | 108 | - The server and/or any relevant intermediaries are in full control of which metrics are communicated to the user agent and when. For example, access to some metrics may be restricted due to privacy or security reasons - see <a href="#privacy-and-security"></a> section.
|
107 | 109 | </div>
|
108 | 110 |
|
| 111 | +Tp <dfn>parse a server-timing header field</dfn> given string |field|: |
| 112 | + |
| 113 | +1. Let |position| be a [=string/position variable=], initially pointing at the start of |field|. |
| 114 | + |
| 115 | +1. Let |rawName| be the result of [=collecting a sequence of code points=] that are not equal to U+003B (;), given |position|. |
| 116 | + |
| 117 | +1. Let |name| be the result of [=strip leading and trailing ASCII whitespace|stripping=] |rawName|. |
| 118 | + |
| 119 | +1. If |name| is an empty string, [=iteration/continue=]. |
| 120 | + |
| 121 | +1. Let |metric| be a new {{PerformanceServerTiming}} whose <a data-for= |
| 122 | + "PerformanceServerTiming">metric name</a> is |name|. |
| 123 | + |
| 124 | +1. Let |params| be an empty <a data-cite="INFRA#map">map</a>. |
| 125 | + |
| 126 | +1. While |position| is not at the end of |field|: |
| 127 | + |
| 128 | + 1. Advance |position| by 1. |
| 129 | + |
| 130 | + 1. Let |rawParamName| be the result of [=collecting a sequence of code points=] from |field| |
| 131 | + that are not equal to U+003D (=), given |position|. |
| 132 | + |
| 133 | + 1. Let |paramName| be the result of [=strip leading and trailing ASCII whitespace|stripping=] |rawParamName|. |
| 134 | + |
| 135 | + 1. If |paramName| is an empty string or |params|[|paramName|] [=map/exists=], [=iteration/continue=]. |
| 136 | + |
| 137 | + 1. Advance |position| by 1. |
| 138 | + |
| 139 | + 1. Let |paramValue| be an empty string. |
| 140 | + |
| 141 | + 1. [=Skip ASCII whitespace=] within |field| given |position|. |
| 142 | + |
| 143 | + 1. If the [=code point=] at |position| within |field| is U+0022 ("), then: |
| 144 | + |
| 145 | + 1. Set |paramValue| to the result of [=collecting an HTTP quoted string=] from |field| given |position| with the extract-value flag set. |
| 146 | + |
| 147 | + 1. [=Collect a sequence of code points=] that are not equal to U+003B (;), given |position|. The result is not used. |
| 148 | + |
| 149 | + 1. Otherwise: |
| 150 | + |
| 151 | + 1. Let |rawParamValue| be the result of [=collecting a sequence of code points=] from |field| that are not equal to U+003B (;), given |position|. |
| 152 | + |
| 153 | + 1. Let |paramValue| be the result of [=strip leading and trailing ASCII whitespace|stripping=] |rawParamValue|. |
| 154 | + |
| 155 | +1. [=map/set|Set=] |metric|'s <a data-for="PerformanceServerTiming">params</a> to |params|. |
| 156 | + |
| 157 | +</section> |
| 158 | + |
109 | 159 | <section data-dfn-for="PerformanceServerTiming" data-link-for="PerformanceServerTiming">
|
110 | 160 | ## The <dfn>PerformanceServerTiming</dfn> Interface
|
111 | 161 |
|
|
122 | 172 | When <dfn class="export" data-dfn-for="PerformanceServerTiming">toJSON</dfn> is called, run [[WEBIDL]]'s [=default toJSON steps=].
|
123 | 173 |
|
124 | 174 | ### <dfn>name</dfn> attribute
|
125 |
| - The <a>name</a> getter steps are to return <a>this</a>'s <a data-for= |
126 |
| - "PerformanceServerTiming">metric name</a>. |
| 175 | + The <a>name</a> getter steps are to return <a>this</a>'s <a data-for="PerformanceServerTiming">metric name</a>. |
127 | 176 |
|
128 | 177 | ### <dfn>duration</dfn> attribute
|
129 | 178 | The <a>duration</a> getter steps are to do the following:
|
130 |
| - <ol> |
131 |
| - <li><p>If <a>this</a>'s <a data-for="PerformanceServerTiming">params</a>[<code>"dur"</code>] does not [=map/exists|exist=], return 0.</p></li> |
132 | 179 |
|
133 |
| - <li><p>Let |dur| be the result of parsing <a>this</a>'s <a data-for="PerformanceServerTiming">params</a>[<code>"dur"</code>] using the [=rules for parsing floating-point number values=].</p></li> |
| 180 | + 1. If <a>this</a>'s <a data-for="PerformanceServerTiming">params</a>[<code>"dur"</code>] does not [=map/exists|exist=], return 0. |
134 | 181 |
|
135 |
| - <li><p>If |dur| is an error, return 0; Otherwise return |dur|.</p></li> |
136 |
| - </ol> |
| 182 | + 1. Let |dur| be the result of parsing <a>this</a>'s <a data-for="PerformanceServerTiming">params</a>[<code>"dur"</code>] using the [=rules for parsing floating-point number values=]. |
| 183 | + |
| 184 | + 1. If |dur| is an error, return 0; Otherwise return |dur|. |
137 | 185 |
|
138 | 186 | ### <dfn>description</dfn> attribute
|
139 | 187 | The <a>description</a> getter steps are to return <a>this</a>'s <a data-for="PerformanceServerTiming">params</a>[<code>"desc"</code>] if it [=map/exists=], otherwise the empty string.
|
|
159 | 207 | ### <code>serverTiming</code> attribute
|
160 | 208 |
|
161 | 209 | The <dfn>serverTiming</dfn> getter steps are the following:
|
162 |
| - <ol> |
163 |
| - <li><p>Let |entries| be a new [=list=].</p></li> |
164 | 210 |
|
165 |
| - <li> |
166 |
| - <p>[=list/iterate|For each=] |rawMetric| in <a>this</a>'s <a data-cite="RESOURCE-TIMING#dfn-timing-info">timing info</a>'s [=fetch timing info/server timing headerss=]:</p> |
| 211 | + 1. Let |entries| be a new [=list=]. |
167 | 212 |
|
168 |
| - <ol> |
169 |
| - <li><p>Let |position| be a [=string/position variable=], initially pointing at the start of |rawMetric|.</p></li> |
| 213 | + 1. [=list/iterate|For each=] |field| in <a>this</a>'s <a data-cite="RESOURCE-TIMING#dfn-timing-info">timing info</a>'s [=fetch timing info/server timing headers=]: |
170 | 214 |
|
171 |
| - <li><p>Let |rawName| be the result of [=collecting a sequence of code points=] |
172 |
| - that are not equal to U+003B (;), given <var>position</var>. |
| 215 | + 1. Let |metric| be the result of [=parse a server-timing header field|parsing=] |field|. |
173 | 216 |
|
174 |
| - <li><p>Let |name| be the result of [=strip leading and trailing ASCII whitespace|stripping=] |rawName|.</p></li> |
175 |
| - |
176 |
| - <li><p>If |name| is an empty string, [=iteration/continue=].</p></li> |
177 |
| - |
178 |
| - <li><p>Let |metric| be a new {{PerformanceServerTiming}} whose <a data-for= |
179 |
| - "PerformanceServerTiming">metric name</a> is |name|.</p></li> |
180 |
| - |
181 |
| - <li><p>Let |params| be an empty <a data-cite="INFRA#map">map</a>.</p></li> |
182 |
| - |
183 |
| - <li> |
184 |
| - <p>While |position| is not at the end of |rawMetric|:</p> |
185 |
| - |
186 |
| - <ol> |
187 |
| - <li><p>Advance <var>position</var> by 1.</p></li> |
188 |
| - |
189 |
| - <li><p>Let |rawParamName| be the result of [=collecting a sequence of code points=] from |rawMetric| |
190 |
| - that are not equal to U+003D (=), given <var>position</var>.</p></li> |
191 |
| - |
192 |
| - <li><p>Let |paramName| be the result of [=strip leading and trailing ASCII whitespace|stripping=] |rawParamName|.</p></li> |
193 |
| - |
194 |
| - <li><p>If |paramName| is an empty string or |params|[|paramName|] [=map/exists=], [=iteration/continue=].</p></li> |
195 |
| - |
196 |
| - <li><p>Advance <var>position</var> by 1.</p></li> |
197 |
| - |
198 |
| - <li><p>Let |paramValue| be an empty string.</p></li> |
199 |
| - |
200 |
| - <li><p>[=Skip ASCII whitespace=] within |rawMetric| given |position|.</p></li> |
201 |
| - |
202 |
| - <li> |
203 |
| - <p>If the [=code point=] at |position| within |rawMetric| is U+0022 ("), then:</p> |
204 |
| - |
205 |
| - <ol> |
206 |
| - <li><p>>Set |paramValue| to the result of [=collecting an HTTP quoted string=] from |
207 |
| - |rawMetric| given <var>position</var> with the extract-value flag set.</p></li> |
208 |
| - |
209 |
| - <li><p>[=Collect a sequence of code points=] that are not equal to U+003B (;), |
210 |
| - given <var>position</var>. The result is not used. |
211 |
| - </ol> |
212 |
| - </li> |
213 |
| - |
214 |
| - <li> |
215 |
| - <p>Otherwise:</p> |
216 |
| - <ol> |
217 |
| - <li><p>Let |rawParamValue| be the result of [=collecting a sequence of code points=] from |rawMetric| |
218 |
| - that are not equal to U+003B (;), given <var>position</var>.</p></li> |
219 |
| - |
220 |
| - <li><p>Let |paramValue| be the result of [=strip leading and trailing ASCII whitespace|stripping=] |rawParamValue|.</p></li> |
221 |
| - </ol> |
222 |
| - </li> |
223 |
| - </ol> |
224 |
| - </li> |
225 |
| - |
226 |
| - <li><p>[=map/set=] |metric|'s <a data-for="PerformanceServerTiming">params</a> to |params|</p></li> |
227 |
| - |
228 |
| - <li><p>[=list/append|Append=] |metric| to |entries|.</p></li> |
229 |
| - </ol> |
230 |
| - </li> |
231 |
| - |
232 |
| - <li><p>Return |list|.</p></li> |
233 |
| - </ol> |
234 |
| -</section> |
235 |
| - |
236 |
| -<section> |
237 |
| -## Process |
238 |
| - |
239 |
| -### Processing Model |
240 |
| -<p>When processing the response of the <a data-cite="NAVIGATION-TIMING#dfn-current-document">current document</a>, set the {{PerformanceResourceTiming/serverTiming}} attribute on the <a data-cite="NAVIGATION-TIMING#step-create-object">newly created</a> `PerformanceNavigationTiming` object to the return value of the [=server-timing header parsing algorithm=] |
241 |
| -</p> |
242 |
| - |
243 |
| -<p>For each resource [=fetch|fetched=] by the current [=browsing context=], excluding resources fetched by cross-origin stylesheets fetched with `no-cors` policy, set the {{PerformanceResourceTiming/serverTiming}} attribute on the <a data-cite="RESOURCE-TIMING#step-create-object">newly created</a> {{PerformanceResourceTiming}} object to: |
244 |
| - <ol> |
245 |
| - <li>An empty [=sequence=], if the return value from the "timing allow check" algorithm (as defined in [[RESOURCE-TIMING]]) is `fail`.</li> |
246 |
| - <li>An empty [=sequence=], if the user agent chooses to limit their support to <span data-cite="html">[=secure contexts=]</span> and the <a data-cite="RESOURCE-TIMING#dfn-current-document">current document</a>'s [=environment settings object=] is <a data-cite="html" data-lt="non-secure contexts">not contextually secure</a>.</li> |
247 |
| - <li>The return value of the [=server-timing header parsing algorithm=], otherwise.</li> |
248 |
| - </ol> |
249 |
| -</p> |
| 217 | + 1. If |metric| is not null, [=list/append=] |metric| to |entries|. |
250 | 218 |
|
251 |
| -#### <dfn>server-timing header parsing algorithm</dfn> |
252 |
| -<p>Given a |resource timing object|, perform the following steps:</p> |
253 |
| - |
254 |
| -<ol> |
255 |
| - <li>Let |entryList| be a new empty [=sequence=]. |
256 |
| - </li> |
257 |
| - <li>For each server-specified metric received from parsing the [=Server-Timing header field=], perform the following steps: |
258 |
| - <ol data-link-for="PerformanceServerTiming"> |
259 |
| - <li>Let |entry:PerformanceServerTiming| be a new {{PerformanceServerTiming}} object.</li> |
260 |
| - <li>Set {{name}} to metric-name.</li> |
261 |
| - <li>Set {{duration}} to the server-timing-param-value for the server-timing-param where server-timing-param-name is case-insensitively equal to "dur", or value 0 if omitted or not representable as a double.</li> |
262 |
| - <li>Set {{description}} to the server-timing-param-value for the server-timing-param where server-timing-param-name is case-insensitively equal to "desc", or an empty string if omitted.</li> |
263 |
| - <li>Append |entry| to |entryList|. |
264 |
| - </li> |
265 |
| - </ol> |
266 |
| - </li> |
267 |
| - <li>Return |entryList|</li> |
268 |
| -</ol> |
269 |
| - |
270 |
| -<p>The user-agent MAY process [=Server-Timing header field=] communicated via a trailer field (see [[RFC7230]] section 4.1.2) using the same algorithm.</p> |
| 219 | + 1. Return |list|. |
271 | 220 | </section>
|
272 | 221 |
|
273 | 222 | <section class='informative'>
|
|
0 commit comments