Skip to content

Commit

Permalink
add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
wconti27 committed Feb 18, 2025
1 parent e4c4494 commit f483748
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
4 changes: 3 additions & 1 deletion packages/datadog-plugin-http/src/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ class HttpClientPlugin extends ClientPlugin {
addResponseHeaders(res, span, this.config)
}

addRequestHeaders(req, span, this.config)
if (req) {
addRequestHeaders(req, span, this.config)
}

this.config.hooks.request(span, req, res)

Expand Down
10 changes: 7 additions & 3 deletions packages/datadog-plugin-http/test/client.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -944,9 +944,13 @@ describe('Plugin', () => {
.then(done)
.catch(done)

http.request('https://httpbin.org/get', { headers: { BadHeader: 'a\nb' } }, res => {
res.on('data', () => { })
})
try {
http.request('http://httpbin.org/get', { headers: { BadHeader: 'a\nb' } }, res => {
res.on('data', () => { })
})
} catch {
// expected to throw error
}
})
})

Expand Down

0 comments on commit f483748

Please sign in to comment.