mirror of
1
Fork 0

Make sure HTTP request Date in GMT

This commit is contained in:
Anthony Wang 2022-06-13 23:10:36 -05:00
parent d749f8ff4f
commit 08eebffb0e
No known key found for this signature in database
GPG Key ID: BC96B00AEC5F2D76
3 changed files with 9 additions and 7 deletions

View File

@ -11,6 +11,7 @@ import (
"encoding/pem" "encoding/pem"
"fmt" "fmt"
"net/http" "net/http"
"strings"
"time" "time"
user_model "code.gitea.io/gitea/models/user" user_model "code.gitea.io/gitea/models/user"
@ -106,7 +107,7 @@ func (c *Client) NewRequest(b []byte, to string) (req *http.Request, err error)
} }
req.Header.Add("Content-Type", ActivityStreamsContentType) req.Header.Add("Content-Type", ActivityStreamsContentType)
req.Header.Add("Accept-Charset", "utf-8") req.Header.Add("Accept-Charset", "utf-8")
req.Header.Add("Date", fmt.Sprintf("%s UTC", time.Now().UTC().Format(time.RFC1123))) req.Header.Add("Date", strings.ReplaceAll(time.Now().UTC().Format(time.RFC1123), "UTC", "GMT"))
signer, _, err := httpsig.NewSigner(c.algs, c.digestAlg, c.postHeaders, httpsig.Signature, httpsigExpirationTime) signer, _, err := httpsig.NewSigner(c.algs, c.digestAlg, c.postHeaders, httpsig.Signature, httpsigExpirationTime)
if err != nil { if err != nil {

View File

@ -96,7 +96,7 @@ func Person(ctx *context.APIContext) {
ctx.Resp.Header().Add("Content-Type", "application/activity+json") ctx.Resp.Header().Add("Content-Type", "application/activity+json")
ctx.Resp.WriteHeader(http.StatusOK) ctx.Resp.WriteHeader(http.StatusOK)
binary, _ = json.Marshal(jsonmap) binary, _ = json.Marshal(jsonmap)
ctx.Resp.Write(binary) _, _ = ctx.Resp.Write(binary)
} }
// PersonInbox function // PersonInbox function

View File

@ -13,6 +13,7 @@ import (
"io" "io"
"net/http" "net/http"
"net/url" "net/url"
"strings"
"time" "time"
"code.gitea.io/gitea/modules/activitypub" "code.gitea.io/gitea/modules/activitypub"
@ -50,7 +51,7 @@ func fetch(iri *url.URL) (b []byte, err error) {
req := httplib.NewRequest(iri.String(), http.MethodGet) req := httplib.NewRequest(iri.String(), http.MethodGet)
req.Header("Accept", activitypub.ActivityStreamsContentType) req.Header("Accept", activitypub.ActivityStreamsContentType)
req.Header("Accept-Charset", "utf-8") req.Header("Accept-Charset", "utf-8")
req.Header("Date", fmt.Sprintf("%s UTC", time.Now().UTC().Format(time.RFC1123))) req.Header("Date", strings.ReplaceAll(time.Now().UTC().Format(time.RFC1123), "UTC", "GMT"))
resp, err := req.Response() resp, err := req.Response()
if err != nil { if err != nil {
return return