[Patch] Gallery export + HTTP Auth



Hi,

ATM F-Spot doesn't support exporting pics to a gallery
(http://gallery.menalto.com) which is protected through HTTP Basic Auth,
as you also can see here:

http://bugzilla.gnome.org/show_bug.cgi?id=314125

The attached patch allows you in a pretty simple way to connect to this
galleries, by specifing the URL as follows:

http://username:password example com

It's not exactly brilliant, but works and shouldn't harm anything else.

cheers,
Fabian
--- FormClient.cs.old	2006-03-09 15:49:44.000000000 +0100
+++ FormClient.cs	2006-03-09 15:47:02.000000000 +0100
@@ -198,6 +198,22 @@
 	{
 		this.Progress = progress_item;
 		Request = (HttpWebRequest) WebRequest.Create (uri);
+
+		string uristring = uri.ToString();
+		if (uristring.IndexOf("@") != -1) {
+			// extract from http://<user>:<pass>@domain/path
+			string logstring = uristring.Substring(7, uristring.IndexOf("@") - 7);
+			string[] userdata = logstring.Split(new Char [] {':'});
+
+			Request.PreAuthenticate = true;
+			NetworkCredential cred = new NetworkCredential(userdata[0], userdata[1]);
+
+			CredentialCache credcache = new CredentialCache();
+			credcache.Add(uri, "Basic", cred);
+
+			Request.Credentials = credcache;
+		}
+
 		CookieCollection cookie_collection = Cookies.GetCookies (uri);
 
 		Request.CookieContainer = new CookieContainer ();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]