Skip to content

Commit

Permalink
[probes.http] Allow specifying proxy connect headers (#763)
Browse files Browse the repository at this point in the history
  • Loading branch information
manugarg committed Jun 5, 2024
1 parent d34c671 commit af6d0be
Show file tree
Hide file tree
Showing 4 changed files with 108 additions and 68 deletions.
4 changes: 4 additions & 0 deletions probes/http/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,10 @@ func (p *Probe) getTransport() (*http.Transport, error) {
return nil, fmt.Errorf("error parsing proxy URL (%s): %v", p.c.GetProxyUrl(), err)
}
transport.Proxy = http.ProxyURL(url)

for k, v := range p.c.GetProxyConnectHeader() {
transport.ProxyConnectHeader.Add(k, v)
}
}

if p.c.GetDisableCertValidation() || p.c.GetTlsConfig() != nil {
Expand Down
158 changes: 91 additions & 67 deletions probes/http/proto/config.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion probes/http/proto/config.proto
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ message ProbeConf {
// }
repeated Header headers = 8;
map<string, string> header = 20;

// Request body. This field works similar to the curl's data flag. If there
// are multiple "body" fields, we combine their values with a '&' in between.
//
Expand Down Expand Up @@ -118,6 +118,11 @@ message ProbeConf {
// Proxy URL, e.g. http://myproxy:3128
optional string proxy_url = 16;

// HTTP proxy connect headers. These headers are passed on to the CONNECT
// requests to the HTTP proxies. Note that CONNECT method is used to fetch
// HTTPS URLs via HTTP proxies.
map<string, string> proxy_connect_header = 23;

// User agent. Default user agent is Go's default user agent.
optional string user_agent = 19;

Expand Down
7 changes: 7 additions & 0 deletions probes/http/proto/config_proto_gen.cue
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,13 @@ import (
// Proxy URL, e.g. http://myproxy:3128
proxyUrl?: string @protobuf(16,string,name=proxy_url)

// HTTP proxy connect headers. These headers are passed on to the CONNECT
// requests to the HTTP proxies. Note that CONNECT method is used to fetch
// HTTPS URLs via HTTP proxies.
proxyConnectHeader?: {
[string]: string
} @protobuf(23,map[string]string,proxy_connect_header)

// User agent. Default user agent is Go's default user agent.
userAgent?: string @protobuf(19,string,name=user_agent)

Expand Down

0 comments on commit af6d0be

Please sign in to comment.