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

Optional port in authority pseudoheader #11928

Open
moscicky opened this issue Jun 18, 2024 · 3 comments
Open

Optional port in authority pseudoheader #11928

moscicky opened this issue Jun 18, 2024 · 3 comments
Assignees
Labels

Comments

@moscicky
Copy link

Jetty Version
12

Jetty Environment
core

Java Version
17

Question
I am testing out an option to set a custom authority pseudo header with Jetty http2 client as described in separate question. I am attempting to set :authority to foo.bar, however the resulting pseudohader is :authority foo.bar:80 (the port is included).

The reason seems to be that HttpRequest used internally uses default port for scheme when not specified:

Per HTTP2 RFC section 8.3.1 which points to URI RFC section 3.2 it seems that port should be optional for authority. Jetty client however sets it forcefully.

The only way I found to remove the port from the pseudoheader is to use a URI with unknown scheme such as baz://foo.bar which has no default port and thus port is not included in the pseudohader. This however causes the internal URI to be invalid, e.g. calling the methods of org.eclipse.jetty.client#Result such as result.getRequest().getURI() throws

java.lang.IllegalArgumentException: port out of range:-1

My question is: is there a legit way to omit the port from authority pseudoheader?

@janbartel
Copy link
Contributor

@lorban any insight on this?

@joakime
Copy link
Contributor

joakime commented Jul 10, 2024

The authority port was worked on in #11488 in Jetty 12.0.9
Are you using the latest version of Jetty 12?

@sbordet
Copy link
Contributor

sbordet commented Jul 11, 2024

@moscicky it's not entirely clear to me what you are trying to do.

Can you detail why you want to set a "custom" authority?
In your original question in #11923, it was shown how to send a request through the destination (which should be a special case), but probably your question was better answered by sending the request through a forward proxy.

You mention in this issue you are using the HTTP/2 client (implying the low-level HTTP2Client class), but then reference classes and methods of the high-level HttpClient.

If you're trying to send a request to foo.com through a forward proxy at localhost:5000, then you should configure HttpClient with an HttpProxy (the forward proxy).

If the server at localhost:5000 is foo.com but for some reason you don't have proper DNS resolution, then use the "send-through-destination" solution detailed in #11923.

The fix for #11488 should get rid of the port.

If you still see the port, we need an exact reproducer of what you are doing, so that it's clear what you're trying to do.

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

4 participants