✏️ 修复 fortune 无法下载

This commit is contained in:
fumiama
2021-11-09 13:09:11 +08:00
parent e2032cdc74
commit eace561f73
2 changed files with 19 additions and 5 deletions

View File

@@ -2,14 +2,28 @@
package file
import (
"crypto/tls"
"io"
"net/http"
"os"
)
var (
tr = &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: true},
}
nochkcrtcli = &http.Client{Transport: tr}
)
// DownloadTo 下载到路径
func DownloadTo(url, file string) error {
resp, err := http.Get(url)
func DownloadTo(url, file string, chkcrt bool) error {
var resp *http.Response
var err error
if chkcrt {
resp, err = http.Get(url)
} else {
resp, err = nochkcrtcli.Get(url)
}
if err == nil {
var f *os.File
f, err = os.Create(file)