-
Notifications
You must be signed in to change notification settings - Fork 109
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
routing/http/client: avoid race by not using global http.Client #579
Conversation
Codecov ReportAttention:
@@ Coverage Diff @@
## main #579 +/- ##
==========================================
+ Coverage 65.56% 65.60% +0.04%
==========================================
Files 207 207
Lines 25597 25612 +15
==========================================
+ Hits 16782 16804 +22
+ Misses 7336 7331 -5
+ Partials 1479 1477 -2
|
@aschmahmann I updated the options to return an error, and simplified the documentation of the options. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code changes look good, left some documentation suggestions/clarifications
Fixes the race condition observed in the tests in ipfs/rainbow#87.
It could've been fixed in rainbow, but that doesn't fix the source issue: we use the same global default HTTP client, while giving an option that can override its user agent. This option changes the user agent of the global variable, which may be used by multiple clients.
In addition, I updated the tests and documentations to reflect how
WithUserAgent
andWithHTTPClient
work. The tests were passing until now by mistake and only because we were using the globaldefaultHTTPClient
.