Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
Posts: 35
Registered: ‎12-12-2008
My Device: Not Specified

HttpConnections that work at Starbucks' hotspots

I have an app that makes HttpConnections to my servers. If there is a wifi connection, it of course tries to use that.

 

At our local Starbucks (in Seattle), my HttpConnections are getting redirect responses (302) to go to a hotspot splash page. But my laptop, and my Bold's web browser dont get redirected to this page, or if they do, I don't see it. I am assuming the hotspot just wants an initial page view and then it grants subsequent requests for some period of time.

 

For the Bold browser, I can't figure out if it is using wifi or is cleverly using 3G instead.

 

My question is: how can I get my network connections to act like the browser: either redirect once to the 302 location, and then continue to the target, or realize they don't want to bother with wifi in this context and use WAP2 or direct connections?

 

Clearly, I can special case the current 302 responses I am seeing and decide to use another connection type instead when I see one of these responses, but I'd like to understad if there is a way to get this to work on the wifi connection.

 

Has anyone written code to handle these hotspot redirects?

Developer
Posts: 4,764
Registered: ‎07-21-2008
My Device: Not Specified

Re: HttpConnections that work at Starbucks' hotspots

You can detect the 302 and proceed to the redirect site, although I have never tried this in a StarBucks hotspot Smiley Happy

 

You can find the redirect URL in the "Location" header, like this:

 

if ((m_responseCode == HttpConnection.HTTP_MOVED_TEMP) || (m_responseCode == HttpConnection.HTTP_MOVED_PERM)){ String location = m_httpConnection.getHeaderField("Location"); System.out.println("Redirect location: " + location);

 

....do something with the new URL here }

 

 

Developer
Posts: 1,041
Registered: ‎07-16-2008
My Device: ಠ_ಠ

Re: HttpConnections that work at Starbucks' hotspots

To test with your bold browser you can turn off the carrier network and only have wifi enabled.
Highlighted
Developer
Posts: 35
Registered: ‎12-12-2008
My Device: Not Specified

Re: HttpConnections that work at Starbucks' hotspots

Thanks RexDoug.  I had gotten that far already. What I am getting back from the redirect is a bunch of HTML with some sort of terms and conditions screen for the hotspot.  I have not yet been able to read what it says, but I am writing some debug code to record that. I am assuming it says something like "welcome to the ATT hotspot, please click here to accept our terms and conditions and to continue browsing". At that point, I am assuming the browser client would get a cookie or something that would be good to get through the proxy for a while (with no further redirects).

 

My next step is going to be recording the headers and HTML that come back, both with the 302 response and the subsequent fetch to the redirected location. I was just hoping someone had already jumped through these hoops.