From 013813261d14229b6e88fececcdf0543ac84a1bd Mon Sep 17 00:00:00 2001 From: Jim McDonald Date: Mon, 22 Jul 2024 15:51:08 +0100 Subject: [PATCH] Add client headers for events stream. --- CHANGELOG.md | 3 +++ http/events.go | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9fa84d6e..19cf3743 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +dev: + - add client headers for events stream + 0.21.7: - use POST for specific validator and validator balance information diff --git a/http/events.go b/http/events.go index fbaaace8..849adffe 100644 --- a/http/events.go +++ b/http/events.go @@ -62,6 +62,12 @@ func (s *Service) Events(ctx context.Context, topics []string, handler consensus log.Trace().Str("url", callURL).Msg("GET request to events stream") client := sse.NewClient(callURL) + for k, v := range s.extraHeaders { + client.Headers[k] = v + } + if _, exists := client.Headers["User-Agent"]; !exists { + client.Headers["User-Agent"] = defaultUserAgent + } client.Connection.Transport = &http.Transport{ Dial: (&net.Dialer{ Timeout: 2 * time.Second,