Re: Send POST data to browser
Re: Send POST data to browser
- Subject: Re: Send POST data to browser
- From: Jens Alfke <email@hidden>
- Date: Thu, 17 Sep 2009 10:14:35 -0700
On Sep 17, 2009, at 3:26 AM, Bartosz Białecki wrote:
I can launch browser with url using this code:
NSURL *url = [NSURL URLWithString: @"https://www.example.com/
index.php"];
[[UIApplication sharedApplication] openURL: url];
but I don't know how to send post data.
You can't do it — the browser will only do a GET on URLs it's told to
open.
I tried also another solution: send post data from my application to
website and then get a response, but then I don't know how to open
returned page in browser.
A successful POST will return one of two different things —
(1) A redirect to another page. This is a typical HTTP redirect, with
a status like 302, 303 or 307 and a Location: header that specifies
where to go. In this case you just read the URL from the Location:
header and pass that to the browser.
(2) An actual page body to display, i.e. a 200 status and a bunch of
HTML. This isn't so easy to handle, since you can't give the HTML
itself to the browser. The only way you could display it is to open
your own UIWebView (in which case it would probably be easier to just
open it before the request and use it to send the POST...)
If you own the website, then you can make sure that its login page
does (1), which is the more correct thing to do anyway.
—Jens_______________________________________________
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