-
Notifications
You must be signed in to change notification settings - Fork 7
/
http_test.go
44 lines (35 loc) · 941 Bytes
/
http_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package dane
/*
* Note: these test routines may not work unless you adapt this file
* to use validating DNS resolvers and appropriately configured DANE TLS
* servers you have access to.
*/
import (
"fmt"
"io/ioutil"
"net/http"
"testing"
)
func TestGetHttpClient(t *testing.T) {
defer fmt.Println()
var urlstring = "https://www.example.com/"
fmt.Printf("## HTTPCLIENT: %s\n", urlstring)
httpclient := GetHttpClient(true)
request, err := http.NewRequest(http.MethodGet, urlstring, nil)
if err != nil {
t.Fatalf("http.NewRequest: %s\n", err.Error())
}
response, err := httpclient.Do(request)
if err != nil {
t.Fatalf("http.Do: %s\n", err.Error())
}
if response.Body != nil {
defer response.Body.Close()
}
body, err := ioutil.ReadAll(response.Body)
if err != nil {
t.Fatalf("Reading HTTP response body: %s\n", err.Error())
}
_ = body
fmt.Printf("GetHttpClient: Success connecting to %s\n", urlstring)
}