mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
Assert that all extra HTTP header values are strings (#781)
Since protocol ignores all HTTP headers that don't have string value, this patch starts validating header key-values before sending them over the protocol. Fixes #713.
This commit is contained in:
@@ -63,8 +63,11 @@ class NetworkManager extends EventEmitter {
|
||||
*/
|
||||
async setExtraHTTPHeaders(extraHTTPHeaders) {
|
||||
this._extraHTTPHeaders = {};
|
||||
for (const key of Object.keys(extraHTTPHeaders))
|
||||
this._extraHTTPHeaders[key.toLowerCase()] = extraHTTPHeaders[key];
|
||||
for (const key of Object.keys(extraHTTPHeaders)) {
|
||||
const value = extraHTTPHeaders[key];
|
||||
console.assert(helper.isString(value), `Expected value of header "${key}" to be String, but "${typeof value}" is found.`);
|
||||
this._extraHTTPHeaders[key.toLowerCase()] = value;
|
||||
}
|
||||
await this._client.send('Network.setExtraHTTPHeaders', { headers: this._extraHTTPHeaders });
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user