-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8361060: Keep track of the origin server against which a jdk.internal.net.http.HttpConnection was constructed #26041
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
base: master
Are you sure you want to change the base?
Conversation
….net.http.HttpConnection was constructed
👋 Welcome back jpai! A progress list of the required criteria for merging this PR into |
@jaikiran This change is no longer ready for integration - check the PR body for details. |
Webrevs
|
HttpClientImpl client, | ||
String[] alpn, | ||
String label) { | ||
super(addr, client, Utils.getServerName(addr), addr.getPort(), alpn, label); | ||
plainConnection = new PlainHttpConnection(addr, client, label); | ||
super(originServer, addr, client, Utils.getServerName(addr), addr.getPort(), alpn, label); |
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.
Do we still need Utils.getServerName(addr), addr.getPort(), now that we have originServer? Or in other words - should we base these calls on the addr
parameter or on the originServer
parameters?
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 had a look at it and you are right - with the introduction of this Origin
construct, it should now be possible (and in fact prefered) to use it for constructing the SNI names. I updated this code to use the Origin
instance.
While doing that, the change caused a test failure which exposed one detail that I hadn't considered. java.net.URI.getHost()
is specified to return a IPv6 address enclosed in square brackets. The Origin
class hadn't considered that previously. It's now been updated to strip the square brackets when constructing the host value. This will allow the Origin.host()
to be used in places where it was/is being used as a host that might be returned from a InetAddress
. Local testing with this change now passes all the tests. I'll now trigger tier testing in our CI.
HttpClientImpl client, | ||
String[] alpn, | ||
InetSocketAddress proxy, | ||
ProxyHeaders proxyHeaders, | ||
String label) | ||
{ | ||
super(addr, client, Utils.getServerName(addr), addr.getPort(), alpn, label); | ||
this.plainConnection = new PlainTunnelingConnection(addr, proxy, client, proxyHeaders, label); | ||
super(originServer, addr, client, Utils.getServerName(addr), addr.getPort(), alpn, label); |
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.
Same question
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.
Updated to use the Origin
instance.
} | ||
return host + ":" + port; | ||
} | ||
} |
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.
Missing newline.
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.
Fixed
public record Origin(String scheme, String host, int port) { | ||
public Origin { | ||
Objects.requireNonNull(scheme); | ||
Objects.requireNonNull(host); | ||
if (port <= 0) { | ||
throw new IllegalArgumentException("Invalid port"); | ||
} | ||
} |
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.
Should we enforce lower case for scheme and host in this constructor?
For instance - convert to lower case if needed in from(URI)
and throw/assert here if not lower case?
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.
We only support http
and https
. So I think it makes sense to convert it to lower case and expect the scheme to be either of these. I've updated the PR accordingly.
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.
Looks good. I wonder if we should lower case the host returned by getHost() too (when not a literal address).
Done. The PR has been updated with this change. tier1, tier2 and tier3 test pass with this change. Given the kind of code we added in this |
I've updated the PR to include a test for the |
Can I please get a review of this change which updates the
jdk.internal.net.http.HttpConnection
to keep track of the origin server for which theHttpConnection
was constructed? This addresses https://bugs.openjdk.org/browse/JDK-8361060.This is an internal implementation change which will allow other parts of the JDK's HttpClient implementation to use the origin server information. An example of such usage is the alternate services that are going to be supported in the JDK's HttpClient upcoming implementation for HTTP/3.
No new tests have been introduced and existing tests in tier1, tier2 and tier3 continue to pass.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/26041/head:pull/26041
$ git checkout pull/26041
Update a local copy of the PR:
$ git checkout pull/26041
$ git pull https://git.openjdk.org/jdk.git pull/26041/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 26041
View PR using the GUI difftool:
$ git pr show -t 26041
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/26041.diff
Using Webrev
Link to Webrev Comment