How does okhttp3 send http2 requests?

question background:
recently I want to use springboot2.0 to build a server that supports http2.0. After setting up, through Chrome access, it shows that the version of http protocol is H2 (the server has been upgraded successfully and the certificate has been configured successfully).
clipboard.png

okhttp3http2.0responseprotocolhttp1.1

:
1.springboot:
clipboard.png

2.EchoController:ECHO
clipboard.png

3.:


:
clipboard.png
response:
Response{protocol=http/1.1, code=200, message=OK, url=https://localhost:8080/echo}

clipboard.png

build request:
ConnectionUpgrade HTTP/1.1 . HTTP/2 h2c, HTTP/2 ClearText.


:
ECHO!!
HTTP_1_1


@Feng_YuStackOverflowbuild okHttpClienth2


http1.1debugclientbuildh2
clipboard.png

I can"t handle it. I"ll give you some advice on how to make it. Let him fall in the ice. No, no, no.
you can also give some advice from all kinds of gods!


https://stackoverflow.com/que.


jdk1.7,1.8 natively does not support the request that http2.0,okhttp can send 2.0 requests. Your code will be fine after modification, but you need to introduce alpn-boot jar package cooperation to simulate http2.0

.
Menu