aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulio Capote <jcapote@gmail.com>2023-01-05 15:53:19 +0000
committerJulio Capote <jcapote@gmail.com>2023-01-05 15:53:19 +0000
commit7cc3e430e0912b67fdaa7c4f9db52e736c2c8370 (patch)
tree280198fa25fe103552e2a5fab88ed7e45a3506d3
parent5b43c429b91476e7d93d67ddcdd5eb64eea6e892 (diff)
downloadcommunique-7cc3e430e0912b67fdaa7c4f9db52e736c2c8370.tar.gz
set date and content type
-rw-r--r--registry/registry.go12
1 files changed, 11 insertions, 1 deletions
diff --git a/registry/registry.go b/registry/registry.go
index 89dd7a1..ac486d9 100644
--- a/registry/registry.go
+++ b/registry/registry.go
@@ -13,6 +13,7 @@ import (
"net/url"
"strings"
"sync"
+ "time"
"git.capotej.com/capotej/communique/config"
"git.capotej.com/capotej/communique/models"
@@ -250,6 +251,9 @@ func (r *Registry) deliverAcceptToInbox(url, actorUrl *url.URL, follow vocab.Act
privKey := &keypair.PrivateKey
request, err := http.NewRequest("POST", url.String(), bytes.NewBuffer(jsonData))
+ request.Header.Set("Date", time.Now().Format(http.TimeFormat))
+ request.Header.Set("Content-Type", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"")
+
r.log.With(
"type",
"delivery",
@@ -259,10 +263,15 @@ func (r *Registry) deliverAcceptToInbox(url, actorUrl *url.URL, follow vocab.Act
).With(
"digest",
request.Header.Get("digest"),
+ ).With(
+ "date",
+ request.Header.Get("date"),
+ ).With(
+ "host",
+ request.Header.Get("host"),
).Debugf("signing request")
r.mu.Lock()
- defer r.mu.Unlock()
prefs := []httpsig.Algorithm{httpsig.RSA_SHA256}
digestAlgorithm := httpsig.DigestSha256
// The "Date" and "Digest" headers must already be set on r, as well as r.URL.
@@ -276,6 +285,7 @@ func (r *Registry) deliverAcceptToInbox(url, actorUrl *url.URL, follow vocab.Act
// body := nil
// If r were a http.ResponseWriter, call SignResponse instead.
err = signer.SignRequest(privKey, actorUrl.String(), request, nil)
+ r.mu.Unlock()
r.log.With(
"type",