cleanup(netx): remove unused proxy-via-context codepath (#367)

We always set the proxy explicitly now. So, let us remove this
extra bit of code we're not using.

Part of https://github.com/ooni/probe/issues/1507.
This commit is contained in:
Simone Basso 2021-06-08 22:26:24 +02:00 committed by GitHub
commit b8cae3f5a6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 1 additions and 73 deletions

View file

@ -10,8 +10,6 @@ import (
"io/ioutil"
"net/http"
"net/url"
"github.com/ooni/probe-cli/v3/internal/engine/netx/dialer"
)
// Logger is the definition of Logger used by this package.
@ -40,10 +38,6 @@ type Client struct {
// Logger is the logger to use.
Logger Logger
// ProxyURL allows to force a proxy URL to fallback to a
// tunnel, e.g., Psiphon.
ProxyURL *url.URL
// UserAgent is the user agent to use.
UserAgent string
}
@ -93,11 +87,6 @@ func (c Client) NewRequest(ctx context.Context, method, resourcePath string,
request.Header.Set("Accept", c.Accept)
}
request.Header.Set("User-Agent", c.UserAgent)
// Implementation note: the following allows tunneling if c.ProxyURL
// is not nil. Because the proxy URL is set as part of each request
// generated using this function, every request that eventually needs
// to reconnect will always do so using the proxy.
ctx = dialer.WithProxyURL(ctx, c.ProxyURL)
return request.WithContext(ctx), nil
}