<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -247,6 +247,36 @@
     
     CFHTTPMessageRef messageRef = CFHTTPMessageCreateRequest(kCFAllocatorDefault, CFSTR(&quot;POST&quot;), (CFURLRef)[gallery fullURL], kCFHTTPVersion1_1);
     
+    /*
+	 * gf: 2/27/2008: The initial login to a gallery (ZWGallery doLogin) uses NSURLRequest. Since this
+	 * connection uses CFHTTPMessage (in order to monitor progress; see below), and since CFHTTPMessage
+	 * (apparently) doesn't handle user@pass in URLs automagically, we may need to add authentication
+	 * credentials. We have to pull them out of the URL (if they're there).
+	 *
+	 * Note the warning in the CF Network Programming Guide: &quot;Do not apply credentials to the HTTP request
+	 * before receiving a server challenge. The server may have changed since the last time you authenticated
+	 * and you could create a security risk.&quot; Unfortunately, doing this right would require a more elaborate
+	 * reworking of the upload loop (below) than I have time or understanding to create.
+	 */
+	NSURL *fullURL = [gallery fullURL];
+	NSString *user = [fullURL user];
+	NSString *password = [fullURL password];
+	NSLog(@&quot;addItemSynchronously: user=%@, password=%@&quot;, user, password);
+	if (user != nil) {
+		NSLog(@&quot;addItemSynchronously: adding authentication&quot;);
+		Boolean result = CFHTTPMessageAddAuthentication(messageRef,		// request
+														nil,			// authenticationFailureResponse
+														(CFStringRef)user,
+														(CFStringRef)password,
+														kCFHTTPAuthenticationSchemeBasic,
+														FALSE);			// forProxy
+		if (result) {
+			NSLog(@&quot;addItemSynchronously: added authentication&quot;);
+		} else {
+			NSLog(@&quot;addItemSynchronously: failed to add authentication!&quot;);
+		}
+	}
+    
     NSString *boundary = @&quot;--------iPhotoToGallery012nklfad9s0an3flakn3lkghkdshlafk3ln2lghroqyoi-----&quot;;
     // the actual boundary lines can to start with an extra 2 hyphens, so we'll make a string to hold that too
     NSString *boundaryNL = [[@&quot;--&quot; stringByAppendingString:boundary] stringByAppendingString:@&quot;\r\n&quot;];</diff>
      <filename>Source/ZWGalleryAlbum.m</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>23f551b0f6d8a5e0c271124e98bee21eddd94a6f</id>
    </parent>
  </parents>
  <author>
    <name>Zach Wily</name>
    <email>zach@zwily.com</email>
  </author>
  <url>http://github.com/zwily/iphototogallery/commit/3cbdfcb62ccd7c459565afa555ee07b06505fc2a</url>
  <id>3cbdfcb62ccd7c459565afa555ee07b06505fc2a</id>
  <committed-date>2008-05-03T09:01:47-07:00</committed-date>
  <authored-date>2008-05-03T08:51:24-07:00</authored-date>
  <message>Fix http auth uploads (patch from George Ferguson)</message>
  <tree>7b4f02eccbb929cc7f57666976a98ee482115eac</tree>
  <committer>
    <name>Zach Wily</name>
    <email>zach@zwily.com</email>
  </committer>
</commit>
