Add client timeout and close response immediately.

This commit is contained in:
Morgan McMillian 2021-11-23 06:35:30 -08:00
parent 2f15ad4244
commit 3b4dc324eb

View file

@ -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)