rlalfo / google-http-java-client

Automatically exported from code.google.com/p/google-http-java-client
0 stars 0 forks source link

Incorrect relative redirect location for URL with empty path #201

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Version of google-http-java-client (e.g. 1.5.0-beta)?
1.14.0-beta-SNAPSHOT

Java environment (e.g. Java 6, Android 2.3, App Engine)?
Java 1.7.0_13

Describe the problem.
for a base URL with empty path, e.g. "http://www.google.com", a redirect to 
"test" will cause the http client to try to connect to 
"http://www.google.comtest" instead of "http://www.google.com/test" that cause 
a failure.

How would you expect it to be fixed?
In a recent patch, I noticed GenericUrl uses java.net.URI internally.
https://codereview.appspot.com/7058067/patch/8001/9001
I think it is better to use URL rather than URI. 
And in Oracle's JDK, the java.net.URL(URL context, String spec) constructor can 
resolve any full/absolute/relative URL correctly. e.g. System.out.println(new 
URL(new URL("http://www.google.com"), "test")); will return 
"http://www.google.com/test"

URL vs URI for reference: 
http://stackoverflow.com/questions/176264/whats-the-difference-between-a-uri-and
-a-url/1984225#1984225

Original issue reported on code.google.com by mingfai...@gmail.com on 23 Feb 2013 at 10:49

GoogleCodeExporter commented 9 years ago

Original comment by pele...@google.com on 25 Feb 2013 at 2:29

GoogleCodeExporter commented 9 years ago
https://codereview.appspot.com/7393060/

Original comment by pele...@google.com on 27 Feb 2013 at 3:23