0
CFHTTPMessageRef messageRef = CFHTTPMessageCreateRequest(kCFAllocatorDefault, CFSTR("POST"), (CFURLRef)[gallery fullURL], kCFHTTPVersion1_1);
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
+ * 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
+ NSURL *fullURL = [gallery fullURL];
0
+ NSString *user = [fullURL user];
0
+ NSString *password = [fullURL password];
0
+ NSLog(@"addItemSynchronously: user=%@, password=%@", user, password);
0
+ NSLog(@"addItemSynchronously: adding authentication");
0
+ Boolean result = CFHTTPMessageAddAuthentication(messageRef, // request
0
+ nil, // authenticationFailureResponse
0
+ (CFStringRef)password,
0
+ kCFHTTPAuthenticationSchemeBasic,
0
+ NSLog(@"addItemSynchronously: added authentication");
0
+ NSLog(@"addItemSynchronously: failed to add authentication!");
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.