fix: avoid mutating global http.DefaultClient in webhook proxy (#2145)

Fixes a bug where the webhook HTTP client was mutating `http.DefaultClient` (the global singleton), causing ALL HTTP requests in the application to use the webhook proxy. This broke OIDC authentication and other external HTTP calls when webhook proxy was configured.

Fixes #2144
This commit is contained in:
kolaente
2026-01-24 13:58:47 +01:00
committed by GitHub
parent acbb06e337
commit 731b7c3001
6 changed files with 7 additions and 7 deletions

View File

@@ -245,7 +245,7 @@ func getWebhookHTTPClient() (client *http.Client) {
return webhookClient
}
client = http.DefaultClient
client = &http.Client{}
client.Timeout = time.Duration(config.WebhooksTimeoutSeconds.GetInt()) * time.Second
if config.WebhooksProxyURL.GetString() == "" || config.WebhooksProxyPassword.GetString() == "" {

View File

@@ -90,7 +90,7 @@ func (g *Provider) GetAvatar(user *user.User, size int64) ([]byte, string, error
if err != nil {
return nil, err
}
resp, err := http.DefaultClient.Do(req)
resp, err := (&http.Client{}).Do(req)
if err != nil {
return nil, err
}

View File

@@ -30,7 +30,7 @@ func unsplashImage(url string, c echo.Context) error {
if err != nil {
return err
}
resp, err := http.DefaultClient.Do(req)
resp, err := (&http.Client{}).Do(req)
if err != nil {
return err
}

View File

@@ -257,7 +257,7 @@ func (p *Provider) Set(s *xorm.Session, image *background.Image, project *models
if err != nil {
return
}
resp, err := http.DefaultClient.Do(req)
resp, err := (&http.Client{}).Do(req)
if err != nil {
return err
}
@@ -340,7 +340,7 @@ func pingbackByPhotoID(photoID string) {
if err != nil {
log.Errorf("Unsplash Pingback Failed: %s", err.Error())
}
_, err = http.DefaultClient.Do(req)
_, err = (&http.Client{}).Do(req)
if err != nil {
log.Errorf("Unsplash Pingback Failed: %s", err.Error())
}

View File

@@ -187,7 +187,7 @@ func makeAuthenticatedGetRequest(token, urlPart string, v interface{}) error {
}
req.Header.Set("Authorization", "Bearer "+token)
resp, err := http.DefaultClient.Do(req)
resp, err := (&http.Client{}).Do(req)
if err != nil {
return err
}

View File

@@ -101,7 +101,7 @@ func DownloadImage(url string) ([]byte, error) {
return nil, fmt.Errorf("failed to create HTTP request: %w", err)
}
resp, err := http.DefaultClient.Do(req)
resp, err := (&http.Client{}).Do(req)
if err != nil {
return nil, fmt.Errorf("failed to download image: %w", err)
}