[vlc-devel] Remember http credentials for the current session.

hasu0bs at web.de hasu0bs at web.de
Thu Feb 28 10:46:21 CET 2013


http://forum.videolan.org/viewtopic.php?f=7&t=62929&p=368234#p337401
-------------- next part --------------
>From a7276dc8d79bdc1ffcdcb746b2adda832a319c0d Mon Sep 17 00:00:00 2001
From: Mettbrot <hasu0bs at web.de>
Date: Wed, 27 Feb 2013 17:16:39 +0100
Subject: [PATCH] Update modules/access/http.c

Remember Username and Password for the current session. (Original Code from james.h.bates)
---
 modules/access/http.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)

diff --git a/modules/access/http.c b/modules/access/http.c
index 535f0bf..a80e27e 100644
--- a/modules/access/http.c
+++ b/modules/access/http.c
@@ -195,6 +195,9 @@ struct access_sys_t
     vlc_array_t * cookies;
 };
 
+char      *psz_cached_http_user = NULL;
+char      *psz_cached_http_password = NULL;
+
 /* */
 static int OpenWithCookies( vlc_object_t *p_this, const char *psz_access,
                             unsigned i_redirect, vlc_array_t *cookies );
@@ -538,6 +541,17 @@ connect:
             Disconnect( p_access );
             goto connect;
         }
+        if (psz_cached_http_user && psz_cached_http_password) {
+
+               p_sys->url.psz_username = strdup(psz_cached_http_user);
+               free(psz_cached_http_user);
+               psz_cached_http_user = NULL;
+               p_sys->url.psz_password = strdup(psz_cached_http_password);
+               free(psz_cached_http_password);
+               psz_cached_http_password = NULL;
+               Disconnect(p_access);
+               goto connect;
+        }
         msg_Dbg( p_access, "authentication failed for realm %s",
                  p_sys->auth.psz_realm );
         dialog_Login( p_access, &psz_login, &psz_password,
@@ -560,6 +574,17 @@ connect:
         }
     }
 
+    /* Succesful authentication => remember user/password if any */
+    if (p_sys->url.psz_username) {
+
+       psz_cached_http_user = strdup(p_sys->url.psz_username);
+    }
+
+    if (p_sys->url.psz_password) {
+
+       psz_cached_http_password = strdup(p_sys->url.psz_password);
+    }
+
     if( ( p_sys->i_code == 301 || p_sys->i_code == 302 ||
           p_sys->i_code == 303 || p_sys->i_code == 307 ) &&
         p_sys->psz_location && *p_sys->psz_location )
-- 
1.8.0.msysgit.0



More information about the vlc-devel mailing list