From 8dcc9704c6e54b5a1e420a55000bd88e1cc43655 Mon Sep 17 00:00:00 2001
From: Christophe Mutricy <xtophe@videolan.org>
Date: Sun, 6 Jan 2008 19:54:28 +0000
Subject: [PATCH] Only rewrite the URI if it's a permanent redirection. Thanks
 to Sebastian Wiedenroth for the patch + some modification by me. Fix #1408

---
 modules/access/http.c | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/modules/access/http.c b/modules/access/http.c
index cce9f70c5596..76b868ea30e1 100644
--- a/modules/access/http.c
+++ b/modules/access/http.c
@@ -330,19 +330,20 @@ connect:
             msg_Err( p_access, "insecure redirection ignored" );
             goto error;
         }
+        if( p_sys->i_code == 301 )
+        {
+            /* Permanent redirection: Change the URI */
+            p_playlist = pl_Yield( p_access );
+            PL_LOCK;
 
-        /* Change the URI */
-        p_playlist = pl_Yield( p_access );
-        PL_LOCK;
+            p_input_item = p_playlist->status.p_item->p_input;
+            input_item_SetURI( p_input_item, p_sys->psz_location );
 
-        p_input_item = p_playlist->status.p_item->p_input;
-        input_item_SetURI( p_input_item, p_sys->psz_location );
+            PL_UNLOCK;
+            pl_Release( p_access );
+        }
         free( p_access->psz_path );
         p_access->psz_path = strdup( p_sys->psz_location );
-
-        PL_UNLOCK;
-        pl_Release( p_access );
-
         /* Clean up current Open() run */
         vlc_UrlClean( &p_sys->url );
         vlc_UrlClean( &p_sys->proxy );
-- 
GitLab