• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Why does this https post request always return "404 Not Found"
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: Why does this https post request always return "404 Not Found"
      • From: Jens Alfke <email@hidden>
  • Prev by Date: cutting an image into multiple images
  • Next by Date: Re: getting the selected object from an NSTableView causes problems
  • Previous by thread: Re: cutting an image into multiple images
  • Next by thread: Re: Why does this https post request always return "404 Not Found"
  • Index(es):
    • Date
    • Thread