use http client from utils

This commit is contained in:
iacore
2024-10-05 15:32:10 +00:00
parent bbec5f6496
commit d99c974745
3 changed files with 13 additions and 3 deletions
+4 -2
View File
@@ -13,6 +13,8 @@ import (
"io"
"net/http"
"strings"
"codeberg.org/vnpower/pixivfe/v2/server/utils"
)
const USER_AGENT = "PixivAndroidApp/5.0.234 (Android 11; Pixel 5)"
@@ -82,7 +84,7 @@ func AppAPIRefresh(r *http.Request, refresh_token string) AppAPICredentials {
req.Header.Set("User-Agent", USER_AGENT)
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
resp, err := http.DefaultClient.Do(req)
resp, err := utils.HttpClient.Do(req)
if err != nil {
panic(err)
}
@@ -117,7 +119,7 @@ func AppAPILogin(r *http.Request) AppAPICredentials {
req.Header.Set("User-Agent", USER_AGENT)
req.Header.Add("Content-Type", "application/x-www-form-urlencoded")
resp, err := http.DefaultClient.Do(req)
resp, err := utils.HttpClient.Do(req)
if err != nil {
panic(err)
}
+8 -1
View File
@@ -180,7 +180,6 @@ rules:
fmt.Errorf("$MSG", $...ARGS)
fix: |
i18n.Errorf("$MSG", $...ARGS)
- id: "14"
message: "non-global regexp.MustCompile"
languages: [go]
@@ -194,3 +193,11 @@ rules:
$VAR := regexp.MustCompile($PATT)
fix: |
var $VAR = regexp.MustCompile($PATT)
- id: "15"
message: "http.DefaultClient"
languages: [go]
severity: ERROR
pattern: |
http.DefaultClient
fix: |
utils.HttpClient
+1
View File
@@ -7,6 +7,7 @@ import "net/http"
var HttpClient = &http.Client{
Transport: &http.Transport{
Proxy: http.ProxyFromEnvironment,
MaxIdleConns: 0,
MaxIdleConnsPerHost: 20,
},
}