mirror of
https://codeberg.org/VnPower/PixivFE
synced 2024-12-06 19:16:23 +01:00
use http client from utils
This commit is contained in:
+4
-2
@@ -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
@@ -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
|
||||
|
||||
@@ -7,6 +7,7 @@ import "net/http"
|
||||
var HttpClient = &http.Client{
|
||||
Transport: &http.Transport{
|
||||
Proxy: http.ProxyFromEnvironment,
|
||||
MaxIdleConns: 0,
|
||||
MaxIdleConnsPerHost: 20,
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user