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

Detection of https protocol is incorrect in Http2Curl.http2curl() #17

Closed
pafitchett-ks opened this issue Oct 9, 2017 · 3 comments
Closed
Assignees
Labels
Milestone

Comments

@pafitchett-ks
Copy link

In http2Curl() there is a block of code for detecting https protocol:

      if (host.endsWith(":443")) {
        inferredScheme = "https";
      } else if (request instanceof RequestWrapper) {
        if (getOriginalRequestUri(request).startsWith("https")) {
          // This is for original URL, so if during redirects we go out of HTTPs, this might be a wrong guess
          inferredScheme = "https";
        }
      }

This code fails if request is an instance of HttpRequestWrapper (which it will be for versions of http client >= 4.3) because HttpRequestWrapper does not itself derive from RequestWrapper and so the call to getOriginalRequestUri() is never executed.

This results in curl call output always displaying http as the protocol.

@dzieciou
Copy link
Owner

dzieciou commented Oct 9, 2017

@pafitchett-ks Thank you for your report and detailed root cause analysis.

How can I reproduce the problem?

Do you have a sample REST-assured requests that causes the failure?

@pafitchett-ks
Copy link
Author

This test, when added to UsingWithHttpClientTest.java, will demonstrate the problem:

import org.testng.Assert;
import uk.org.lidalia.slf4jtest.TestLoggerFactory;
  @Test(groups = "end-to-end-samples")
  public void testHttps() throws IOException {
    TestLoggerFactory.clearAll();
    HttpGet getRequest = new HttpGet("https://google.com");
    createHttpClient().execute(getRequest);
    Assert.assertEquals(TestLoggerFactory.getAllLoggingEvents().get(0).getMessage(),"curl 'https://google.com/' --compressed --insecure --verbose");
  }

@dzieciou
Copy link
Owner

dzieciou commented Jan 2, 2019

@pafitchett-ks Fixed in 1.0.4-SNAPSHOT. Thanks again for reporting.

@dzieciou dzieciou closed this as completed Jan 2, 2019
@dzieciou dzieciou added this to the 1.0.4 milestone Jun 29, 2019
@dzieciou dzieciou added the bug label Jun 29, 2019
@dzieciou dzieciou self-assigned this Jun 29, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants