- add function that request http GET
authorjw_wonny.cha <jw_wonny.cha@samsung.com>
Tue, 2 Apr 2019 06:05:46 +0000 (15:05 +0900)
committerjw_wonny.cha <jw_wonny.cha@samsung.com>
Tue, 2 Apr 2019 06:05:46 +0000 (15:05 +0900)
src/scoringmgr/http_sender.go [new file with mode: 0644]

diff --git a/src/scoringmgr/http_sender.go b/src/scoringmgr/http_sender.go
new file mode 100644 (file)
index 0000000..b58032f
--- /dev/null
@@ -0,0 +1,36 @@
+package scoringmgr
+
+import (
+       "io/ioutil"
+       "net"
+       "net/http"
+       "time"
+)
+
+func doGet(targetURL string) (respBytes []byte, err error) {
+       req, err := http.NewRequest("GET", targetURL, nil)
+       if err != nil {
+               return
+       }
+
+       var netTransport = &http.Transport{
+               Dial: (&net.Dialer{
+                       Timeout: 5 * time.Second,
+               }).Dial,
+               TLSHandshakeTimeout: 5 * time.Second,
+       }
+
+       client := &http.Client{
+               Timeout:   time.Second * 10,
+               Transport: netTransport,
+       }
+
+       resp, err := client.Do(req)
+       if err != nil {
+               return
+       }
+       defer resp.Body.Close()
+
+       respBytes, err = ioutil.ReadAll(resp.Body)
+       return
+}