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.
|
* 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 {
|
func handleFetchCollectionActivities(app *App, w http.ResponseWriter, r *http.Request) error {
|
||||||
w.Header().Set("Server", serverSoftware)
|
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 {
|
if err != nil {
|
||||||
return err
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue