blob: ca9a24e720d6b963f59efca13a78c20bde916d45 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
<!-- BEGIN AUTHORED CONTENT -->
<div id="pageData-name" class="pageData">chrome.experimental.devtools.network
API</div>
<p id="classSummary">
Use the <code>chrome.experimental.devtools.network</code> module to retrieve
the information about network requests displayed by the Developer Tools
in the Network panel.
</p><p>
See <a href="experimental.devtools.html">DevTools APIs summary</a> for
general introduction to using Developer Tools APIs</a>.
</p>
<h2>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://groups.google.com/group/http-archive-specification/web/har-1-2-spec">
HAR v1.2 Specification</a>.
</p><p>
In terms of HAR, the
<code>chrome.experimental.devtools.network.getHAR()</code> method returns
entire <em>HAR log</em>, while
<code>chrome.experimental.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.experimental.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.html#devtools.network">Samples</a>.
</p>
<!-- END AUTHORED CONTENT -->
|