mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-11 16:32:59 +00:00
Bug 1130318 - Send also header source from the backend. r=vporof
This commit is contained in:
parent
c6869264c8
commit
7db9d04684
@ -1729,6 +1729,7 @@ NetworkEventActor.prototype =
|
||||
from: this.actorID,
|
||||
headers: this._request.headers,
|
||||
headersSize: this._request.headersSize,
|
||||
rawHeaders: this._request.rawHeaders,
|
||||
};
|
||||
},
|
||||
|
||||
@ -1787,6 +1788,7 @@ NetworkEventActor.prototype =
|
||||
from: this.actorID,
|
||||
headers: this._response.headers,
|
||||
headersSize: this._response.headersSize,
|
||||
rawHeaders: this._response.rawHeaders,
|
||||
};
|
||||
},
|
||||
|
||||
@ -1843,12 +1845,20 @@ NetworkEventActor.prototype =
|
||||
*
|
||||
* @param array aHeaders
|
||||
* The request headers array.
|
||||
* @param string aRawHeaders
|
||||
* The raw headers source.
|
||||
*/
|
||||
addRequestHeaders: function NEA_addRequestHeaders(aHeaders)
|
||||
addRequestHeaders: function NEA_addRequestHeaders(aHeaders, aRawHeaders)
|
||||
{
|
||||
this._request.headers = aHeaders;
|
||||
this._prepareHeaders(aHeaders);
|
||||
|
||||
var rawHeaders = this.parent._createStringGrip(aRawHeaders);
|
||||
if (typeof rawHeaders == "object") {
|
||||
this._longStringActors.add(rawHeaders);
|
||||
}
|
||||
this._request.rawHeaders = rawHeaders;
|
||||
|
||||
let packet = {
|
||||
from: this.actorID,
|
||||
type: "networkEventUpdate",
|
||||
@ -1911,9 +1921,17 @@ NetworkEventActor.prototype =
|
||||
*
|
||||
* @param object aInfo
|
||||
* The response information.
|
||||
* @param string aRawHeaders
|
||||
* The raw headers source.
|
||||
*/
|
||||
addResponseStart: function NEA_addResponseStart(aInfo)
|
||||
addResponseStart: function NEA_addResponseStart(aInfo, aRawHeaders)
|
||||
{
|
||||
var rawHeaders = this.parent._createStringGrip(aRawHeaders);
|
||||
if (typeof rawHeaders == "object") {
|
||||
this._longStringActors.add(rawHeaders);
|
||||
}
|
||||
this._response.rawHeaders = rawHeaders;
|
||||
|
||||
this._response.httpVersion = aInfo.httpVersion;
|
||||
this._response.status = aInfo.status;
|
||||
this._response.statusText = aInfo.statusText;
|
||||
|
@ -796,7 +796,7 @@ NetworkMonitor.prototype = {
|
||||
|
||||
this.openRequests[httpActivity.id] = httpActivity;
|
||||
|
||||
httpActivity.owner.addRequestHeaders(headers);
|
||||
httpActivity.owner.addRequestHeaders(headers, aExtraStringData);
|
||||
httpActivity.owner.addRequestCookies(cookies);
|
||||
},
|
||||
|
||||
@ -924,7 +924,7 @@ NetworkMonitor.prototype = {
|
||||
// contains the response status (e.g. HTTP/1.1 200 OK).
|
||||
//
|
||||
// Note: The response header is not saved here. Calling the
|
||||
// channel.visitResponseHeaders() methood at this point sometimes causes an
|
||||
// channel.visitResponseHeaders() method at this point sometimes causes an
|
||||
// NS_ERROR_NOT_AVAILABLE exception.
|
||||
//
|
||||
// We could parse aExtraStringData to get the headers and their values, but
|
||||
@ -955,7 +955,7 @@ NetworkMonitor.prototype = {
|
||||
|
||||
response.discardResponseBody = aHttpActivity.discardResponseBody;
|
||||
|
||||
aHttpActivity.owner.addResponseStart(response);
|
||||
aHttpActivity.owner.addResponseStart(response, aExtraStringData);
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -160,6 +160,24 @@ function checkHeadersOrCookies(aArray, aExpected)
|
||||
}
|
||||
}
|
||||
|
||||
function checkRawHeaders(aText, aExpected)
|
||||
{
|
||||
let headers = aText.split(/\r\n|\n|\r/);
|
||||
let arr = [];
|
||||
for (let header of headers) {
|
||||
let index = header.indexOf(": ");
|
||||
if (index < 0) {
|
||||
continue;
|
||||
}
|
||||
arr.push({
|
||||
name: header.substr(0, index),
|
||||
value: header.substr(index + 2)
|
||||
});
|
||||
}
|
||||
|
||||
checkHeadersOrCookies(arr, aExpected);
|
||||
}
|
||||
|
||||
var gTestState = {};
|
||||
|
||||
function runTests(aTests, aEndCallback)
|
||||
|
@ -141,12 +141,18 @@ function onRequestHeaders(aState, aResponse)
|
||||
|
||||
ok(aResponse.headers.length > 0, "request headers > 0");
|
||||
ok(aResponse.headersSize > 0, "request headersSize > 0");
|
||||
ok(!!aResponse.rawHeaders, "request rawHeaders available");
|
||||
|
||||
checkHeadersOrCookies(aResponse.headers, {
|
||||
Referer: /network_requests_iframe\.html/,
|
||||
Cookie: /bug768096/,
|
||||
});
|
||||
|
||||
checkRawHeaders(aResponse.rawHeaders, {
|
||||
Referer: /network_requests_iframe\.html/,
|
||||
Cookie: /bug768096/,
|
||||
});
|
||||
|
||||
onRequestCookies = onRequestCookies.bind(null, aState);
|
||||
aState.client.getRequestCookies(aState.netActor,
|
||||
onRequestCookies);
|
||||
@ -187,12 +193,18 @@ function onResponseHeaders(aState, aResponse)
|
||||
|
||||
ok(aResponse.headers.length > 0, "response headers > 0");
|
||||
ok(aResponse.headersSize > 0, "response headersSize > 0");
|
||||
ok(!!aResponse.rawHeaders, "response rawHeaders available");
|
||||
|
||||
checkHeadersOrCookies(aResponse.headers, {
|
||||
"Content-Type": /^application\/(json|octet-stream)$/,
|
||||
"Content-Length": /^\d+$/,
|
||||
});
|
||||
|
||||
checkRawHeaders(aResponse.rawHeaders, {
|
||||
"Content-Type": /^application\/(json|octet-stream)$/,
|
||||
"Content-Length": /^\d+$/,
|
||||
});
|
||||
|
||||
onResponseCookies = onResponseCookies.bind(null, aState);
|
||||
aState.client.getResponseCookies(aState.netActor,
|
||||
onResponseCookies);
|
||||
|
@ -157,12 +157,18 @@ function onRequestHeaders(aState, aResponse)
|
||||
|
||||
ok(aResponse.headers.length > 0, "request headers > 0");
|
||||
ok(aResponse.headersSize > 0, "request headersSize > 0");
|
||||
ok(!!aResponse.rawHeaders.length, "request rawHeaders available");
|
||||
|
||||
checkHeadersOrCookies(aResponse.headers, {
|
||||
Referer: /network_requests_iframe\.html/,
|
||||
Cookie: /bug768096/,
|
||||
});
|
||||
|
||||
checkRawHeaders(aResponse.rawHeaders, {
|
||||
Referer: /network_requests_iframe\.html/,
|
||||
Cookie: /bug768096/,
|
||||
});
|
||||
|
||||
onRequestCookies = onRequestCookies.bind(null, aState);
|
||||
aState.client.getRequestCookies(aState.netActor,
|
||||
onRequestCookies);
|
||||
@ -209,12 +215,18 @@ function onResponseHeaders(aState, aResponse)
|
||||
|
||||
ok(aResponse.headers.length > 0, "response headers > 0");
|
||||
ok(aResponse.headersSize > 0, "response headersSize > 0");
|
||||
ok(!!aResponse.rawHeaders, "response rawHeaders available");
|
||||
|
||||
checkHeadersOrCookies(aResponse.headers, {
|
||||
"Content-Type": /^application\/(json|octet-stream)$/,
|
||||
"Content-Length": /^\d+$/,
|
||||
});
|
||||
|
||||
checkRawHeaders(aResponse.rawHeaders, {
|
||||
"Content-Type": /^application\/(json|octet-stream)$/,
|
||||
"Content-Length": /^\d+$/,
|
||||
});
|
||||
|
||||
onResponseCookies = onResponseCookies.bind(null, aState);
|
||||
aState.client.getResponseCookies(aState.netActor,
|
||||
onResponseCookies);
|
||||
|
Loading…
Reference in New Issue
Block a user