• 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 POST issues
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

  • Follow-Ups:
    • Re: NSURLConnection POST issues
      • From: Damien Cooke <email@hidden>
References: 
 >NSURLConnection POST issues (From: Damien Cooke <email@hidden>)

  • Prev by Date: Re: Enabling NSZombieEnabled programatically
  • Next by Date: Re: Enabling NSZombieEnabled programatically
  • Previous by thread: NSURLConnection POST issues
  • Next by thread: Re: NSURLConnection POST issues
  • Index(es):
    • Date
    • Thread