mirror of
https://github.com/go-gitea/gitea
synced 2025-01-28 02:24:27 +00:00
Use the httplib module instead of http for GET requests
This commit is contained in:
parent
3ed4a71a4c
commit
21c56f8e94
@ -17,6 +17,7 @@ import (
|
|||||||
|
|
||||||
"code.gitea.io/gitea/modules/activitypub"
|
"code.gitea.io/gitea/modules/activitypub"
|
||||||
gitea_context "code.gitea.io/gitea/modules/context"
|
gitea_context "code.gitea.io/gitea/modules/context"
|
||||||
|
"code.gitea.io/gitea/modules/httplib"
|
||||||
"code.gitea.io/gitea/modules/json"
|
"code.gitea.io/gitea/modules/json"
|
||||||
"code.gitea.io/gitea/modules/setting"
|
"code.gitea.io/gitea/modules/setting"
|
||||||
|
|
||||||
@ -89,21 +90,17 @@ func getPublicKeyFromResponse(ctx context.Context, b []byte, keyID *url.URL) (p
|
|||||||
}
|
}
|
||||||
|
|
||||||
func fetch(iri *url.URL) (b []byte, err error) {
|
func fetch(iri *url.URL) (b []byte, err error) {
|
||||||
var req *http.Request
|
var req *httplib.Request
|
||||||
req, err = http.NewRequest(http.MethodGet, iri.String(), nil)
|
req = httplib.NewRequest(iri.String(), http.MethodGet)
|
||||||
if err != nil {
|
req.Header("Accept", activitypub.ActivityStreamsContentType)
|
||||||
return
|
req.Header("Accept-Charset", "utf-8")
|
||||||
}
|
|
||||||
req.Header.Add("Accept", activitypub.ActivityStreamsContentType)
|
|
||||||
req.Header.Add("Accept-Charset", "utf-8")
|
|
||||||
clock, err := activitypub.NewClock()
|
clock, err := activitypub.NewClock()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
req.Header.Add("Date", fmt.Sprintf("%s GMT", clock.Now().UTC().Format(time.RFC1123)))
|
req.Header("Date", fmt.Sprintf("%s GMT", clock.Now().UTC().Format(time.RFC1123)))
|
||||||
var resp *http.Response
|
var resp *http.Response
|
||||||
client := &http.Client{}
|
resp, err = req.Response()
|
||||||
resp, err = client.Do(req)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user