Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Allow passing arbitrary headers #157

Closed
wants to merge 1 commit into
from
Jump to file or symbol
Failed to load files and symbols.
+10 −1
Split
View
@@ -393,7 +393,8 @@ function initAsClient(address, options) {
origin: null,
protocolVersion: protocolVersion,
host: null,
- protocol: null
+ protocol: null,
+ headers: null
}).merge(options);
if (options.value.protocolVersion != 8 && options.value.protocolVersion != 13) {
throw new Error('unsupported protocol version');
@@ -445,6 +446,14 @@ function initAsClient(address, options) {
requestOptions.headers['Host'] = options.value.host;
}
+ if (options.value.headers) {
+ for (var key in options.value.headers) {
+ if (!requestOptions.headers.hasOwnProperty(key)) {
+ requestOptions.headers[key] = options.value.headers[key];
+ }
+ }
+ }
+
if (isNodeV4) {
requestOptions.path = (serverUrl.pathname || '/') + (serverUrl.search || '');
requestOptions.agent = agent;