[vlc-commits] HTTP: use a single variable to track redirections

Rémi Denis-Courmont git at videolan.org
Wed May 25 17:27:06 CEST 2011


vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Wed May 25 17:26:36 2011 +0300| [c237e73edfd1406b130dd702012921775bfea4da] | committer: Rémi Denis-Courmont

HTTP: use a single variable to track redirections

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=c237e73edfd1406b130dd702012921775bfea4da
---

 modules/access/http.c |   17 +++++++----------
 1 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/modules/access/http.c b/modules/access/http.c
index 39a5878..271c1fb 100644
--- a/modules/access/http.c
+++ b/modules/access/http.c
@@ -214,8 +214,7 @@ struct access_sys_t
 
 /* */
 static int OpenWithCookies( vlc_object_t *p_this, const char *psz_access,
-                            int i_nb_redirect, int i_max_redirect,
-                            vlc_array_t *cookies );
+                            unsigned i_redirect, vlc_array_t *cookies );
 
 /* */
 static ssize_t Read( access_t *, uint8_t *, size_t );
@@ -246,7 +245,7 @@ static int AuthCheckReply( access_t *p_access, const char *psz_header,
 static int Open( vlc_object_t *p_this )
 {
     access_t *p_access = (access_t*)p_this;
-    return OpenWithCookies( p_this, p_access->psz_access, 0,
+    return OpenWithCookies( p_this, p_access->psz_access,
                 var_InheritInteger( p_access, "http-max-redirect" ), NULL );
 }
 
@@ -255,14 +254,12 @@ static int Open( vlc_object_t *p_this )
  * @param p_this: the vlc object
  * @psz_access: the acces to use (http, https, ...) (this value must be used
  *              instead of p_access->psz_access)
- * @i_nb_redirect: the number of redirection already done
- * @i_max_redirect: limit to the number of redirection to follow
+ * @i_redirect: number of redirections remaining
  * @cookies: the available cookies
  * @return vlc error codes
  */
 static int OpenWithCookies( vlc_object_t *p_this, const char *psz_access,
-                            int i_nb_redirect, int i_max_redirect,
-                            vlc_array_t *cookies )
+                            unsigned i_redirect, vlc_array_t *cookies )
 {
     access_t     *p_access = (access_t*)p_this;
     access_sys_t *p_sys;
@@ -576,7 +573,7 @@ connect:
         msg_Dbg( p_access, "redirection to %s", p_sys->psz_location );
 
         /* Check the number of redirection already done */
-        if( i_nb_redirect >= i_max_redirect )
+        if( i_redirect == 0 )
         {
             msg_Err( p_access, "Too many redirection: break potential infinite"
                      "loop" );
@@ -617,8 +614,8 @@ connect:
         free( p_sys );
 
         /* Do new Open() run with new data */
-        return OpenWithCookies( p_this, psz_protocol, i_nb_redirect + 1,
-                                i_max_redirect, cookies );
+        return OpenWithCookies( p_this, psz_protocol, i_redirect - 1,
+                                cookies );
     }
 
     if( p_sys->b_mms )



More information about the vlc-commits mailing list