Add client timeout and close response immediately.
This commit is contained in:
parent
2f15ad4244
commit
3b4dc324eb
1 changed files with 4 additions and 2 deletions
|
@ -327,13 +327,15 @@ func main() {
|
|||
}
|
||||
req.Header.Set("User-Agent", "pnut-bridge")
|
||||
req.Header.Add("Authorization", "Bearer "+conf.MbToken)
|
||||
client := &http.Client{}
|
||||
client := &http.Client{
|
||||
Timeout: 10 * time.Second,
|
||||
}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
log.Println(">> error on reponse", err)
|
||||
}
|
||||
defer resp.Body.Close()
|
||||
body, _ := ioutil.ReadAll(resp.Body)
|
||||
resp.Body.Close()
|
||||
//log.Println("<< ", string([]byte(body)))
|
||||
var m []MbMessage
|
||||
jerr := json.Unmarshal(body, &m)
|
||||
|
|
Loading…
Reference in a new issue