aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Wang2022-03-27 12:25:27 -0500
committerAnthony Wang2022-03-27 12:25:27 -0500
commit21c56f8e94660beb8af05ac472d399ce70023ab0 (patch)
tree9a2dee2b5139ee005ed219f590afe810a9ea1319
parent3ed4a71a4c78ab559c3c7b8374ba302367fb0825 (diff)
Use the httplib module instead of http for GET requests
-rw-r--r--routers/api/v1/activitypub/reqsignature.go17
1 files changed, 7 insertions, 10 deletions
diff --git a/routers/api/v1/activitypub/reqsignature.go b/routers/api/v1/activitypub/reqsignature.go
index d04225a76..fc51410fd 100644
--- a/routers/api/v1/activitypub/reqsignature.go
+++ b/routers/api/v1/activitypub/reqsignature.go
@@ -17,6 +17,7 @@ import (
"code.gitea.io/gitea/modules/activitypub"
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/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) {
- var req *http.Request
- req, err = http.NewRequest(http.MethodGet, iri.String(), nil)
- if err != nil {
- return
- }
- req.Header.Add("Accept", activitypub.ActivityStreamsContentType)
- req.Header.Add("Accept-Charset", "utf-8")
+ var req *httplib.Request
+ req = httplib.NewRequest(iri.String(), http.MethodGet)
+ req.Header("Accept", activitypub.ActivityStreamsContentType)
+ req.Header("Accept-Charset", "utf-8")
clock, err := activitypub.NewClock()
if err != nil {
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
- client := &http.Client{}
- resp, err = client.Do(req)
+ resp, err = req.Response()
if err != nil {
return
}