Skip to content

fix: allow specifying the user-agent header for outgoing requests#1287

Merged
panva merged 2 commits intopanva:mainfrom
pvieira-diligent:fix-http-options-user-agent-override
Jan 19, 2025
Merged

fix: allow specifying the user-agent header for outgoing requests#1287
panva merged 2 commits intopanva:mainfrom
pvieira-diligent:fix-http-options-user-agent-override

Conversation

@pvieira-diligent
Copy link
Contributor

Specifying the user-agent header for outgoing requests was introduced in 95f24ef.

This PR is fixing an issue with that commit: the user-agent header value set in the httpOptions config is not really being used, and the http agent defaults to not sending the user-agent HTTP header.

  const helperOptions = pickBy({ signal, agent, dnsLookup }, Boolean);
  // ...
  options.headers['user-agent'] = helperOptions['user-agent']; // at this point, helperOptions['user-agent'] is always undefined

In practice, due to the missing user-agent, WAFs could block requests to the jwks_uri endpoint during a client authentication.

@panva
Copy link
Owner

panva commented Jan 17, 2025

Clearly i should've added a test then, apologies. Can you add a test now?

@pvieira-diligent
Copy link
Contributor Author

Clearly i should've added a test then, apologies. Can you add a test now?

I've added a couple of tests already.

Are you expecting different ones? I'm happy to add more if I'm missing any scenarios.

@panva panva merged commit c77513c into panva:main Jan 19, 2025
46 checks passed
@panva
Copy link
Owner

panva commented Jan 19, 2025

Thank you @pvieira-diligent

@pvieira-diligent pvieira-diligent deleted the fix-http-options-user-agent-override branch January 20, 2025 15:52
@github-actions github-actions bot locked and limited conversation to collaborators Apr 21, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants