aboutsummaryrefslogtreecommitdiff
path: root/modules/activitypub/client.go
diff options
context:
space:
mode:
Diffstat (limited to 'modules/activitypub/client.go')
-rw-r--r--modules/activitypub/client.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/modules/activitypub/client.go b/modules/activitypub/client.go
index b04706dd0..738b1e473 100644
--- a/modules/activitypub/client.go
+++ b/modules/activitypub/client.go
@@ -27,6 +27,12 @@ const (
httpsigExpirationTime = 60
)
+// Gets the current time as an RFC 2616 formatted string
+// RFC 2616 requires RFC 1123 dates but with GMT instead of UTC
+func CurrentTime() string {
+ return strings.ReplaceAll(time.Now().UTC().Format(time.RFC1123), "UTC", "GMT")
+}
+
func containsRequiredHTTPHeaders(method string, headers []string) error {
var hasRequestTarget, hasDate, hasDigest bool
for _, header := range headers {
@@ -97,9 +103,8 @@ func (c *Client) NewRequest(b []byte, to string) (req *http.Request, err error)
return
}
req.Header.Add("Content-Type", ActivityStreamsContentType)
- req.Header.Add("Accept-Charset", "utf-8")
- req.Header.Add("Date", strings.ReplaceAll(time.Now().UTC().Format(time.RFC1123), "UTC", "GMT"))
-
+ req.Header.Add("Date", CurrentTime())
+ req.Header.Add("User-Agent", "Gitea/"+setting.AppVer)
signer, _, err := httpsig.NewSigner(c.algs, c.digestAlg, c.postHeaders, httpsig.Signature, httpsigExpirationTime)
if err != nil {
return