Skip to content

Commit

Permalink
Add User-Agent header
Browse files Browse the repository at this point in the history
  • Loading branch information
prplecake committed Nov 24, 2022
1 parent f20f433 commit 7263b57
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import (
"gopkg.in/yaml.v2"
)

const (
HttpUserAgent = "gof"
)

var (
configFile string
)
Expand All @@ -23,6 +27,7 @@ type feed struct {
type config struct {
Accounts []account
LastUpdated time.Time
HttpConfig httpConfig
}

type account struct {
Expand All @@ -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
Expand All @@ -47,6 +56,7 @@ func readConfig(fileName string) *config {
if debug {
log.Printf("Config:\n\n%v", config)
}
config.HttpConfig.UserAgent = HttpUserAgent
return config
}

Expand Down
1 change: 1 addition & 0 deletions message.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down

0 comments on commit 7263b57

Please sign in to comment.