Skip navigation.
 
mlWhy does this https post request always return "404 Not Found"
FROM : an0
DATE : Sat Jun 21 15:43:14 2008

- (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.

Related mailsAuthorDate
mlWhy does this https post request always return "404 Not Found" an0 Jun 21, 15:43
mlRe: Why does this https post request always return "404 Not Found" Jens Alfke Jun 22, 00:32
mlRe: Why does this https post request always return "404 Not Found" an0 Jun 22, 07:14
mlRe: Why does this https post request always return "404 Not Found" Steve Christensen Jun 22, 17:21