Commit ce0a5b02 authored by Mrs4s's avatar Mrs4s

fix timeout.

parent f96abc5e
...@@ -8,15 +8,20 @@ import ( ...@@ -8,15 +8,20 @@ import (
"io/ioutil" "io/ioutil"
"net/http" "net/http"
"strings" "strings"
"time"
) )
var client = &http.Client{
Timeout: time.Second * 15,
}
func GetBytes(url string) ([]byte, error) { func GetBytes(url string) ([]byte, error) {
req, err := http.NewRequest("GET", url, nil) req, err := http.NewRequest("GET", url, nil)
if err != nil { if err != nil {
return nil, err return nil, err
} }
req.Header["User-Agent"] = []string{"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36 Edg/83.0.478.61"} req.Header["User-Agent"] = []string{"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36 Edg/83.0.478.61"}
resp, err := http.DefaultClient.Do(req) resp, err := client.Do(req)
if err != nil { if err != nil {
return nil, err return nil, err
} }
......
...@@ -137,6 +137,7 @@ func (c *httpClient) onBotPushEvent(m coolq.MSG) { ...@@ -137,6 +137,7 @@ func (c *httpClient) onBotPushEvent(m coolq.MSG) {
log.Warnf("上报Event数据 %v 到 %v 失败: %v", m.ToJson(), c.addr, err) log.Warnf("上报Event数据 %v 到 %v 失败: %v", m.ToJson(), c.addr, err)
return return
} }
log.Debugf("上报Event数据 %v 到 %v", m.ToJson(), c.addr)
if gjson.Valid(res) { if gjson.Valid(res) {
c.bot.CQHandleQuickOperation(gjson.Parse(m.ToJson()), gjson.Parse(res)) c.bot.CQHandleQuickOperation(gjson.Parse(m.ToJson()), gjson.Parse(res))
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment