Skip to content
This repository has been archived by the owner on Oct 3, 2023. It is now read-only.

Commit

Permalink
fix: correctly set HTTP headers on outgoing requests. (#69)
Browse files Browse the repository at this point in the history
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 e5222c4 commit 58d23f5
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 58d23f5

Please sign in to comment.