Re: NSURLConnection POST issues
Re: NSURLConnection POST issues
- Subject: Re: NSURLConnection POST issues
- From: Jason Foreman <email@hidden>
- Date: Sat, 9 Jan 2010 22:05:15 -0600
On Jan 9, 2010, at 9:31 PM, Damien Cooke wrote:
> here is my code to send this data
>
> [appendedData appendData:[[[NSString stringWithFormat:@"ProdName=%@",[self applicationName]] stringByAddingPercentEscapesUsingEncoding: NSASCIIStringEncoding] dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]];
> [appendedData appendData:[[[NSString stringWithFormat:@"ProdVersion=%@",[self productVersion]] stringByAddingPercentEscapesUsingEncoding: NSASCIIStringEncoding]dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES]];
Review the info for the application/x-www-form-urlencoded Form content type here: <http://www.w3.org/TR/html401/interact/forms.html#h-17.13.4>
In brief, you aren't separating your form variables with an "&" character.
You're doing this:
"ProdName=FooProdVersion=Bar"
whereas you want this:
"ProdName=Foo&ProdVersion=Bar"
> NSString *dataLength = [[NSString alloc] initWithFormat:@"%d", [appendedData length]];
> [request setValue:dataLength forHTTPHeaderField:@"Content-Length"];
I believe this is unnecessary, as it will be calculated automatically from the data passed to -setHTTPBody.
Regards,
Jason
Attachment:
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________
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