Implement Request.setHeader() method

This patch implements Request.setHeader() method to override
request headers.

References #8.
This commit is contained in:
Andrey Lushnikov 2017-06-15 08:37:06 -07:00
parent 5ba6621cde
commit 50976c7f29
2 changed files with 6 additions and 4 deletions

View File

@ -71,10 +71,13 @@ class Request {
} }
/** /**
* @param {!Object} headers * @param {string} key
* @param {string} value
*/ */
setHeaders(headers) { setHeader(key, value) {
this._headersOverride = headers; if (!this._headersOverride)
this._headersOverride = Object.assign({}, this._headers);
this._headersOverride[key] = value;
} }
/** /**

View File

@ -1,4 +1,3 @@
//! unsupported
async_test(function () { async_test(function () {
var webpage = require('webpage'); var webpage = require('webpage');