frontend: specify timeout for requests (#29)
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
type channelData struct {
|
||||
@@ -46,7 +47,8 @@ func batchRequest(servers []string, endpoint string, command string) []string {
|
||||
}
|
||||
url := "http://" + hostname + ":" + strconv.Itoa(setting.proxyPort) + "/" + url.PathEscape(endpoint) + "?q=" + url.QueryEscape(command)
|
||||
go func(url string, i int) {
|
||||
response, err := http.Get(url)
|
||||
client := http.Client{Timeout: 5 * time.Second}
|
||||
response, err := client.Get(url)
|
||||
if err != nil {
|
||||
ch <- channelData{i, "request failed: " + err.Error() + "\n"}
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user