NetworkEvent

Heather Arthur edited this page Jul 25, 2013 · 7 revisions

Events: "update"

Properties

url

URL of the request.

method

HTTP method of the request, e.g. "GET"

isXHR

Whether the request is an XHR request.

Methods

getRequestHeaders

getRequestHeaders(cb)

Get the request headers for this event. Response properties: headers, headerSize.

netEvent.getRequestHeaders(function(err, resp) {
  for (var i in resp.headers) {
    var header = resp.headers[i];
    console.log(header.name + ": " + header.value);
  }
});

getRequestCookies

getRequestCookies(cb)

Get the request cookies for this event:

netEvent.getRequestCookies(function(err, cookies) {
  for (var i in cookies) {
    var cookie = cookies[i];
    console.log(cookie.name + "=" + cookie.value);
  }
});

getRequestPostData

getRequestPostData(cb)

Get the request's POST data, if applicable. Response properties: postData, postDataDiscarded.

netEvent.getRequestPostData(function(err, resp) {
  console.log("POST data", resp.postData);
});

getResponseHeaders

getResponseHeaders(cb)

Get the response's headers. Response properties: headers, headersSize.

netEvent.getResponseHeaders(function(err, resp) {
  for (var i in resp.headers) {
    var header = resp.headers[i];
    console.log(header.name + ": " + header.value);
  }
});

getResponseCookies

getResponseCookies(cb)

Get the request cookies for this event:

netEvent.getRequestCookies(function(err, cookies) {
  for (var i in cookies) {
    var cookie = cookies[i];
    console.log(cookies[i].name + "=" + cookies[i].value);
  }
});

getResponseContent

getResponseContent(cb)

Get the response body. Response properties: content, contentDiscarded (if the body was not recorded).

netEvent.getResponseContent(function(err, resp) {
  console.log("response body:", response.content);
});

getEventTimings

getEventTimings(cb)

Get the (HAR) timings for this event. Response properties: timings, totalTime. timings is an object with properties: dns, connect, send, wait, receive.

netEvent.getEventTimings(function(err, resp) {
  console.log("total time:", resp.totalTime);
  console.log("DNS resolution time:", resp.timings.dns, "ms");
});

Events

request-headers

Fired when request headers are available. Event properties: headers (count of headers), headersSize (bytes).

request-cookies

Fired when the request cookies are available. Event properties: cookies (count of cookies).

request-postdata

Fired when the request POST data is available. Event properties: dataSize (length of data), discardRequestBody (if the data was not recorded).

response-start

Fired when initial response information is available. Event properties response.

response-headers

Fired when the response headers are available. Event properties: headers (number of headers), headerSize (size in bytes).

response-cookies

Fired when response cookies are available. Event properties: cookies (number of cookies).

response-content

Fired when response body is available. Event properties: mimeType, contentSize (bytes), discardResponseBody

event-timings

Fired when event timing info is available. Event properties: totalTime (total time of event in ms).