context timeout for postmsg
This commit is contained in:
parent
b7f732ce82
commit
c2454d117d
|
@ -17,6 +17,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
|
"context"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
@ -69,6 +70,9 @@ func PostMsg(keyname string, key httpsig.PrivateKey, url string, msg []byte) err
|
||||||
req.Header.Set("User-Agent", "honksnonk/5.0; "+serverName)
|
req.Header.Set("User-Agent", "honksnonk/5.0; "+serverName)
|
||||||
req.Header.Set("Content-Type", theonetruename)
|
req.Header.Set("Content-Type", theonetruename)
|
||||||
httpsig.SignRequest(keyname, key, req, msg)
|
httpsig.SignRequest(keyname, key, req, msg)
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), 1 * time.Minute)
|
||||||
|
defer cancel()
|
||||||
|
req = req.WithContext(ctx)
|
||||||
resp, err := client.Do(req)
|
resp, err := client.Do(req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in New Issue