views:

29

answers:

1

Hi

I am building an iPhone app the retrieves a file from an IIS7 server. I'm using a plain old NSURLRequest to retrieve this file. The request works fine if I use another web server, but for some reason this one keeps giving me a 400 bad request. So I took a look at the request the NSURLRequest sends, and it looks like this:

::1 [Wed Sep 01 20:18:53 -0400 2010]: GET /some.file
::1 [Wed Sep 01 20:18:53 -0400 2010]:  HTTP/1.1
::1 [Wed Sep 01 20:18:53 -0400 2010]: Host: localhost
::1 [Wed Sep 01 20:18:53 -0400 2010]: User-Agent: MyApp/1.0 CFNetwork/485.2 Darwin/10.4.0
::1 [Wed Sep 01 20:18:53 -0400 2010]: Accept: */*
::1 [Wed Sep 01 20:18:53 -0400 2010]: Accept-Language: en-us
::1 [Wed Sep 01 20:18:53 -0400 2010]: Accept-Encoding: gzip, deflate
::1 [Wed Sep 01 20:18:53 -0400 2010]: Connection: keep-alive
::1 [Wed Sep 01 20:18:53 -0400 2010]: 

I used telnet and connected directly to the webserver. Sent the following:

GET /some.file HTTP/1.1\r\n

This worked fine, the server responded with the file.

I have a feeling that the fact that NSURLRequest puts HTTP/1.1 on another line causes IIS7 to return a Bad Request.

Anyone know how I can remedy this situation? I don't mind making changes on the server or client, but unfortunately i'm stuck with IIS.

Thanks

A: 

Figured it out...my URL had a \n at the end. No wonder NSURLRequest was placing HTTP/1.1 on another line. I'm surprised NSURL doesn't clean up the string. wow.

Felix Khazin