Skip to Main Content

Java APIs

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

URL.openStream fails on redirect to URL with spaces

843790May 9 2007 — edited Apr 3 2009
hi,
silly question probably but i cant find the answer.
a server tries to redirect me to a url with spaces and java doesnt encode the redirected url properly (the second request fails and code 400 is returned)

code like that:
URL url = new URL(urlString);
url.openStream();
on last line IOException is thrown

the communication looks like this
the request is sent from java, the server first replies with HTTP code 302, and returns URL that has empty spaces in the file name part. this is sent as-is back from java in next request and causes server to return HTTP code 400 and java fails with IOException...
as far as i could see other HTTP clients like mozilla or wget encode properly the spaces to %20 in the redirected url (and manage to get the data from redirected url).
what am i doing wrong? please point me to some docs or api pages
thanks & regards
peter

the url, just in case...
http://www.lightclan.nl/index.php?SubID=1079&View=283
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 1 2009
Added on May 9 2007
14 comments
2,640 views