mirror of
https://github.com/go-gitea/gitea
synced 2024-09-09 05:16:07 +00:00
Use time.RFC1123 and make the http.Client proxy-aware
This commit is contained in:
parent
373a84a8e2
commit
d1a53f7d6a
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user