Add timeout on ActivityPub requests

pull/249/head
Matt Baer 5 years ago
parent b9914dd65a
commit bc9843dfa3
  1. 12
      activitypub.go

@ -1,5 +1,5 @@
/*
* Copyright © 2018-2019 A Bunch Tell LLC.
* Copyright © 2018-2020 A Bunch Tell LLC.
*
* This file is part of WriteFreely.
*
@ -62,6 +62,12 @@ func (ru *RemoteUser) AsPerson() *activitystreams.Person {
}
}
func activityPubClient() http.Client {
return http.Client{
Timeout: 15 * time.Second,
}
}
func handleFetchCollectionActivities(app *App, w http.ResponseWriter, r *http.Request) error {
w.Header().Set("Server", serverSoftware)
@ -502,7 +508,7 @@ func makeActivityPost(hostName string, p *activitystreams.Person, url string, m
}
}
resp, err := http.DefaultClient.Do(r)
resp, err := activityPubClient().Do(r)
if err != nil {
return err
}
@ -538,7 +544,7 @@ func resolveIRI(hostName, url string) ([]byte, error) {
}
}
resp, err := http.DefaultClient.Do(r)
resp, err := activityPubClient().Do(r)
if err != nil {
return nil, err
}

Loading…
Cancel
Save