• 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
NSURLDownload Error
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSURLDownload Error


  • Subject: NSURLDownload Error
  • From: Eric Musgrove <email@hidden>
  • Date: Sun, 11 Nov 2007 03:09:24 -0500

I'm attempting to send a POST request from my Cocoa app, and then handle the subsequent download. I've gone through a bit of information via a blog regarding how to actually send a post request, and have attempted to implement it, however I seem to be having an issue. My code follows:

@implementation LoginHandler
- (void)beginLogin:user_id withKey:api_key andSpinner:statusSpinner
{
NSString *post = [NSString stringWithFormat:@"userID=%@&apiKey=%@", user_id, api_key];
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];

NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];

NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:@"http://api.eve-online.com/account/Characters.xml.aspx "]];
[request setHTTPMethod:@"POST"];
[request setValue:postLength forHTTPHeaderField:@"Content-Length"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];

NSURLDownload *loginRequest = [[NSURLDownload alloc] initWithRequest:request delegate:self];

[statusSpinner startAnimation:self];

if (loginRequest)
{
NSLog(@"Download Started");
//[loginRequest setDestination:@"/Users/eric/" allowOverwrite:YES];
}
else
{
NSLog(@"Error");
}
[statusSpinner stopAnimation:self];
}


- (void)download:(NSURLDownload *)download didReceiveResponse: (NSURLResponse *)response
{
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response;
NSDictionary *httpResponseHeaderFields = [httpResponse allHeaderFields];
NSLog(@"Response Received: \n\n%@", httpResponseHeaderFields);
}


- (void)downloadDidFinish:(NSURLDownload *)download
{
	[download release];
	NSLog(@"%@", @"downloadDidFinish");
}

- (void)download:(NSURLDownload *)download didFailWithError:(NSError *)error
{
[download release];
NSLog(@"Download failed! Error - %@ %@", [error localizedDescription], [[error userInfo] objectForKey:NSErrorFailingURLStringKey]);
}


@end

The resulting output is as such:

2007-11-11 02:55:31.556 Eve Online Monitor[10353:10b] Download Started
2007-11-11 02:55:31.868 Eve Online Monitor[10353:10b] Response Received:

{
"Cache-Control" = private;
"Content-Type" = "application/xml; charset=utf-8";
Date = "Sun, 11 Nov 2007 07:55:31 GMT";
Server = "Microsoft-IIS/6.0";
"Transfer-Encoding" = Identity;
"X-Aspnet-Version" = "2.0.50727";
"X-Powered-By" = "ASP.NET";
}
2007-11-11 02:55:31.872 Eve Online Monitor[10353:10b] Download failed! Error - Cannot open file http://api.eve-online.com/account/Characters.xml.aspx


No manner of modifying the code has resulting in any variation, which is quite odd cause simply going to the URL itself provides a result. However, doing a curl on the fully formed url returns fine. Any assistance would be greatly appreciated.
_______________________________________________


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


  • Prev by Date: Re: Misc questions
  • Next by Date: Re: SenTestingKit fails when using CG-Only (Fixed)
  • Previous by thread: Re: Core Data NSSQLiteStoreType problem
  • Next by thread: Re: SenTestingKit fails when using CG-Only (Fixed)
  • Index(es):
    • Date
    • Thread