close #535 request set timeout

This commit is contained in:
Xhofe
2022-02-14 14:59:00 +08:00
parent fb05a6ca48
commit e90b979d15
5 changed files with 14 additions and 15 deletions

View File

@ -5,6 +5,7 @@ import (
"github.com/go-resty/resty/v2"
log "github.com/sirupsen/logrus"
"net/http"
"time"
)
type DriverConfig struct {
@ -168,6 +169,7 @@ var NoRedirectClient *resty.Client
var RestyClient = resty.New()
var HttpClient = &http.Client{}
var UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36"
var DefaultTimeout = time.Second * 20
func init() {
NoRedirectClient = resty.New().SetRedirectPolicy(
@ -178,4 +180,5 @@ func init() {
NoRedirectClient.SetHeader("user-agent", UserAgent)
RestyClient.SetHeader("user-agent", UserAgent)
RestyClient.SetRetryCount(3)
RestyClient.SetTimeout(DefaultTimeout)
}