-------------- Original message ----------------------
From: Stefan Arentz <[EMAIL PROTECTED]>
> 
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 '%2b'.
> 

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 protected])

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:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to