cleanup: remove redundant HTTPClient definition (#643)
This counts as a follow-up cleanup as part of doing https://github.com/ooni/probe/issues/1885.
This commit is contained in:
parent
273b70bacc
commit
43161a8138
9 changed files with 19 additions and 37 deletions
|
|
@ -193,25 +193,17 @@ type httpTransportBody struct {
|
|||
io.Closer
|
||||
}
|
||||
|
||||
// HTTPClient is the HTTP client type we use. This interface is
|
||||
// compatible with http.Client. What changes in this kind of clients
|
||||
// is that we'll insert redirection events into the WritableDB.
|
||||
type HTTPClient interface {
|
||||
Do(req *http.Request) (*http.Response, error)
|
||||
CloseIdleConnections()
|
||||
}
|
||||
|
||||
// NewHTTPClient creates a new HTTPClient instance that
|
||||
// does not automatically perform redirects.
|
||||
func NewHTTPClientWithoutRedirects(
|
||||
db WritableDB, jar http.CookieJar, txp model.HTTPTransport) HTTPClient {
|
||||
db WritableDB, jar http.CookieJar, txp model.HTTPTransport) model.HTTPClient {
|
||||
return newHTTPClient(db, jar, txp, http.ErrUseLastResponse)
|
||||
}
|
||||
|
||||
// NewHTTPClientWithRedirects creates a new HTTPClient
|
||||
// instance that automatically perform redirects.
|
||||
func NewHTTPClientWithRedirects(
|
||||
db WritableDB, jar http.CookieJar, txp model.HTTPTransport) HTTPClient {
|
||||
db WritableDB, jar http.CookieJar, txp model.HTTPTransport) model.HTTPClient {
|
||||
return newHTTPClient(db, jar, txp, nil)
|
||||
}
|
||||
|
||||
|
|
@ -241,7 +233,7 @@ type HTTPRedirectEvent struct {
|
|||
var ErrHTTPTooManyRedirects = errors.New("stopped after 10 redirects")
|
||||
|
||||
func newHTTPClient(db WritableDB, cookiejar http.CookieJar,
|
||||
txp model.HTTPTransport, defaultErr error) HTTPClient {
|
||||
txp model.HTTPTransport, defaultErr error) model.HTTPClient {
|
||||
return netxlite.WrapHTTPClient(&http.Client{
|
||||
Transport: txp,
|
||||
Jar: cookiejar,
|
||||
|
|
|
|||
Loading…
Reference in a new issue