Skip to content

Commit db00d11

Browse files
committed
Changing the field name from extraHeaders to Headers
1 parent 72c32f5 commit db00d11

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

config/http_config.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ type HTTPClientConfig struct {
178178
// marshalled configuration when set to false.
179179
FollowRedirects bool `yaml:"follow_redirects" json:"follow_redirects"`
180180
// Extra Headers to be added on the Http Request
181-
ExtraHeaders map[string]string `yaml:"extra_headers,omitempty" json:"extra_headers,omitempty"`
181+
Headers map[string]string `yaml:"headers,omitempty" json:"headers,omitempty"`
182182
}
183183

184184
// SetDirectory joins any relative file paths with dir.
@@ -420,8 +420,8 @@ func NewRoundTripperFromConfig(cfg HTTPClientConfig, name string, optFuncs ...HT
420420
rt = NewBasicAuthRoundTripper(cfg.BasicAuth.Username, cfg.BasicAuth.Password, cfg.BasicAuth.PasswordFile, rt)
421421
}
422422

423-
if cfg.ExtraHeaders != nil && len(cfg.ExtraHeaders) > 0 {
424-
rt = NewExtraHeadersRoundTripper(cfg.ExtraHeaders, rt)
423+
if cfg.Headers != nil && len(cfg.Headers) > 0 {
424+
rt = NewExtraHeadersRoundTripper(cfg.Headers, rt)
425425
}
426426

427427
if cfg.OAuth2 != nil {

config/http_config_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ const (
6868
ExpectedPassword = "42"
6969
)
7070

71-
var expectedExtraHeaders = map[string]string{"Header1": "Value1", "Header2": "Value2"}
71+
var expectedHeaders = map[string]string{"Header1": "Value1", "Header2": "Value2"}
7272

7373
var invalidHTTPClientConfigs = []struct {
7474
httpClientConfigFile string
@@ -202,7 +202,7 @@ func TestNewClientFromConfig(t *testing.T) {
202202
},
203203
{
204204
clientConfig: HTTPClientConfig{
205-
ExtraHeaders: expectedExtraHeaders,
205+
Headers: expectedHeaders,
206206
TLSConfig: TLSConfig{
207207
CAFile: TLSCAChainPath,
208208
CertFile: ClientCertificatePath,
@@ -211,9 +211,9 @@ func TestNewClientFromConfig(t *testing.T) {
211211
InsecureSkipVerify: false},
212212
},
213213
handler: func(w http.ResponseWriter, r *http.Request) {
214-
for key, value := range expectedExtraHeaders {
214+
for key, value := range expectedHeaders {
215215
if r.Header.Get(key) != value {
216-
fmt.Fprintf(w, "The received Headers (%s) does not contain all expected headers (%s).", r.Header, expectedExtraHeaders)
216+
fmt.Fprintf(w, "The received Headers (%s) does not contain all expected headers (%s).", r.Header, expectedHeaders)
217217
return
218218
}
219219
}

0 commit comments

Comments
 (0)