Mohamed Anees A
Mohamed Anees A

Reputation: 4601

Enabling HTTP/2 on the plain text connector

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!

Upvotes: 1

Views: 1859

Answers (2)

ok2c
ok2c

Reputation: 27613

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/

Upvotes: 1

sbordet
sbordet

Reputation: 18637

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.

Upvotes: 0

Related Questions