Skip to content

Commit

Permalink
Use custom user agent, log URN
Browse files Browse the repository at this point in the history
  • Loading branch information
nicpottier committed Aug 17, 2017
1 parent 731fe47 commit 163532d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion sender.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func (w *Sender) Send() {
return
}

msgLog := log.WithField("msgID", msg.ID().String()).WithField("text", msg.Text())
msgLog := log.WithField("msgID", msg.ID().String()).WithField("text", msg.Text()).WithField("urn", msg.URN().String())
start := time.Now()

// was this msg already sent? (from a double queue?)
Expand Down
3 changes: 3 additions & 0 deletions server.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ func NewServerWithLogger(config *config.Courier, backend Backend, logger *logrus
// if it encounters any unrecoverable (or ignorable) error, though its bias is to move forward despite
// connection errors
func (s *server) Start() error {
// set our user agent, needs to happen before we do anything so we don't change have threading issues
utils.HTTPUserAgent = fmt.Sprintf("Courier/%s", s.config.Version)

// start our backend
err := s.backend.Start()
if err != nil {
Expand Down
6 changes: 6 additions & 0 deletions utils/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ const (
// MakeInsecureHTTPRequest fires the passed in http request against a transport that does not validate
// SSL certificates.
func MakeInsecureHTTPRequest(req *http.Request) (*RequestResponse, error) {
req.Header.Set("User-Agent", HTTPUserAgent)

start := time.Now()
requestTrace, err := httputil.DumpRequestOut(req, true)
if err != nil {
Expand All @@ -62,6 +64,8 @@ func MakeInsecureHTTPRequest(req *http.Request) (*RequestResponse, error) {
// MakeHTTPRequest fires the passed in http request, returning any errors encountered. RequestResponse is always set
// regardless of any errors being set
func MakeHTTPRequest(req *http.Request) (*RequestResponse, error) {
req.Header.Set("User-Agent", HTTPUserAgent)

start := time.Now()
requestTrace, err := httputil.DumpRequestOut(req, true)
if err != nil {
Expand Down Expand Up @@ -180,3 +184,5 @@ func GetInsecureHTTPClient() *http.Client {

return client
}

var HTTPUserAgent = "Courier/vDev"

0 comments on commit 163532d

Please sign in to comment.