| <p> |
| See <a href="devtools">DevTools APIs summary</a> for |
| general introduction to using Developer Tools APIs</a>. |
| </p> |
| |
| <h2 id="overview">Overview</h2> |
| |
| <p> |
| Network requests information is represented in the HTTP Archive format |
| (<em>HAR</em>). The description of HAR is outside of scope of this document, |
| please refer to <a href= |
| "http://www.softwareishard.com/blog/har-12-spec/"> |
| HAR v1.2 Specification</a>. |
| </p><p> |
| In terms of HAR, the |
| <code>chrome.devtools.network.getHAR()</code> method returns |
| entire <em>HAR log</em>, while |
| <code>chrome.devtools.network.onRequestFinished</code> event |
| provides <em>HAR entry</em> as an argument to the event callback. |
| </p> |
| <p>Note that request content is not provided as part of HAR for efficieny |
| reasons. You may call request's <code>getContent()</code> method to retrieve |
| content. |
| <p>If the Developer Tools window is opened after the page is loaded, |
| some requests may be missing |
| in the array of entries returned by <code>getHAR()</code>. |
| Reload the page to get all requests. |
| In general, the list of |
| requests returned by <code>getHAR()</code> should match that displayed in |
| the Network panel. |
| <h2 id="overview-examples">Examples</h2> |
| |
| <p>The following code logs URLs of all images larger than 40KB as they are |
| loaded:</p> |
| |
| <pre> |
| chrome.devtools.network.onRequestFinished.addListener( |
| function(request) { |
| if (request.response.bodySize > 40*1024) |
| chrome.experimental.devtools.console.addMessage( |
| chrome.experimental.devtools.console.Severity.Warning, |
| "Large image: " + request.request.url); |
| }); |
| </pre> |
| |
| <p> |
| You can find more examples that use this API in |
| <a href="samples#devtools.network">Samples</a>. |
| </p> |