From 7263b5702af718040a92b335bed2717874237c56 Mon Sep 17 00:00:00 2001 From: prplecake Date: Thu, 24 Nov 2022 12:45:49 -0600 Subject: [PATCH] Add User-Agent header --- config.go | 10 ++++++++++ message.go | 1 + 2 files changed, 11 insertions(+) diff --git a/config.go b/config.go index 36e0f1d..68df4b6 100644 --- a/config.go +++ b/config.go @@ -8,6 +8,10 @@ import ( "gopkg.in/yaml.v2" ) +const ( + HttpUserAgent = "gof" +) + var ( configFile string ) @@ -23,6 +27,7 @@ type feed struct { type config struct { Accounts []account LastUpdated time.Time + HttpConfig httpConfig } type account struct { @@ -32,6 +37,10 @@ type account struct { Feeds []feed } +type httpConfig struct { + UserAgent string +} + func readConfig(fileName string) *config { log.Println("reading config...") configFile = fileName @@ -47,6 +56,7 @@ func readConfig(fileName string) *config { if debug { log.Printf("Config:\n\n%v", config) } + config.HttpConfig.UserAgent = HttpUserAgent return config } diff --git a/message.go b/message.go index 2f93832..b7cf00d 100644 --- a/message.go +++ b/message.go @@ -65,6 +65,7 @@ func (msg *message) post() error { // Set Headers req.Header.Set("Content-Type", "application/x-www-form-urlencoded") req.Header.Set("Authorization", "Bearer "+msg.account.AccessToken) + req.Header.Set("User-Agent", conf.HttpConfig.UserAgent) c := &http.Client{Timeout: time.Second * 10}