OLD | NEW |
1 <!-- BEGIN AUTHORED CONTENT --> | 1 <div id="pageData-name" class="pageData">chrome.devtools.network |
| 2 API</div> |
2 <p id="classSummary"> | 3 <p id="classSummary"> |
3 Use the <code>chrome.devtools.network</code> module to retrieve | 4 Use the <code>chrome.devtools.network</code> module to retrieve |
4 the information about network requests displayed by the Developer Tools | 5 the information about network requests displayed by the Developer Tools |
5 in the Network panel. | 6 in the Network panel. |
6 </p><p> | 7 </p><p> |
7 See <a href="devtools.html">DevTools APIs summary</a> for | 8 See <a href="devtools.html">DevTools APIs summary</a> for |
8 general introduction to using Developer Tools APIs</a>. | 9 general introduction to using Developer Tools APIs</a>. |
9 </p> | 10 </p> |
10 | |
11 <h2>Overview</h2> | 11 <h2>Overview</h2> |
12 | |
13 <p> | 12 <p> |
14 Network requests information is represented in the HTTP Archive format | 13 Network requests information is represented in the HTTP Archive format |
15 (<em>HAR</em>). The description of HAR is outside of scope of this document, | 14 (<em>HAR</em>). The description of HAR is outside of scope of this document, |
16 please refer to <a href= | 15 please refer to <a href= |
17 "http://www.softwareishard.com/blog/har-12-spec/"> | 16 "http://www.softwareishard.com/blog/har-12-spec/"> |
18 HAR v1.2 Specification</a>. | 17 HAR v1.2 Specification</a>. |
19 </p><p> | 18 </p><p> |
20 In terms of HAR, the | 19 In terms of HAR, the |
21 <code>chrome.devtools.network.getHAR()</code> method returns | 20 <code>chrome.devtools.network.getHAR()</code> method returns |
22 entire <em>HAR log</em>, while | 21 entire <em>HAR log</em>, while |
23 <code>chrome.devtools.network.onRequestFinished</code> event | 22 <code>chrome.devtools.network.onRequestFinished</code> event |
24 provides <em>HAR entry</em> as an argument to the event callback. | 23 provides <em>HAR entry</em> as an argument to the event callback. |
25 </p> | 24 </p> |
26 <p>Note that request content is not provided as part of HAR for efficieny | 25 <p>Note that request content is not provided as part of HAR for efficieny |
27 reasons. You may call request's <code>getContent()</code> method to retrieve | 26 reasons. You may call request's <code>getContent()</code> method to retrieve |
28 content. | 27 content. |
29 <p>If the Developer Tools window is opened after the page is loaded, | 28 <p>If the Developer Tools window is opened after the page is loaded, |
30 some requests may be missing | 29 some requests may be missing |
31 in the array of entries returned by <code>getHAR()</code>. | 30 in the array of entries returned by <code>getHAR()</code>. |
32 Reload the page to get all requests. | 31 Reload the page to get all requests. |
33 In general, the list of | 32 In general, the list of |
34 requests returned by <code>getHAR()</code> should match that displayed in | 33 requests returned by <code>getHAR()</code> should match that displayed in |
35 the Network panel. | 34 the Network panel. |
36 <h2 id="overview-examples">Examples</h2> | 35 <h2 id="overview-examples">Examples</h2> |
37 | |
38 <p>The following code logs URLs of all images larger than 40KB as they are | 36 <p>The following code logs URLs of all images larger than 40KB as they are |
39 loaded:</p> | 37 loaded:</p> |
40 | |
41 <pre> | 38 <pre> |
42 chrome.devtools.network.onRequestFinished.addListener( | 39 chrome.devtools.network.onRequestFinished.addListener( |
43 function(request) { | 40 function(request) { |
44 if (request.response.bodySize > 40*1024) | 41 if (request.response.bodySize > 40*1024) |
45 chrome.experimental.devtools.console.addMessage( | 42 chrome.experimental.devtools.console.addMessage( |
46 chrome.experimental.devtools.console.Severity.Warning, | 43 chrome.experimental.devtools.console.Severity.Warning, |
47 "Large image: " + request.request.url); | 44 "Large image: " + request.request.url); |
48 }); | 45 }); |
49 </pre> | 46 </pre> |
50 | |
51 <p> | 47 <p> |
52 You can find more examples that use this API in | 48 You can find more examples that use this API in |
53 <a href="samples.html#devtools.network">Samples</a>. | 49 <a href="samples.html#devtools.network">Samples</a>. |
54 </p> | 50 </p> |
55 | |
56 <!-- END AUTHORED CONTENT --> | |
OLD | NEW |