views:

40

answers:

1

Hello all,

So I am trying to connect to my company's website through an HTTP authentication request. The problem is, in order to validate, it has to go through a series of redirects and gather 2 cookies along the way. Does anyone know if the ASI libraries found here have a way of handling this sort of thing?

For example, does the request traverse the redirects automatically? I mean I set the username and password for the request for the login page, but I am not sure how to make it do anything from there. I have solved this problem in Java, but am relatively new to iPad/Objective-c programming Any help in this whatsoever would be greatly appreciated. Thanks!

A: 

When I've had to do this type of automated web form login coding before, I normally code it up as an OSX app and use HTTPScoop to see what's going on with the requests. You can just login with your browser with HTTPScoop running to see what the browser is sending and then mimic that with your code. Once I have it working on OSX, I move the code into the iPhone/iPad app. This seems to work pretty well. ASIHTTPRequest works on both OSX and iOS so porting it over once it's working on OSX is trivial.

Matt Long
Ah ok that sounds like a good place to start. Thanks for your help, I will keep you posted.
gabaum10
So is there no library anywhere that will automatically follow the redirects and return the cookies at the end? I know there are a few ways to do that in Java and it is very surprising that none exist in objective-c.
gabaum10
Not that I'm aware of. If you find one, let me know. ;-)
Matt Long
It turns out the ASI libraries do do that. They just do not flaunt that for some reason. It seems to me that would have been really useful to know. There is a flag "shouldFollowRedirects" that you can set. Thanks for the help :)
gabaum10
Yeah. Didn't realize it either. I'll have to take a closer look at that feature. Very interesting.
Matt Long