The Request-URI used in a HTTP request from java.net.HttpURLConnection contains the uri fragment when the connection is being made through a proxy. This is not strictly correct according to RFC 2616 and could cause problems for some proxies.
This is not the case in 1.3.x, the fragment is not added to the Request-URI. This behavior first changed in 1.4.
In the case where the connection is direct the uri fragment is not added to the Request-URI for all version of the jdk.
The Request-URI is being generated in HttpClient.getURLFile. In the case where we are connecting through a proxy then URL.toExternalForm is used, and this will include the fragment (if there is one). In the case of direct connection we simply use url.getFile().
This changed from 1.3 to 1.4. In 1.3 we simply do <protocol>://<host><port> + url.getfile(). In 1.4 this was changed to URL.toExternalForm (which includes the fragment).
This change (as mentioned above) was for:
4720715 FTP with user and password doesn't work through proxy
The reason to use toExternalForm is that it will include the username and password if there is one. FTP uses HttpURLConnection in the case of a connection through a proxy.
We should fix it in HttpClient.getURLFile by replacing toExternalForm with something like
<protocol>://<user>:<pass>@<host><port> + url.getfile()