manage http timeout to allow long poll
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
ycc
2024-04-20 22:29:22 +02:00
parent 7c17a11426
commit d14cd161da
4 changed files with 14 additions and 7 deletions

View File

@ -5,6 +5,7 @@ import (
"encoding/json"
"io"
"net/http"
"time"
)
func HttpGetId(url string) (response map[string]string, err error) {
@ -25,8 +26,11 @@ func HttpGetId(url string) (response map[string]string, err error) {
return srvId, nil
}
func HttpPostMessage(url string, msg []byte) (response []byte, err error) {
resp, err := http.Post(url+"/msg",
func HttpPostMessage(url string, msg []byte, timeout int) (response []byte, err error) {
client := http.Client{
Timeout: time.Duration(timeout) * time.Second,
}
resp, err := client.Post(url+"/msg",
"application/octet-stream", bytes.NewBuffer(msg))
if err != nil {
return nil, err