aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Wang2022-03-28 12:37:52 -0500
committerAnthony Wang2022-03-28 12:37:52 -0500
commitd1a53f7d6ad7651ed05732aed1c76a7ebad85d6c (patch)
tree3a15d3769862d5d9c8e7baef9ae470677318cd57
parent373a84a8e29ebb893839de6e3f1a6c7c6cd9da85 (diff)
Use time.RFC1123 and make the http.Client proxy-aware
-rw-r--r--modules/activitypub/client.go10
1 files changed, 8 insertions, 2 deletions
diff --git a/modules/activitypub/client.go b/modules/activitypub/client.go
index fc87c32f4..254cec0f8 100644
--- a/modules/activitypub/client.go
+++ b/modules/activitypub/client.go
@@ -11,8 +11,10 @@ import (
"encoding/pem"
"fmt"
"net/http"
+ "time"
user_model "code.gitea.io/gitea/models/user"
+ "code.gitea.io/gitea/modules/proxy"
"code.gitea.io/gitea/modules/setting"
"github.com/go-fed/activity/pub"
@@ -84,7 +86,11 @@ func NewClient(user *user_model.User, pubID string) (c *Client, err error) {
c = &Client{
clock: clock,
- client: &http.Client{},
+ client: &http.Client{
+ Transport: &http.Transport{
+ Proxy: proxy.Proxy(),
+ },
+ },
algs: algos,
digestAlg: httpsig.DigestAlgorithm(setting.Federation.DigestAlgorithm),
getHeaders: setting.Federation.GetHeaders,
@@ -106,7 +112,7 @@ func (c *Client) NewRequest(b []byte, to string) (req *http.Request, err error)
}
req.Header.Add("Content-Type", ActivityStreamsContentType)
req.Header.Add("Accept-Charset", "utf-8")
- req.Header.Add("Date", fmt.Sprintf("%s GMT", c.clock.Now().UTC().Format("Mon, 02 Jan 2006 15:04:05")))
+ req.Header.Add("Date", fmt.Sprintf("%s GMT", c.clock.Now().UTC().Format(time.RFC1123)))
signer, _, err := httpsig.NewSigner(c.algs, c.digestAlg, c.postHeaders, httpsig.Signature, 60)
if err != nil {