mirror of
https://github.com/Mrs4s/go-cqhttp.git
synced 2025-05-05 03:23:49 +08:00
feat: http timeout setting
This commit is contained in:
parent
55cb80dccc
commit
0b90074a48
@ -364,6 +364,7 @@ func LoginInteract() {
|
|||||||
})
|
})
|
||||||
saveToken()
|
saveToken()
|
||||||
cli.AllowSlider = true
|
cli.AllowSlider = true
|
||||||
|
download.SetGlobalTimeout(time.Duration(base.HTTPTimeout) * time.Second) // 在登录完成后设置, 防止在堵塞协议更新
|
||||||
log.Infof("登录成功 欢迎使用: %v", cli.Nickname)
|
log.Infof("登录成功 欢迎使用: %v", cli.Nickname)
|
||||||
log.Info("开始加载好友列表...")
|
log.Info("开始加载好友列表...")
|
||||||
global.Check(cli.ReloadFriendList(), true)
|
global.Check(cli.ReloadFriendList(), true)
|
||||||
@ -375,7 +376,6 @@ func LoginInteract() {
|
|||||||
base.Account.Status = 0
|
base.Account.Status = 0
|
||||||
}
|
}
|
||||||
cli.SetOnlineStatus(allowStatus[base.Account.Status])
|
cli.SetOnlineStatus(allowStatus[base.Account.Status])
|
||||||
|
|
||||||
servers.Run(coolq.NewQQBot(cli))
|
servers.Run(coolq.NewQQBot(cli))
|
||||||
log.Info("资源初始化完成, 开始处理信息.")
|
log.Info("资源初始化完成, 开始处理信息.")
|
||||||
log.Info("アトリは、高性能ですから!")
|
log.Info("アトリは、高性能ですから!")
|
||||||
|
@ -39,6 +39,7 @@ var (
|
|||||||
AllowTempSession bool // 是否允许发送临时会话信息
|
AllowTempSession bool // 是否允许发送临时会话信息
|
||||||
UpdateProtocol bool // 是否更新协议
|
UpdateProtocol bool // 是否更新协议
|
||||||
SignServerOverwrite string // 使用特定的服务器进行签名
|
SignServerOverwrite string // 使用特定的服务器进行签名
|
||||||
|
HTTPTimeout int
|
||||||
|
|
||||||
PostFormat string // 上报格式 string or array
|
PostFormat string // 上报格式 string or array
|
||||||
Proxy string // 存储 proxy_rewrite,用于设置代理
|
Proxy string // 存储 proxy_rewrite,用于设置代理
|
||||||
@ -88,6 +89,7 @@ func Init() {
|
|||||||
ReportSelfMessage = conf.Message.ReportSelfMessage
|
ReportSelfMessage = conf.Message.ReportSelfMessage
|
||||||
UseSSOAddress = conf.Account.UseSSOAddress
|
UseSSOAddress = conf.Account.UseSSOAddress
|
||||||
AllowTempSession = conf.Account.AllowTempSession
|
AllowTempSession = conf.Account.AllowTempSession
|
||||||
|
HTTPTimeout = conf.Message.HTTPTimeout
|
||||||
}
|
}
|
||||||
{ // others
|
{ // others
|
||||||
Proxy = conf.Message.ProxyRewrite
|
Proxy = conf.Message.ProxyRewrite
|
||||||
|
@ -33,7 +33,7 @@ var client = &http.Client{
|
|||||||
MaxIdleConns: 0,
|
MaxIdleConns: 0,
|
||||||
MaxIdleConnsPerHost: 999,
|
MaxIdleConnsPerHost: 999,
|
||||||
},
|
},
|
||||||
Timeout: time.Second * 15,
|
Timeout: time.Second * 5,
|
||||||
}
|
}
|
||||||
|
|
||||||
// ErrOverSize 响应主体过大时返回此错误
|
// ErrOverSize 响应主体过大时返回此错误
|
||||||
@ -42,6 +42,13 @@ var ErrOverSize = errors.New("oversize")
|
|||||||
// UserAgent HTTP请求时使用的UA
|
// UserAgent HTTP请求时使用的UA
|
||||||
const UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Edg/87.0.664.66"
|
const UserAgent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36 Edg/87.0.664.66"
|
||||||
|
|
||||||
|
func SetGlobalTimeout(t time.Duration) {
|
||||||
|
if t == 0 {
|
||||||
|
t = time.Second * 10
|
||||||
|
}
|
||||||
|
client.Timeout = t
|
||||||
|
}
|
||||||
|
|
||||||
// Request is a file download request
|
// Request is a file download request
|
||||||
type Request struct {
|
type Request struct {
|
||||||
Method string
|
Method string
|
||||||
|
@ -56,6 +56,7 @@ type Config struct {
|
|||||||
ExtraReplyData bool `yaml:"extra-reply-data"`
|
ExtraReplyData bool `yaml:"extra-reply-data"`
|
||||||
SkipMimeScan bool `yaml:"skip-mime-scan"`
|
SkipMimeScan bool `yaml:"skip-mime-scan"`
|
||||||
ConvertWebpImage bool `yaml:"convert-webp-image"`
|
ConvertWebpImage bool `yaml:"convert-webp-image"`
|
||||||
|
HTTPTimeout int `yaml:"http-timeout"`
|
||||||
} `yaml:"message"`
|
} `yaml:"message"`
|
||||||
|
|
||||||
Output struct {
|
Output struct {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user