Re: NSURLConnection POST issues
Re: NSURLConnection POST issues
- Subject: Re: NSURLConnection POST issues
- From: Damien Cooke <email@hidden>
- Date: Sun, 10 Jan 2010 15:31:09 +1030
Thanks Jason,
I knew it would be simple. Thank you so much.
Regards
Damien
On 10/01/2010, at 2:35 PM, Jason Foreman wrote:
>
> 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
>
>
_______________________________________________
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