Skip to content

Commit

Permalink
fix: correctly set HTTP headers on outgoing requests. (census-instrum…
Browse files Browse the repository at this point in the history
…entation#69)

settings options.headers does not directly update the headers,
setHeader ensures the modifications make it to the actual request.
  • Loading branch information
tcolgate authored and kjin committed Jun 29, 2018
1 parent 306efa0 commit bdbd215
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions packages/opencensus-instrumentation-http/src/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,9 @@ export class HttpPlugin extends BasePlugin {
return (span: Span): httpModule.ClientRequest => {
plugin.logger.debug('makeRequestTrace');

const headers = options.headers;
const setter: HeaderSetter = {
setHeader(name: string, value: string) {
headers[name] = value;
request.setHeader(name, value);
}
};

Expand All @@ -280,6 +279,7 @@ export class HttpPlugin extends BasePlugin {
response.on('end', () => {
plugin.logger.debug('outgoingRequest on end()');
const method = response.method ? response.method : 'GET';
const headers = options.headers;
const userAgent =
headers ? (headers['user-agent'] || headers['User-Agent']) : null;

Expand Down

0 comments on commit bdbd215

Please sign in to comment.