JDK-4786588 : redirect broken with relative URL
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.net
  • Affected Version: 1.4.0
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_8
  • CPU: generic
  • Submitted: 2002-11-30
  • Updated: 2002-12-02
  • Resolved: 2002-12-02
Related Reports
Duplicate :  
Description
When a HttpURLConnection encounters a redirect, it attempts to parse the
redirect URL.  This may be a relative URL, however it is parsed as an
absolute URL.  Consequently, a relative URL appearing in the redirect
header will result in a Malformed URLException rather than the correct
redirection behavior.

The underlying bug is in the class

	sun.net.www.protocol.http.HttpURLConnection

in the method

	followRedirect()

in the statment

	locUrl = new URL(loc);

Which should be using the two-argument version of the URL constructor.



Comments
EVALUATION Actually, RFC2616 specifies that an absolute URI must be used for redirects. However, the browsers all support relative URIs, so the issue has been fixed in 1.4.2. See 4726087. ###@###.### 2002-12-02
02-12-2002