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