From 7c10ab9fde6b2b2360e5968aa0172b1565bca161 Mon Sep 17 00:00:00 2001 From: Anthony Wang Date: Sat, 18 Jun 2022 13:08:00 -0500 Subject: [PATCH] Change Gitea user agent from the default to Gitea/Version --- modules/activitypub/client.go | 1 + routers/api/v1/activitypub/reqsignature.go | 1 + 2 files changed, 2 insertions(+) diff --git a/modules/activitypub/client.go b/modules/activitypub/client.go index 923bc4ea4..738b1e473 100644 --- a/modules/activitypub/client.go +++ b/modules/activitypub/client.go @@ -104,6 +104,7 @@ func (c *Client) NewRequest(b []byte, to string) (req *http.Request, err error) } req.Header.Add("Content-Type", ActivityStreamsContentType) 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 diff --git a/routers/api/v1/activitypub/reqsignature.go b/routers/api/v1/activitypub/reqsignature.go index 08e6b57e2..460368552 100644 --- a/routers/api/v1/activitypub/reqsignature.go +++ b/routers/api/v1/activitypub/reqsignature.go @@ -47,6 +47,7 @@ func getPublicKeyFromResponse(b []byte, keyID *url.URL) (p crypto.PublicKey, err func fetch(iri *url.URL) (b []byte, err error) { req := httplib.NewRequest(iri.String(), http.MethodGet) req.Header("Accept", activitypub.ActivityStreamsContentType) + req.Header("User-Agent", "Gitea/"+setting.AppVer) resp, err := req.Response() if err != nil { return