Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

outgoing requests have 2 user agent headers #1083

Closed
lucianolxp opened this issue Apr 3, 2020 · 1 comment · Fixed by #1084
Closed

outgoing requests have 2 user agent headers #1083

lucianolxp opened this issue Apr 3, 2020 · 1 comment · Fixed by #1084
Labels
difficulty: easy fix is easy in difficulty type: bug bug in the library

Comments

@lucianolxp
Copy link

Issue Summary

with the change from request to axios, the outgoing requests have now 2 user agent headers:

  • 'User-agent': 'sendgrid/7.0.0;nodejs'
  • 'User-Agent': 'axios/0.19.2'

this makes our testing with nock fail, because it tries to lower-case all headers and breaks when there is a conflict.

Steps to Reproduce

  1. create a mock server to receive requests made with the sdk
  2. inspect any incoming request header

Code Snippet

sendgrid adds the user agent header with uppercase "U" and lowercase "a"

'User-agent': 'sendgrid/' + pkg.version + ';nodejs',

but axios just checks for the header with "u" + "a" or "U" + "A"
https://github.com/axios/axios/blob/42eb9dfabc85ed029462da1c503f8b414b08ffd0/lib/adapters/http.js#L34

if (!headers['User-Agent'] && !headers['user-agent']) {

Exception/Log

the resulting request has both headers:

headers: {
  Accept: 'application/json',
  'Content-Type': 'application/json',
  'User-agent': 'sendgrid/7.0.0;nodejs',
  Authorization: 'Bearer SG.fakeKey',
  'User-Agent': 'axios/0.19.2',
  'Content-Length': 360
}

Technical details:

  • sendgrid-nodejs version: 7.0.0
  • node version: 12.13.1
@childish-sambino childish-sambino added difficulty: easy fix is easy in difficulty status: work in progress Twilio or the community is in the process of implementing type: bug bug in the library labels Apr 3, 2020
@childish-sambino
Copy link
Contributor

Nice catch. PR submitted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty: easy fix is easy in difficulty type: bug bug in the library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants