[ale] OT: Java and Cookies

Jason Day jasonday at worldnet.att.net
Fri Aug 29 15:59:11 EDT 2003


On Fri, Aug 29, 2003 at 02:21:18PM -0500, Denny Chambers wrote:
> I am having my own problem, that maybe you can help with. I send a POST 
> request to a URL with HttpURLConnection. tha URL sends back a 302 
> Redirect. The problem happens when the HttpURLConnection goes to follow 
> the redirect, it changes the request to a GET, and I loose the data that 
> I was passing. Any clue on getting around this, before I start hacking 
> it up and handling the redirect myself? Does this sound like a bug, or 
> is this just the way redirects work? Sounds like a bug to me?

In my experience, the HttpClient class (which is what HttpURLConnection
uses by default) cannot follow redirects reliably.  I ended up coding
the redirect handling stuff myself, which really wasn't that hard.  You
just have to remember to set followRedirects to false.  Most of my work
was with JDK 1.3.1_02, so this may be fixed in later versions.  Even in
later versions, though, I think it still always does a GET for the
redirect.

Also, the getResponseCode() method is broken in versions prior to
1.3.1_04.  I don't remember the exact details, but I had to write my own
getResponseCode method too.

And, if you ever need to support SSL, JSSE unfortunately includes all
the bugs in pre 1.3.1_04 versions of the JDK.  Yay.

Jason
-- 
Jason Day                                       jasonday at
http://jasonday.home.att.net                    worldnet dot att dot net
 
"Of course I'm paranoid, everyone is trying to kill me."
    -- Weyoun-6, Star Trek: Deep Space 9
_______________________________________________
Ale mailing list
Ale at ale.org
http://www.ale.org/mailman/listinfo/ale





More information about the Ale mailing list