diff --git a/instance.go b/instance.go index 6961817..bf98125 100644 --- a/instance.go +++ b/instance.go @@ -66,8 +66,9 @@ func GetNodeInfo(endpoint string, o RunningInstance) RunningInstance { pleromastodon_nodeinfo_uri := "https://" + endpoint + "/nodeinfo/2.0.json" req, _ := http.NewRequest("GET", pleromastodon_nodeinfo_uri, nil) + req.Header.Set("User-Agent", "Tusky") - pleromastodon_api_resp, err := o.client.Do(req) + pleromastodon_api_resp, err := DoTries(&o, req) if err != nil { return o } else { @@ -88,6 +89,7 @@ func GetNodeInfo(endpoint string, o RunningInstance) RunningInstance { // Check the front page index_uri := "https://" + endpoint + "/" req, _ = http.NewRequest("GET", index_uri, nil) + req.Header.Set("User-Agent", "Tusky") resp_index, err := DoTries(&o, req) o.LastRun = time.Now().Format(time.RFC3339) if err != nil { diff --git a/poll.go b/poll.go index 98fdbfb..6348fce 100644 --- a/poll.go +++ b/poll.go @@ -87,6 +87,7 @@ func PollMastodonPleroma(endpoint string, o *RunningInstance) { api_timeline := "https://" + endpoint + "/api/v1/timelines/public?limit=40&since_id=" + min_id req, err := http.NewRequest("GET", api_timeline, nil) + req.Header.Set("User-Agent", "Tusky") if err != nil { logFatal.Fatal("Unable to create new request for " + endpoint + ": ", err) return diff --git a/retrieve.go b/retrieve.go index 07edce3..e656f35 100644 --- a/retrieve.go +++ b/retrieve.go @@ -109,9 +109,10 @@ func check_post(uri string) (PostJson, error) { o := GetHTTPSession(postjson.instance) req, _ := http.NewRequest("GET", uri, nil) + req.Header.Set("User-Agent", "Tusky") req.Header.Add("Accept", "application/ld+json") - resp, err := o.client.Do(req) + resp, err := DoTries(&o, req) if err != nil { return postjson, errors.New("Connection error to " + uri) } @@ -189,6 +190,7 @@ func check_user(uri string) (UserJson, error) { o := GetHTTPSession(userjson.instance) req, _ := http.NewRequest("GET", uri, nil) + req.Header.Set("User-Agent", "Tusky") req.Header.Add("Accept", "application/ld+json") var resp *http.Response diff --git a/stream.go b/stream.go index 1066ea9..241842f 100644 --- a/stream.go +++ b/stream.go @@ -29,6 +29,7 @@ func StreamMastodon(endpoint string, o *RunningInstance) { api_timeline := "https://" + endpoint + "/api/v1/streaming/public" req, err := http.NewRequest("GET", api_timeline, nil) + req.Header.Set("User-Agent", "Tusky") if err != nil { logFatal.Fatal("Unable to create new request for " + endpoint + ", exiting.") return