示例#1
0
func get(t *testing.T, server *httptest.Server, client *http.Client, url string) {
	resp, err := client.Get(server.URL + url)
	if err != nil {
		t.Fatal("cannot get proxy", err)
	}
	ioutil.ReadAll(resp.Body)
	resp.Body.Close()
}
示例#2
0
func get(url string, client *http.Client) ([]byte, error) {
	resp, err := client.Get(url)
	if err != nil {
		return nil, err
	}
	txt, err := ioutil.ReadAll(resp.Body)
	defer resp.Body.Close()
	if err != nil {
		return nil, err
	}
	return txt, nil
}