• 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
Re: NSURLConnection substitutes characters?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: NSURLConnection substitutes characters?
      • From: Jens Alfke <email@hidden>
    • Re: NSURLConnection substitutes characters?
      • From: Stefan Arentz <email@hidden>
  • Prev by Date: Re: NSURLConnection substitutes characters?
  • Next by Date: Trigonometric Problem, Particularly tan() Function
  • Previous by thread: Re: NSURLConnection substitutes characters?
  • Next by thread: Re: NSURLConnection substitutes characters?
  • Index(es):
    • Date
    • Thread