Make sure HTTP request Date in GMT
This commit is contained in:
parent
d749f8ff4f
commit
08eebffb0e
|
@ -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 {
|
||||||
|
|
|
@ -56,13 +56,13 @@ func Person(ctx *context.APIContext) {
|
||||||
ctx.Error(http.StatusInternalServerError, "Set PreferredUsername", err)
|
ctx.Error(http.StatusInternalServerError, "Set PreferredUsername", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
person.URL = ap.IRI(setting.AppURL + username)
|
person.URL = ap.IRI(setting.AppURL + username)
|
||||||
|
|
||||||
person.Icon = ap.Image{
|
person.Icon = ap.Image{
|
||||||
Type: ap.ImageType,
|
Type: ap.ImageType,
|
||||||
MediaType: "image/png",
|
MediaType: "image/png",
|
||||||
URL: ap.IRI(user.AvatarLink()),
|
URL: ap.IRI(user.AvatarLink()),
|
||||||
}
|
}
|
||||||
|
|
||||||
person.Inbox = nil
|
person.Inbox = nil
|
||||||
|
@ -91,12 +91,12 @@ func Person(ctx *context.APIContext) {
|
||||||
ctx.Error(http.StatusInternalServerError, "Unmarshall", err)
|
ctx.Error(http.StatusInternalServerError, "Unmarshall", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
jsonmap["@context"] = []string{"https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"}
|
jsonmap["@context"] = []string{"https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"}
|
||||||
|
|
||||||
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
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in New Issue