mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2026-01-15 19:45:10 +08:00
fix: Fix the problem that some request connections are not released (#8329)
This commit is contained in:
parent
e352de6744
commit
5cdc316293
11 changed files with 15 additions and 2 deletions
|
|
@ -403,6 +403,7 @@ func (a aliClient) uploadPart(uri string, reader io.Reader) error {
|
|||
return err
|
||||
}
|
||||
client := &http.Client{}
|
||||
defer client.CloseIdleConnections()
|
||||
response, err := client.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
@ -428,6 +429,7 @@ func (a aliClient) handleDownload(uri string, target string) error {
|
|||
req.Header.Add("origin", "https://www.aliyundrive.com")
|
||||
req.Header.Add("referer", "https://www.aliyundrive.com/")
|
||||
client := &http.Client{}
|
||||
defer client.CloseIdleConnections()
|
||||
response, err := client.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -226,6 +226,7 @@ func (g *googleDriveClient) handleDownload(urlItem string, target string) error
|
|||
Proxy: http.ProxyURL(proxyURL),
|
||||
},
|
||||
}
|
||||
defer client.CloseIdleConnections()
|
||||
response, err := client.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -213,6 +213,7 @@ func RefreshToken(grantType string, tokenType string, varMap map[string]interfac
|
|||
}
|
||||
data.Set("redirect_uri", loadParamFromVars("redirect_uri", varMap))
|
||||
client := &http.Client{}
|
||||
defer client.CloseIdleConnections()
|
||||
url := "https://login.microsoftonline.com/common/oauth2/v2.0/token"
|
||||
if isCN == "true" {
|
||||
url = "https://login.chinacloudapi.cn/common/oauth2/v2.0/token"
|
||||
|
|
|
|||
|
|
@ -274,6 +274,7 @@ func (f FileOp) DownloadFileWithProcess(url, dst, key string, ignoreCertificate
|
|||
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
|
||||
}
|
||||
}
|
||||
defer client.CloseIdleConnections()
|
||||
request, err := http.NewRequest("GET", url, nil)
|
||||
if err != nil {
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ func PostLocalCore(url string) error {
|
|||
return err
|
||||
}
|
||||
client := &http.Client{}
|
||||
defer client.CloseIdleConnections()
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ func HandleGet(url string) (*http.Response, error) {
|
|||
Timeout: time.Second * 300,
|
||||
}
|
||||
client.Transport = loadRequestTransport()
|
||||
defer client.CloseIdleConnections()
|
||||
|
||||
req, err := http.NewRequestWithContext(context.Background(), "GET", url, nil)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -181,6 +181,7 @@ func getZeroSSLEabCredentials(email string) (*zeroSSLRes, error) {
|
|||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
client := &http.Client{}
|
||||
defer client.CloseIdleConnections()
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
|||
|
|
@ -301,6 +301,7 @@ func (a aliClient) uploadPart(uri string, reader io.Reader) error {
|
|||
return err
|
||||
}
|
||||
client := &http.Client{}
|
||||
defer client.CloseIdleConnections()
|
||||
response, err := client.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -123,6 +123,7 @@ func RefreshToken(grantType string, tokenType string, varMap map[string]interfac
|
|||
}
|
||||
data.Set("redirect_uri", loadParamFromVars("redirect_uri", varMap))
|
||||
client := &http.Client{}
|
||||
defer client.CloseIdleConnections()
|
||||
url := "https://login.microsoftonline.com/common/oauth2/v2.0/token"
|
||||
if isCN == "true" {
|
||||
url = "https://login.chinacloudapi.cn/common/oauth2/v2.0/token"
|
||||
|
|
|
|||
|
|
@ -5,14 +5,15 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/1Panel-dev/1Panel/core/app/dto"
|
||||
"github.com/1Panel-dev/1Panel/core/i18n"
|
||||
"io"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/1Panel-dev/1Panel/core/app/dto"
|
||||
"github.com/1Panel-dev/1Panel/core/i18n"
|
||||
)
|
||||
|
||||
func NewLocalClient(reqUrl, reqMethod string, body io.Reader) (interface{}, error) {
|
||||
|
|
@ -31,6 +32,7 @@ func NewLocalClient(reqUrl, reqMethod string, body io.Reader) (interface{}, erro
|
|||
client := &http.Client{
|
||||
Transport: transport,
|
||||
}
|
||||
defer client.CloseIdleConnections()
|
||||
parsedURL, err := url.Parse("http://unix")
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("handle url Parse failed, err: %v \n", err)
|
||||
|
|
|
|||
|
|
@ -87,6 +87,7 @@ func handleGetWithTransport(url string, transport *http.Transport) (*http.Respon
|
|||
Timeout: time.Second * 300,
|
||||
}
|
||||
client.Transport = transport
|
||||
defer client.CloseIdleConnections()
|
||||
|
||||
req, err := http.NewRequestWithContext(context.Background(), "GET", url, nil)
|
||||
if err != nil {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue