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

Correctly handle IPV6 in HttpProxyHandler #6195

Closed
wants to merge 1 commit into from
Closed

Conversation

normanmaurer
Copy link
Member

Motivation:

The HttpProxyHandler is expected to be capable of issuing a valid CONNECT request for a tunneled connection to an IPv6 host.

Modifications:

  • Correctly format the IPV6 address.
  • Add unit tests

Result:

HttpProxyHandler works with IPV6 as well. Fixes [#6152].

@normanmaurer normanmaurer self-assigned this Jan 10, 2017
@normanmaurer normanmaurer added this to the 4.1.7.Final milestone Jan 10, 2017
@normanmaurer
Copy link
Member Author

@ZuluForce PTAL as well

@ZuluForce
Copy link

@normanmaurer LGTM Thanks for taking this on.

Copy link
Member

@Scottmitch Scottmitch left a comment

Choose a reason for hiding this comment

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

Can you add a test case to HttpProxyHandlerTest which verifies that IPv6 compression is done correctly?

InetAddress address = addr.getAddress();
rhost = address instanceof Inet4Address ? toAddressString(address) : '[' + toAddressString(address) + ']';
}
return rhost + ':' + addr.getPort();
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if it would should be more explicit about the string concatenation operations used here. For example it seems unlikely JIT will be able to combine all of these conditional concatenation operations into a single StringBuilder. Can we create a single StringBuilder and manually do the append calls (e.g. including what is now building rhost) to be sure we don't create multiple String/StringBuilder operations?

Copy link
Member

@nmittler nmittler left a comment

Choose a reason for hiding this comment

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

LGTM ... just address the comment from @Scottmitch

Copy link
Member

@Scottmitch Scottmitch left a comment

Choose a reason for hiding this comment

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

few small comments and lgtm


private static StringBuilder newSocketAddressStringBuilder(String hostString, String port, boolean ipv4) {
if (ipv4) {
// Need to include enought space for hostString:port .
Copy link
Member

Choose a reason for hiding this comment

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

enought -> enough

Copy link
Member

Choose a reason for hiding this comment

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

also remove the space before the period?

Copy link
Member Author

Choose a reason for hiding this comment

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

I added the space before to make it clear it is not part of it... But I guess its ok to remove it as well.

// Need to include enought space for hostString:port .
return new StringBuilder(hostString.length() + 1 + port.length()).append(hostString);
} else {
// Need to include enought space for [hostString]:port .
Copy link
Member

Choose a reason for hiding this comment

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

enought -> enough

also remove the space before the period?

if (ipv4) {
// Need to include enought space for hostString:port .
return new StringBuilder(hostString.length() + 1 + port.length()).append(hostString);
} else {
Copy link
Member

Choose a reason for hiding this comment

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

nit: no need for else

Motivation:

The HttpProxyHandler is expected to be capable of issuing a valid CONNECT request for a tunneled connection to an IPv6 host.

Modifications:

- Correctly format the IPV6 address.
- Add unit tests

Result:

HttpProxyHandler works with IPV6 as well. Fixes [#6152].
@normanmaurer
Copy link
Member Author

Cherry-picked into 4.1 (eb5dc4b)

@normanmaurer normanmaurer deleted the http_proxy branch January 12, 2017 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants