mirror of
https://github.com/writeas/writefreely
synced 2025-02-01 19:06:49 +01:00
Add timeout on ActivityPub requests
This commit is contained in:
parent
b9914dd65a
commit
bc9843dfa3
@ -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…
x
Reference in New Issue
Block a user