Why does this https post request always return "404 Not Found"
Why does this https post request always return "404 Not Found"
- Subject: Why does this https post request always return "404 Not Found"
- From: an0 <email@hidden>
- Date: Sat, 21 Jun 2008 21:43:14 +0800
- (void) login
{
NSString *userName = [[userNameField stringValue]
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSString *password = [[passwordField stringValue]
stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *url = [NSURL URLWithString:@"https://secure.del.icio.us/login"];
NSMutableURLRequest *urlRequest = [NSMutableURLRequest
requestWithURL:url
cachePolicy:NSURLRequestReturnCacheDataElseLoad
timeoutInterval:30];
[urlRequest setHTTPMethod:@"POST"];
NSString *body = [NSString stringWithFormat:
@"user_name=%@&"
@"password=%@",
userName, password];
[urlRequest setHTTPBody:[body dataUsingEncoding:NSUTF8StringEncoding]];
NSLog(@"request: %@\n%@\n%@",
[urlRequest URL],
[urlRequest HTTPMethod],
[[[NSString alloc] initWithData:[urlRequest HTTPBody]
encoding:NSUTF8StringEncoding] autorelease]);
NSData *urlData;
NSURLResponse *response;
NSError *error;
urlData = [NSURLConnection sendSynchronousRequest:urlRequest
returningResponse:&response
error:&error];
if (!urlData) {
NSAlert *alert = [NSAlert alertWithError:error];
[alert runModal];
return;
}
// Parse the login result
NSString *loginResult = [[[NSString alloc] initWithData:urlData
encoding:NSUTF8StringEncoding]
autorelease];
NSLog(@"login result: %@", loginResult);
}
Is there anything special about https requests in Cocoa that I must
learn? Since I've verified that sending http requests in this manner
is perfectly OK, and accessing https://secure.del.icio.us/login in web
browsers goes well.
If anyone could tell me anything that I've missed here, I'll very much
appreciate that.
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden