Re: NSURLConnection substitutes characters?
Re: NSURLConnection substitutes characters?
- Subject: Re: NSURLConnection substitutes characters?
- From: email@hidden
- Date: Sun, 13 Jul 2008 04:25:47 +0000
-------------- Original message ----------------------
From: Stefan Arentz <email@hidden>
>
If you want to send Base64 encoded data in a query parameter (or post
> data) then you will need to 'percentage-escape' it properly. In which
> case a '+' needs to be translated to a '+'.
>
I posted basically the same question on a PHP forum and one poster set off a lightbulb. I use the following method in the PHPInvocation class to build the post and because of my choice of "Content-Type" in the httpHeaderField of the NSMutableURLRequest, the data is getting urlencoded on the Cocoa end.
+ (id) phpRequestWithURL:(NSURL *) inURL
data:(NSData *) inData
{
NSMutableURLRequest *result = [NSMutableURLRequest requestWithURL: inURL];
NSString *dataLength = [[NSNumber numberWithInt: [inData length]] stringValue];
[result setHTTPMethod: @"POST"];
[result setValue: @"application/x-www-form-urlencoded" forHTTPHeaderField: @"Content-type"];
[result setValue: dataLength forHTTPHeaderField: @"Content-length"];
[result setValue: @"close" forHTTPHeaderField: @"Connection"];
[result setHTTPBody: inData];
return result;
}
Is there some content type I could use other than "application/x-www-form-urlencoded" that would work with PHP scripts?
_______________________________________________
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