1

Following Jetty documentation of enabling HTTP/2,

I reached till the following step,

2015-06-17 14:16:12.549:INFO:oejs.ServerConnector:main: Started ServerConnector@6f32cd1e{HTTP/1.1,[http/1.1, h2c]}{0.0.0.0:8080}

From the docs,

No major browser currently supports plain text HTTP/2, so the 8080 port will only be able to use HTTP/2 with specific clients (eg curl) that use the upgrade mechanism or assume HTTP/2.

The documentation mentions "specific clients", but what client I can use for overcoming this issue? I tried okHttp and apache-httpclient, okHttp doesn't support the upgrade mechanism (AFAIK, Would be great if it is otherwise), and apache-httpClient doesn't support h2.

I basically need to make GET/POST request from my program to this endpoint(Obviously, using HTTP/2).

To put in a simple words, Please suggest any Java client which support non-encrypted http/2 (h2c)

Thanks!

5
  • Do you nee to support HTTP/1 on this port also? Commented Sep 26, 2019 at 12:01
  • Yes...to support other services using the same endpoints Commented Sep 26, 2019 at 12:03
  • The feature in your client to support non-encrypted http/2 is called h2c, look for that. Commented Sep 26, 2019 at 12:27
  • @JoakimErdfelt I am unable to find such a client for Java. Thats the purpose of this question. You paraphrased my question in a better way Commented Sep 26, 2019 at 12:41
  • > apache-httpClient doesn't support h2: this statement is incorrect. Commented Sep 26, 2019 at 13:54

2 Answers 2

1

Apache HttpCore and HttpClient 5.0 support h2 as well as h2c but presently do not support the http/1.1 to h2c upgrade mechanism. I am not sure they ever will given it is unclear how useful this upgrade mechanism is in the first place.

For code examples please refer to

http://hc.apache.org/httpcomponents-client-5.0.x/examples-async.html

For HttpClient 4.5.x to HttpClient 5.0 upgrade guide please refer to:

https://ok2c.github.io/httpclient-migration-guide/

Sign up to request clarification or add additional context in comments.

Comments

0

The Jetty Project has a HTTP client library that can be used as HTTP client and supports HTTP/2, both clear text and encrypted.

You want to look at this documentation.

See also how the Jetty Project uses that same client for tests.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.