✏️ drop all pb & 增加 gist 审批

This commit is contained in:
fumiama
2021-12-16 15:27:47 +08:00
parent a363623df9
commit e2c603338e
11 changed files with 209 additions and 196 deletions

View File

@@ -1,6 +1,7 @@
package web
import (
"errors"
"io"
"net/http"
)
@@ -23,3 +24,18 @@ func ReqWith(url string, method string, referer string, ua string) (data []byte,
}
return
}
func GetData(url string) (data []byte, err error) {
var response *http.Response
response, err = http.Get(url)
if err == nil {
if response.ContentLength <= 0 {
err = errors.New("web.GetData: empty body")
response.Body.Close()
return
}
data, err = io.ReadAll(response.Body)
response.Body.Close()
}
return
}