Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException if redirect location is relative #80

Closed
wonderfly opened this issue Jan 9, 2015 · 8 comments
Closed

NullPointerException if redirect location is relative #80

wonderfly opened this issue Jan 9, 2015 · 8 comments
Assignees
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. 🚨 This issue needs some love. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@wonderfly
Copy link
Contributor

From esch...@gmail.com on March 28, 2012 00:23:53

Version of google-http-java-client (e.g. 1.5.0-beta)? 1.7.0-beta Java environment (e.g. Java 6, Android 2.3, App Engine)? Java 6 Describe the problem. Retrieving URL which redirects to local page using relative links leads to NPE
Example URL: http://vkontakte.ru/share.php?url=http://habr.ru/p/140827/ Code:
HttpTransport transport = new NetHttpTransport();
GenericUrl url = new GenericUrl(" http://vkontakte.ru/share.php?url=http://habr.ru/p/140827/"); HttpRequest request = transport.createRequestFactory().buildGetRequest(url);
HttpResponse response = request.execute();
Exception:
Exception in thread "main" java.lang.NullPointerException
at com.google.api.client.http.GenericUrl.(GenericUrl.java:104)
at com.google.api.client.http.HttpRequest.handleRedirect(HttpRequest.java:864)
at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:827)
at Service.getPageContent(Service.java:64) How would you expect it to be fixed? I think redirect url should be constructed using current request

Original issue: http://code.google.com/p/google-http-java-client/issues/detail?id=80

@wonderfly wonderfly added type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. imported priority: p2 Moderately-important priority. Fix may not be included in next release. labels Jan 9, 2015
@wonderfly wonderfly self-assigned this Jan 9, 2015
@wonderfly
Copy link
Contributor Author

From yan...@google.com on April 23, 2012 16:28:03

http://tools.ietf.org/html/rfc2616#section-14.30 According to the specification, the Location field points to an absolute URI, which indicates to me that a relative URL would be incompatible with the specification.

However, note this comment in wikipedia.org: http://en.wikipedia.org/wiki/HTTP_location http://en.wikipedia.org/wiki/URL_redirection#Using_server-side_scripting_for_redirection "While the internet standard RFC 1945 (HTTP 1.0) requires a complete absolute URI for redirection,[2][3] the most popular web browsers tolerate the passing of a relative URL as the value for a Location header.[citation needed]"

I tried it in Chrome and it works there. So it seems reasonable to try to tolerate it in the client library as well.

Status: Accepted
Labels: Component-HTTP

@wonderfly
Copy link
Contributor Author

From yan...@google.com on October 24, 2012 10:39:57

Owner: ngmic...@google.com
Cc: rmis...@google.com
Labels: Milestone-Version1.13.0

@wonderfly
Copy link
Contributor Author

From yan...@google.com on December 13, 2012 06:38:11

Labels: -Milestone-Version1.13.0 Milestone-Version1.14.0

@wonderfly
Copy link
Contributor Author

From yan...@google.com on January 09, 2013 12:50:08

Owner: yan...@google.com
Cc: ngmic...@google.com

@wonderfly
Copy link
Contributor Author

From yan...@google.com on January 09, 2013 14:08:09

https://codereview.appspot.com/7058067/

Status: Started

@wonderfly
Copy link
Contributor Author

From yan...@google.com on January 14, 2013 12:08:46

Status: Fixed

@wonderfly
Copy link
Contributor Author

From mingfai...@gmail.com on February 23, 2013 02:53:42

The fix cannot handle relative path redirect for empty path URL, @see https://code.google.com/p/google-http-java-client/issues/detail?id=201

@wonderfly
Copy link
Contributor Author

From yan...@google.com on March 11, 2013 04:58:38

Issue 198 has been merged into this issue.

@yoshi-automation yoshi-automation added the 🚨 This issue needs some love. label Apr 6, 2020
clundin25 pushed a commit to clundin25/google-http-java-client that referenced this issue Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p2 Moderately-important priority. Fix may not be included in next release. 🚨 This issue needs some love. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

2 participants