Skip to content

outgoing requests have 2 user agent headers #1083

@lucianolxp

Description

@lucianolxp

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions