[utils] Remove stray undocumented Host header in redirect (fix 46fde7c)
authordirkf <fieldhouse@gmx.net>
Thu, 20 Jul 2023 04:29:59 +0000 (05:29 +0100)
committerdirkf <fieldhouse@gmx.net>
Thu, 20 Jul 2023 04:29:59 +0000 (05:29 +0100)
youtube_dl/utils.py

index d52fa7a28ba02a36ece42c5c97c74402dc157a83..6d798f13af9ece7b12c01dddf1fb75f6537bdbaa 100644 (file)
@@ -2996,7 +2996,8 @@ class YoutubeDLRedirectHandler(compat_urllib_request.HTTPRedirectHandler):
         # Technically the Cookie header should be in unredirected_hdrs;
         # however in practice some may set it in normal headers anyway.
         # We will remove it here to prevent any leaks.
-        remove_headers = ['Cookie']
+        # Also remove unwanted and undocumented Host header for old URL
+        remove_headers = ['Cookie', 'Host']
 
         # A 303 must either use GET or HEAD for subsequent request
         # https://datatracker.ietf.org/doc/html/rfc7231#section-6.4.4