add download method

This commit is contained in:
fuxiao
2021-08-26 18:50:14 +08:00
parent 9f9cd3fec1
commit 4744b3d3c0
10 changed files with 577 additions and 246 deletions

View File

@@ -59,23 +59,26 @@ func TestClient_Post(t *testing.T) {
Sort: 0,
}
//data := map[string]interface{}{
// "id": 1,
// "pid": 0,
// "code": "110000",
// "name": "北京市",
// "sort": 0,
//}
if resp, err := client.Put("/backend/region/update-region", data); err != nil {
t.Error(err)
return
} else {
t.Log(resp.Response.Status)
t.Log(resp.Response.Header)
t.Log(resp.Bytes())
t.Log(resp.String())
t.Log(resp.ReadBytes())
t.Log(resp.ReadString())
t.Log(resp.GetHeaders())
t.Log(resp.GetCookies())
}
}
func TestClient_Download(t *testing.T) {
url := "https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png"
if path, err := http.NewClient().Download(url, "./"); err != nil {
t.Error(err)
return
} else {
t.Log(path)
}
}