NSMutableURLRequest: How to change Request URI?
-
Writing an iPhone app to login to a site remotely that is running php. In order to log in to the website it appears I need to do the following:
POST /submit.php?do=submit HTTP/1.1\r\n
However, no matter what I do all I seem to be able to accomplish is:
POST / HTTP/1.1\r\n
It appears that the "/ HTTP/1.1\r\n" are added by NSMutableURLRequest. But I need it to be "/submit.php?do=submit HTTP/1.1\r\n". So how do I make these changes?
Cheers,
Lloyd -
On Apr 5, 2010, at 7:30 AM, Lloyd Sargent wrote:
> Writing an iPhone app to login to a site remotely that is running php. In order to log in to the website it appears I need to do the following:
>
> POST /submit.php?do=submit HTTP/1.1\r\n
>
> However, no matter what I do all I seem to be able to accomplish is:
>
> POST / HTTP/1.1\r\n
>
> It appears that the "/ HTTP/1.1\r\n" are added by NSMutableURLRequest.
Yes; that is required by the spec. Otherwise the server would assume the client is using an ancient version of HTTP, which is not what you want to happen.
> But I need it to be "/submit.php?do=submit HTTP/1.1\r\n". So how do I make these changes?
Are you sure you're setting the URL correctly? That bit is part of the URL. What is the returned value of [request URL] prior to placing the request into a connection?
Nick Zitzmann
<http://www.chronosnet.com/> -
>> It appears that the "/ HTTP/1.1\r\n" are added by NSMutableURLRequest.
>
>
> Yes; that is required by the spec. Otherwise the server would assume the client is using an ancient version of HTTP, which is not what you want to happen.
Got it.
>> But I need it to be "/submit.php?do=submit HTTP/1.1\r\n". So how do I make these changes?
>
>
> Are you sure you're setting the URL correctly? That bit is part of the URL. What is the returned value of [request URL] prior to placing the request into a connection?
Doh!!! Thanks, it's been a while and the mind gets rusty.
Yup, just added it to the URL and now it works just perfect! I'm a happy camper!
Cheers,
Lloyd


