Ich verwende in meinem Android App OkHttp3 zu HTTP/1.x Anfragen an meine Backend-Server über einen Forward-Proxy, wie so zu machen:Unterstützt OkHttp3 HTTP2 über einen HTTP-Forward-Proxy?
List<Protocol> protos = new ArrayList<>();
protos.add(Protocol.HTTP_2);
protos.add(Protocol.HTTP_1_1);
InetSocketAddress proxyAddr = new InetSocketAddress("proxy.example.com", 80);
Proxy proxy = new Proxy(Proxy.Type.HTTP, proxyAddr);
OkHttpClient cli = new OkHttpClient.Builder()
.proxy(proxy)
.protocols(protos)
.build();
String url = "http://www.example.com/";
Request req = new Request.Builder().url(url).build();
Response res = cli.newCall(req).execute();
Ich möchte ein Upgrade auf HTTP2. Es scheint mir jedoch, dass OkHttp3 HTTP2-Anfragen nur stellen kann, wenn wir nicht über einen HTTP-Proxy gehen. Also, der obige Code würde nicht funktionieren.
Mit anderen Worten, OkHttp3 unterstützt die ersten 3 Fälle, aber nicht die vierte. HTTP/2 unten bedeutet h2 (HTTP/2 über TLS) nicht h2c (HTTP/2 über Klartext).
a) Client < - HTTP/1.x -> Upstream-Server
b) -Client < - HTTP/1.x -> Forward-Proxy < - HTTP/x -> Upstream Server
c) -Client < - HTTP/2 -> Upstream-Server
d) -Client < - HTTP/2 -> Forward-Proxy < - HTTP/x -> Upstream-Server
Hat jemand co nfirm oder verleugne mein Verständnis? Vielen Dank.
Jesse, ich bin ein SO-Neuling und ich habe eine Follow-up-Frage, die ich in einem Kommentar nicht sauber ausdrücken kann - ich weiß nicht, wie. Bitte sehen Sie die nächste Antwort. – hoolam