GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: add option to pass redirect Location: header value as-is without encoding, decoding, or escaping by iocanel · Pull Request #871 · googleapis/google-http-java-client

Conversation

@iocanel

@iocanel iocanel commented Oct 31, 2019 •
edited by elharo
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

Fixes #864

At the moment I have no actual way to test it, as I failed to use 1.33.1-SNAPSHOT with Jib (any helping hand is more than welcome).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@iocanel
iocanel requested a review from a team October 31, 2019 16:40
@googlebot

This comment has been minimized.

Sign in to view
@googlebot googlebot added the cla: no This human has *not* signed the Contributor License Agreement. label Oct 31, 2019
elharo
elharo previously requested changes Oct 31, 2019
View reviewed changes

@elharo elharo left a comment •
edited by chanseokoh
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs tests, and those should probably be written before the model code.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
elharo
elharo reviewed Oct 31, 2019
View reviewed changes

@elharo elharo left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, typo in the issue number.This is for #864, not #834

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@iocanel

This comment has been minimized.

Sign in to view
@googlebot

This comment has been minimized.

Sign in to view
@googlebot googlebot added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels Oct 31, 2019
chanseokoh
chanseokoh reviewed Oct 31, 2019
View reviewed changes

@chanseokoh chanseokoh left a comment •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for doing this. I see there are still several places that need to be updated as well.

places that still need fixing (click to expand)
  public final String buildAuthority() {
    ...
    if (userInfo != null) {
      buf.append(CharEscapers.escapeUriUserInfo(userInfo)).append('@');
  private void appendRawPathFromParts(StringBuilder buf) {
      ...
      if (pathPart.length() != 0) {
        buf.append(CharEscapers.escapeUriPath(pathPart));
  public final String buildRelativeUrl() {
    ...
    if (fragment != null) {
      buf.append('#').append(URI_FRAGMENT_ESCAPER.escape(fragment));
  public static List<String> toPathParts(String encodedPath) {
      ...
      result.add(CharEscapers.decodeUri(sub));
  static void addQueryParams(Set<Entry<String, Object>> entrySet, StringBuilder buf) {
        ...
        String name = CharEscapers.escapeUriQuery(nameValueEntry.getKey());
  private static boolean appendParam(boolean first, StringBuilder buf, String name, Object value) {
    ...
    String stringValue = CharEscapers.escapeUriQuery(value.toString());

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google-http-client/src/main/java/com/google/api/client/http/GenericUrl.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-http-client/src/main/java/com/google/api/client/http/HttpRequest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@chanseokoh

This comment has been minimized.

Sign in to view
@iocanel

This comment has been minimized.

Sign in to view
elharo
elharo reviewed Nov 1, 2019
View reviewed changes

@elharo elharo left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you considered whether a different class or a subclass might be an option instead?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google-http-client/src/main/java/com/google/api/client/http/GenericUrl.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-http-client/src/main/java/com/google/api/client/http/GenericUrl.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-http-client/src/main/java/com/google/api/client/http/GenericUrl.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-http-client/src/main/java/com/google/api/client/http/GenericUrl.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

chanseokoh
chanseokoh reviewed Nov 1, 2019
View reviewed changes

@chanseokoh chanseokoh left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I will start testing this on the Jib side.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google-http-client/src/main/java/com/google/api/client/http/HttpRequest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

chanseokoh
chanseokoh reviewed Nov 1, 2019
View reviewed changes
Comment thread google-http-client/src/main/java/com/google/api/client/http/HttpRequest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

chanseokoh
chanseokoh reviewed Nov 1, 2019
View reviewed changes

@chanseokoh chanseokoh left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks again.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google-http-client/src/main/java/com/google/api/client/http/HttpRequest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@chanseokoh

chanseokoh commented Nov 1, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

I've tested the new behavior with TestWebServer.

  public static void main(String[] args) throws Exception {
    String url1 = "?id=301&_auth_=exp=1572285389~hmac=f0a387f0";
    String url2 = "?id=302&Signature=2wYOD0a%2BDAkK%2F9lQJUOuIpYti8o%3D&Expires=1569997614";
    String url3 = "?id=303&_auth_=exp=1572285389~hmac=f0a387f0";
    String url4 = "?id=307&Signature=2wYOD0a%2BDAkK%2F9lQJUOuIpYti8o%3D&Expires=1569997614";
//  String url5 = "?code=308&_auth_=exp=1572285389~hmac=f0a387f0";

    String redirect301 = "HTTP/1.1 301 Moved Permanently\nLocation: " + url1 + "\nContent-Length: 0\n\n";
    String redirect302 = "HTTP/1.1 302 Found\nLocation: " + url2 + "\nContent-Length: 0\n\n";
    String redirect303 = "HTTP/1.1 303 See Other\nLocation: " + url3 + "\nContent-Length: 0\n\n";
    String redirect307 = "HTTP/1.1 307 Temporary Redirect\nLocation: " + url4 + "\nContent-Length: 0\n\n";
//  String redirect308 = "HTTP/1.1 308 Permanent Redirect\nLocation: " + url5 + "\nContent-Length: 0\n\n";
    String ok200 = "HTTP/1.1 200 OK\nContent-Length:12\n\nHello World!";
    List<String> responses = Arrays.asList(redirect301, redirect302, redirect303, redirect307, ok200);

    try (TestWebServer server = new TestWebServer(false, responses, 1)) {
      new ApacheHttpTransport().createRequestFactory()
          .buildGetRequest(new GenericUrl(server.getEndpoint()))
          .setUseRawRedirectUrls(true).execute().disconnect();
      System.out.println(server.getInputRead());
    }
  }

The output is the following, and I can see that all the redirects preserved the raw URL values.

GET / HTTP/1.1
Accept-Encoding: gzip
User-Agent: Google-HTTP-Java-Client/1.33.1-SNAPSHOT (gzip)
Host: 0.0.0.0:41115
Connection: Keep-Alive
GET /?id=301&_auth_=exp=1572285389~hmac=f0a387f0 HTTP/1.1
Accept-Encoding: gzip
User-Agent: Google-HTTP-Java-Client/1.33.1-SNAPSHOT (gzip)
Host: 0.0.0.0:41115
Connection: Keep-Alive
GET /?id=302&Signature=2wYOD0a%2BDAkK%2F9lQJUOuIpYti8o%3D&Expires=1569997614 HTTP/1.1
Accept-Encoding: gzip
User-Agent: Google-HTTP-Java-Client/1.33.1-SNAPSHOT (gzip)
Host: 0.0.0.0:41115
Connection: Keep-Alive
GET /?id=303&_auth_=exp=1572285389~hmac=f0a387f0 HTTP/1.1
Accept-Encoding: gzip
User-Agent: Google-HTTP-Java-Client/1.33.1-SNAPSHOT (gzip)
Host: 0.0.0.0:41115
Connection: Keep-Alive
GET /?id=307&Signature=2wYOD0a%2BDAkK%2F9lQJUOuIpYti8o%3D&Expires=1569997614 HTTP/1.1
Accept-Encoding: gzip
User-Agent: Google-HTTP-Java-Client/1.33.1-SNAPSHOT (gzip)
Host: 0.0.0.0:41115
Connection: Keep-Alive

I also added a basically same test on Jib, and it also works the same way as expected. So, at least this seems to work end-to-end.

(I noticed 308 Permanent Redirect isn't automatically redirected, and this may be a bug. Filed #873.)

@iocanel however, I haven't tested Jib against actual OpenShift and Quay servers.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chanseokoh chanseokoh mentioned this pull request Nov 1, 2019
setFollowRedirects(true) does not follow 308 (Permanent Redirect) #873
Closed
@iocanel

iocanel commented Nov 4, 2019

Copy link
Copy Markdown
Contributor Author

@chanseokoh: Thanks! If you have a branch of jib working with this PR, I could possilby use it and test it against Openshift and Quay.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chanseokoh

chanseokoh commented Nov 4, 2019 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

@iocanel the branch is already there. Check this out: #871 (comment)

(The comment that I linked is hidden somewhere in our PR conversation history above.)

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

chanseokoh
chanseokoh reviewed Nov 4, 2019
View reviewed changes

@chanseokoh chanseokoh left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @iocanel, a few things to fix.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread google-http-client/src/main/java/com/google/api/client/http/GenericUrl.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-http-client/src/main/java/com/google/api/client/http/GenericUrl.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-http-client/src/main/java/com/google/api/client/http/HttpRequest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-http-client/src/main/java/com/google/api/client/http/HttpRequest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-http-client/src/main/java/com/google/api/client/http/HttpRequest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@chanseokoh

This comment has been minimized.

Sign in to view
@iocanel

iocanel commented Nov 6, 2019

Copy link
Copy Markdown
Contributor Author

@iocanel I think this is working. Have you had a chance to test this against OpenShift and Quay from Jib?

Tried the fix against registry.redhat.io and it seems that it works fine.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chanseokoh

chanseokoh commented Nov 6, 2019

Copy link
Copy Markdown
Contributor

Thanks for verifying that. The code changes make sense to me and I think it works.

@yoshi-java @chingor13 please review this.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@elharo elharo added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 6, 2019
@kokoro-team kokoro-team removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Nov 6, 2019
elharo
elharo reviewed Nov 6, 2019
View reviewed changes
Comment thread google-http-client/src/main/java/com/google/api/client/http/GenericUrl.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-http-client/src/main/java/com/google/api/client/http/GenericUrl.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-http-client/src/main/java/com/google/api/client/http/GenericUrl.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-http-client/src/main/java/com/google/api/client/http/GenericUrl.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-http-client/src/main/java/com/google/api/client/http/GenericUrl.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-http-client/src/main/java/com/google/api/client/http/GenericUrl.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-http-client/src/main/java/com/google/api/client/http/GenericUrl.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-http-client/src/main/java/com/google/api/client/http/HttpRequest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-http-client/src/main/java/com/google/api/client/http/UrlEncodedParser.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-http-client/src/main/java/com/google/api/client/http/UrlEncodedParser.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

chanseokoh
chanseokoh reviewed Nov 6, 2019
View reviewed changes
Comment thread google-http-client/src/main/java/com/google/api/client/http/HttpRequest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

Comment thread google-http-client/src/main/java/com/google/api/client/http/HttpRequest.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@chanseokoh

This comment has been minimized.

Sign in to view
@chanseokoh chanseokoh added the kokoro:run Add this label to force Kokoro to re-run the tests. label Nov 11, 2019
@chanseokoh chanseokoh changed the title fix (#864): Redirect location is now passed verbatim. feat: add option to pass redirect Location: header value as-is without encoding, decoding, or escaping Nov 11, 2019
@kokoro-team kokoro-team removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Nov 11, 2019
@chanseokoh
chanseokoh dismissed elharo’s stale review November 11, 2019 21:12

dismissing initial stale review

@chanseokoh chanseokoh added the kokoro:run Add this label to force Kokoro to re-run the tests. label Nov 12, 2019
@kokoro-team kokoro-team removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Nov 12, 2019
@iocanel

iocanel commented Nov 12, 2019

Copy link
Copy Markdown
Contributor Author

I think that all points have been covered.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

iocanel added 2 commits November 12, 2019 17:39
@iocanel
fix (#864): Redirect location is now passed verbatim.
81a8701
@iocanel
test: Add test case to test passing a url to GenericUrl verbatim.
f6eda75
@chanseokoh chanseokoh added the kokoro:run Add this label to force Kokoro to re-run the tests. label Nov 12, 2019
@kokoro-team kokoro-team removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Nov 12, 2019
chanseokoh
chanseokoh reviewed Nov 12, 2019
View reviewed changes
Comment thread google-http-client/src/main/java/com/google/api/client/http/GenericUrl.java Resolved

Uh oh!

There was an error while loading. Please reload this page.

@iocanel @chanseokoh
Update google-http-client/src/main/java/com/google/api/client/http/Ge…
762c673
…nericUrl.java

Co-Authored-By: Chanseok Oh <[email protected]>
@chanseokoh chanseokoh added the kokoro:run Add this label to force Kokoro to re-run the tests. label Nov 12, 2019
@kokoro-team kokoro-team removed the kokoro:run Add this label to force Kokoro to re-run the tests. label Nov 12, 2019
chanseokoh
chanseokoh approved these changes Nov 12, 2019
View reviewed changes
@chanseokoh

chanseokoh commented Nov 14, 2019

Copy link
Copy Markdown
Contributor

@chingor13 @codyoss friendly ping. I'd like to get this moving.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iocanel iocanel mentioned this pull request Nov 20, 2019
Fails to pull image from registry - registry.redhat.io GoogleContainerTools/jib#2106
Closed
@chanseokoh

chanseokoh commented Nov 20, 2019

Copy link
Copy Markdown
Contributor

@chingor13 @codyoss @Yoshi-Java can we aim for having this fix for the next release? This is pretty significant stuff for us.

cmoulliard, geoand, and aureamunoz reacted with thumbs up emoji
All reactions
  • 👍 3 reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

codyoss
codyoss approved these changes Nov 20, 2019
View reviewed changes
@codyoss
codyoss merged commit 2c4f49e into googleapis:master Nov 20, 2019
@codyoss

codyoss commented Nov 20, 2019

Copy link
Copy Markdown
Member

LGMT, thanks for all of your iterations on this.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@iocanel

iocanel commented Dec 17, 2019

Copy link
Copy Markdown
Contributor Author

@chanseokoh any idea on when this PR is going to be part of a release?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@chanseokoh

chanseokoh commented Dec 17, 2019

Copy link
Copy Markdown
Contributor

I think this will be in the next release. But I don't know when they will make a release. @codyoss?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@codyoss

codyoss commented Dec 17, 2019

Copy link
Copy Markdown
Member

I am going to try to get a couple more things in this release. But if they are not going to land I will make a note to try to cut a release tomorrow regardless. @chanseokoh @iocanel

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

clundin25 pushed a commit to clundin25/google-http-java-client that referenced this pull request Aug 11, 2022
@suztomo
fix: downgrading nexus staging plugin 1.6.8 (googleapis#871)
e87224c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@codyoss codyoss codyoss approved these changes
+2 more reviewers
@elharo elharo elharo left review comments
@chanseokoh chanseokoh chanseokoh approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Option to use "Location:" header value verbatim for redirection

Uh oh!

There was an error while loading. Please reload this page.

6 participants

@iocanel @googlebot @chanseokoh @codyoss @elharo @kokoro-team
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.