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

Commit 58d23f5

Browse files
tcolgatekjin
authored andcommitted
fix: correctly set HTTP headers on outgoing requests. (#69)
settings options.headers does not directly update the headers, setHeader ensures the modifications make it to the actual request.
1 parent e5222c4 commit 58d23f5

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

  • packages/opencensus-instrumentation-http/src

packages/opencensus-instrumentation-http/src/http.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,10 +256,9 @@ export class HttpPlugin extends BasePlugin {
256256
return (span: Span): httpModule.ClientRequest => {
257257
plugin.logger.debug('makeRequestTrace');
258258

259-
const headers = options.headers;
260259
const setter: HeaderSetter = {
261260
setHeader(name: string, value: string) {
262-
headers[name] = value;
261+
request.setHeader(name, value);
263262
}
264263
};
265264

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

0 commit comments

Comments
 (0)