Skip to content

Conversation

@grrru
Copy link

@grrru grrru commented Dec 9, 2025

When no custom HTTPClient is provided, BuildHTTPClient() returns http.DefaultClient.
Later, addRedirectFunctionality sets client.CheckRedirect on this shared instance.

Under concurrent usage, multiple goroutines mutate DefaultClient.CheckRedirect at the same time, causing a data race.

@grrru grrru marked this pull request as ready for review December 9, 2025 08:10
@grrru
Copy link
Author

grrru commented Jan 2, 2026

@levigross
Hello. Can I ask you to review this?

@levigross
Copy link
Owner

This will cause a lot of copies of the http.Client per request. I would suggest changing the addRedirectFunctionality code 😃

@grrru
Copy link
Author

grrru commented Jan 6, 2026

@levigross
Hi.
I updated the PR and modified addRedirectFunctionality as suggested to avoid in-place mutation.

However, in my opinion, The revised patch does not seem to meaningfully reduce http.Client copies, and allocation behavior appears largely unchanged.

Could you please confirm if this is the direction you intended, or advise on a better approach?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants