Properly handle failed AP requests

This commit is contained in:
Matt Baer 2018-11-14 18:30:24 -05:00
parent 0eac9251c0
commit 58d163d2e0

View file

@ -460,14 +460,13 @@ func makeActivityPost(p *activitystreams.Person, url string, m interface{}) erro
} }
resp, err := http.DefaultClient.Do(r) resp, err := http.DefaultClient.Do(r)
if err != nil {
return err
}
if resp != nil && resp.Body != nil { if resp != nil && resp.Body != nil {
defer resp.Body.Close() defer resp.Body.Close()
} }
if resp == nil {
log.Error("No response.")
return fmt.Errorf("No resonse.")
}
body, err := ioutil.ReadAll(resp.Body) body, err := ioutil.ReadAll(resp.Body)
if err != nil { if err != nil {
return err return err
@ -497,6 +496,9 @@ func resolveIRI(url string) ([]byte, error) {
} }
resp, err := http.DefaultClient.Do(r) resp, err := http.DefaultClient.Do(r)
if err != nil {
return nil, err
}
if resp != nil && resp.Body != nil { if resp != nil && resp.Body != nil {
defer resp.Body.Close() defer resp.Body.Close()
} }