-
Notifications
You must be signed in to change notification settings - Fork 323
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add support for proxy connect headers #409
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ package config | |
|
||
import ( | ||
"encoding/json" | ||
"net/http" | ||
"path/filepath" | ||
) | ||
|
||
|
@@ -48,6 +49,29 @@ func (s Secret) MarshalJSON() ([]byte, error) { | |
return json.Marshal(secretToken) | ||
} | ||
|
||
type Header map[string][]Secret | ||
|
||
func (h *Header) HTTPHeader() http.Header { | ||
if h == nil || *h == nil { | ||
return nil | ||
} | ||
|
||
header := make(http.Header) | ||
|
||
for name, values := range *h { | ||
var s []string | ||
if values != nil { | ||
s = make([]string, 0, len(values)) | ||
for _, value := range values { | ||
s = append(s, string(value)) | ||
} | ||
} | ||
header[name] = s | ||
Comment on lines
+62
to
+69
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code has a slightly odd smell to me. Why not simply use The test cases would need to be adjusted, since the bogus items like nil header names or empty value lists won't be added, as they would be illegal headers - and as such I don't see the point of including them as test cases anyway. Header.Add() will also canonicalize the header names. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh, yeah, I completely missed that. I'll follow up with another PR. |
||
} | ||
|
||
return header | ||
} | ||
|
||
// DirectorySetter is a config type that contains file paths that may | ||
// be relative to the file containing the config. | ||
type DirectorySetter interface { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"proxy_connect_header": { | ||
"single": [ | ||
"value_0" | ||
], | ||
"multi": [ | ||
"value_1", | ||
"value_2" | ||
] | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
proxy_connect_header: | ||
single: | ||
- value_0 | ||
multi: | ||
- value_1 | ||
- value_2 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"proxy_url": "http://remote.host", | ||
"proxy_connect_header": { | ||
"single": [ | ||
"value_0" | ||
], | ||
"multi": [ | ||
"value_1", | ||
"value_2" | ||
] | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is added mostly to be able to test the conversion to http.Header and the marshaling / unmarshaling.