Fix: HTTP proxy: return the response of a redirect, do not follow (#384)

Authored-by: Fernand Geertsema <fernand@web-iq.eu>
This commit is contained in:
fgeertsema
2021-02-15 14:40:51 +01:00
committed by GitHub
parent a55acb2816
commit bdc8817672

View File

@@ -13,9 +13,11 @@ func newHandler(ctx context.Context, wg *sync.WaitGroup, logger logging.Logger,
stealth, verbose bool, username, password string) http.Handler { stealth, verbose bool, username, password string) http.Handler {
const httpTimeout = 24 * time.Hour const httpTimeout = 24 * time.Hour
return &handler{ return &handler{
ctx: ctx, ctx: ctx,
wg: wg, wg: wg,
client: &http.Client{Timeout: httpTimeout}, client: &http.Client{
Timeout: httpTimeout,
CheckRedirect: returnRedirect},
logger: logger, logger: logger,
verbose: verbose, verbose: verbose,
stealth: stealth, stealth: stealth,
@@ -62,3 +64,8 @@ var hopHeaders = [...]string{ //nolint:gochecknoglobals
"Transfer-Encoding", "Transfer-Encoding",
"Upgrade", "Upgrade",
} }
// Do not follow redirect, but directly return the redirect response.
func returnRedirect(req *http.Request, via []*http.Request) error {
return http.ErrUseLastResponse
}