Question

I'm developing a java application for a GPRS modem (Siemens TC65). I call several times a method to do a HttpConnection to different URLs. Sometimes it works fine but sometimes I get redirected by my operator (HTTP code 302). I follow the URL provided in the Location header it returns 200 but it's not the page that I want.

If I use the SIM card in a gsm pen and access with a browser, sometimes the same redirect occurs but i eventually reach the desired page. The problem is the modem doesn't execute Javascript, so I analysed what the javascript does and the procedure is the following:

page1 -> page2 -> page3 -> desired page

Page1 and page2 do some base64 coding of the URL and parameters, page3 is a .aspx. So everytime I get a redirection I encode64 my URL and send to the .aspx page, the .aspx page returns 302 with the desired page decoded in the Location header. It even returns a cookie with ASP.NET_SessionId which I save and send in the next request.

But even if i do all of this and follow the URL returned by the .aspx (which is the same as I begin with) it just starts from the beginning and I get an endless loop of redirects.

I can post the code but I don't think it has any problem since it works fine, sometimes... The problem is the successive redirects by the operator and not running a browser.

Anything i should do differently when trying to follow a redirection from an aspx server?

Anyone had any similar problem? I would greatly appreciate any help.

Thanks in advance! Hugo

Was it helpful?

Solution

I managed to make it work.

What I was doing is replacing the javascript in page2 by my own code in my program, since the modem can't run javascript. And used the result and sent it to page3. This is fine but I actually wasn't making a HTTP request to page2.

If I request the three pages in the right sequence, replicating the functions that the javascript did in my own code and save the cookies, after page3 I receive a redirect to the desired web page and doesn't redirect again like it used to. I figured since I did everything page2 did I really didn't need to make a request and just skipped to page3. But for some reason I do, I dunno why, maybe the asp session actually starts on that page and doesn't show on the page source code or the server monitors the page request. And I didn't even understand why the operator needs to do this, I think it might even break HTTP connections from old cellphones cause it isn't really designed for devices that can't run javascript.

Next time I will just use a different operator =p

Thanks to Charles Forsythe for the tips and help.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top