public
Description: An iPhoto plugin to export photos to Gallery.
Homepage: http://zwily.com/iphoto
Clone URL: git://github.com/zwily/iphototogallery.git
Fix http auth uploads (patch from George Ferguson)
zwily (author)
Sat May 03 08:51:24 -0700 2008
commit  3cbdfcb62ccd7c459565afa555ee07b06505fc2a
tree    7b4f02eccbb929cc7f57666976a98ee482115eac
parent  23f551b0f6d8a5e0c271124e98bee21eddd94a6f
...
247
248
249
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
250
251
252
...
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
0
@@ -247,6 +247,36 @@
0
     
0
     CFHTTPMessageRef messageRef = CFHTTPMessageCreateRequest(kCFAllocatorDefault, CFSTR("POST"), (CFURLRef)[gallery fullURL], kCFHTTPVersion1_1);
0
     
0
+ /*
0
+ * gf: 2/27/2008: The initial login to a gallery (ZWGallery doLogin) uses NSURLRequest. Since this
0
+ * connection uses CFHTTPMessage (in order to monitor progress; see below), and since CFHTTPMessage
0
+ * (apparently) doesn't handle user@pass in URLs automagically, we may need to add authentication
0
+ * credentials. We have to pull them out of the URL (if they're there).
0
+ *
0
+ * Note the warning in the CF Network Programming Guide: "Do not apply credentials to the HTTP request
0
+ * before receiving a server challenge. The server may have changed since the last time you authenticated
0
+ * and you could create a security risk." Unfortunately, doing this right would require a more elaborate
0
+ * reworking of the upload loop (below) than I have time or understanding to create.
0
+ */
0
+ NSURL *fullURL = [gallery fullURL];
0
+ NSString *user = [fullURL user];
0
+ NSString *password = [fullURL password];
0
+ NSLog(@"addItemSynchronously: user=%@, password=%@", user, password);
0
+ if (user != nil) {
0
+ NSLog(@"addItemSynchronously: adding authentication");
0
+ Boolean result = CFHTTPMessageAddAuthentication(messageRef, // request
0
+ nil, // authenticationFailureResponse
0
+ (CFStringRef)user,
0
+ (CFStringRef)password,
0
+ kCFHTTPAuthenticationSchemeBasic,
0
+ FALSE); // forProxy
0
+ if (result) {
0
+ NSLog(@"addItemSynchronously: added authentication");
0
+ } else {
0
+ NSLog(@"addItemSynchronously: failed to add authentication!");
0
+ }
0
+ }
0
+
0
     NSString *boundary = @"--------iPhotoToGallery012nklfad9s0an3flakn3lkghkdshlafk3ln2lghroqyoi-----";
0
     // the actual boundary lines can to start with an extra 2 hyphens, so we'll make a string to hold that too
0
     NSString *boundaryNL = [[@"--" stringByAppendingString:boundary] stringByAppendingString:@"\r\n"];

Comments

    No one has commented yet.