Fix: HTTP proxy: return the response of a redirect, do not follow
Authored-by: Fernand Geertsema
@@ -15,7 +15,9 @@ func newHandler(ctx context.Context, wg *sync.WaitGroup, logger logging.Logger,
return &handler{
ctx: ctx,
wg: wg,
- client: &http.Client{Timeout: httpTimeout},
+ client: &http.Client{
+ Timeout: httpTimeout,
+ CheckRedirect: returnRedirect},
logger: logger,
verbose: verbose,
stealth: stealth,
@@ -62,3 +64,8 @@ var hopHeaders = [...]string{ //nolint:gochecknoglobals
"Transfer-Encoding",
"Upgrade",
}
+
+// Do not follow redirect, but directly return the redirect response.
+func returnRedirect(req *http.Request, via []*http.Request) error {
+ return http.ErrUseLastResponse
+}
