From c2454d117df905cb59f00d1c0665b7b85f89a229 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Sat, 9 May 2020 19:25:25 -0400 Subject: [PATCH] context timeout for postmsg --- activity.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/activity.go b/activity.go index baf30d0..6778510 100644 --- a/activity.go +++ b/activity.go @@ -17,6 +17,7 @@ package main import ( "bytes" + "context" "database/sql" "errors" "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("Content-Type", theonetruename) 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) if err != nil { return err