JanPRO Well-Known Member Licensed User Longtime User Jan 11, 2019 #1 Hi, Erel said: Http/2 is supported by OkHttp. Click to expand... However, when I request the following test api: https://http2.pro/api/v1 I get the result, that HTTP/2 is not supported. So my question now, does the latest B4J OkHttp library really support HTTP/2? Jan
Hi, Erel said: Http/2 is supported by OkHttp. Click to expand... However, when I request the following test api: https://http2.pro/api/v1 I get the result, that HTTP/2 is not supported. So my question now, does the latest B4J OkHttp library really support HTTP/2? Jan
JanPRO Well-Known Member Licensed User Longtime User Jan 12, 2019 #3 Hi, it's just a simple Get request: Code: Copy Sub TestHttp2 Dim H As HttpJob H.Initialize("",Me) H.Download("https://http2.pro/api/v1") Wait For (H) JobDone(J As HttpJob) Log(J.GetString) End Sub Jan Upvote 0
Hi, it's just a simple Get request: Code: Copy Sub TestHttp2 Dim H As HttpJob H.Initialize("",Me) H.Download("https://http2.pro/api/v1") Wait For (H) JobDone(J As HttpJob) Log(J.GetString) End Sub Jan
I inakigarm Well-Known Member Licensed User Longtime User Jan 12, 2019 #4 JanPRO said: Hi, it's just a simple Get request: Code: Copy Sub TestHttp2 Dim H As HttpJob H.Initialize("",Me) H.Download("https://http2.pro/api/v1") Wait For (H) JobDone(J As HttpJob) Log(J.GetString) End Sub Jan Click to expand... You'll have to use http source class modules ("HttpJob.bas" "HttpUtils2Service.bas") not the jokhttputils library () and in the "HttpUtils2Service.bas" change the hc initialization to Code: Copy hc.InitializeAcceptAll("hc") (source modules: https://www.b4x.com/android/forum/t...putils2-httputils2-source-code.82632/#content hc.InitializeAcceptAll skips the certificate verification step With that, this is the result: Code: Copy Dim H As HttpJob H.Initialize("",Me) H.Download("https://http2.pro/api/v1") Wait For (H) JobDone(J As HttpJob) If J.Success Then Log(J.GetString) Else Log(J.ErrorMessage) End If {"http2":0,"protocol":"HTTP\/1.1","push":0,"user_agent":"okhttp\/3.5.0"} See also: https://www.b4x.com/android/forum/t...liente-to-server-using-ssl.94727/#post-599293 Upvote 0
JanPRO said: Hi, it's just a simple Get request: Code: Copy Sub TestHttp2 Dim H As HttpJob H.Initialize("",Me) H.Download("https://http2.pro/api/v1") Wait For (H) JobDone(J As HttpJob) Log(J.GetString) End Sub Jan Click to expand... You'll have to use http source class modules ("HttpJob.bas" "HttpUtils2Service.bas") not the jokhttputils library () and in the "HttpUtils2Service.bas" change the hc initialization to Code: Copy hc.InitializeAcceptAll("hc") (source modules: https://www.b4x.com/android/forum/t...putils2-httputils2-source-code.82632/#content hc.InitializeAcceptAll skips the certificate verification step With that, this is the result: Code: Copy Dim H As HttpJob H.Initialize("",Me) H.Download("https://http2.pro/api/v1") Wait For (H) JobDone(J As HttpJob) If J.Success Then Log(J.GetString) Else Log(J.ErrorMessage) End If {"http2":0,"protocol":"HTTP\/1.1","push":0,"user_agent":"okhttp\/3.5.0"} See also: https://www.b4x.com/android/forum/t...liente-to-server-using-ssl.94727/#post-599293
JanPRO Well-Known Member Licensed User Longtime User Jan 12, 2019 #5 Thank you, but I don't have any problem with the SSL certificate. This question is about the protocol used by OkHttp. In your response inakigarm said: {"http2":0,"protocol":"HTTP\/1.1","push":0,"user_agent":"okhttp\/3.5.0"} Click to expand... you can see that Http 1.1 was used, when you open the Api url in a modern browser you will see that the value for http2 becomes 1. Jan Upvote 0
Thank you, but I don't have any problem with the SSL certificate. This question is about the protocol used by OkHttp. In your response inakigarm said: {"http2":0,"protocol":"HTTP\/1.1","push":0,"user_agent":"okhttp\/3.5.0"} Click to expand... you can see that Http 1.1 was used, when you open the Api url in a modern browser you will see that the value for http2 becomes 1. Jan
DonManfred Expert Licensed User Longtime User Jan 12, 2019 #6 Based on this SO. best is to use java 9 i guess. But i don´t know if that helps. Upvote 0
I inakigarm Well-Known Member Licensed User Longtime User Jan 12, 2019 #7 JanPRO said: This question is about the protocol used by OkHttp. Click to expand... Yes, I mirsread your first post ;-) Upvote 0
JanPRO said: This question is about the protocol used by OkHttp. Click to expand... Yes, I mirsread your first post ;-)
DonManfred Expert Licensed User Longtime User Jan 12, 2019 #8 I just searched for java 9 and realized that b4j can work with openjava 11 See https://www.b4x.com/b4j.html#installation I just configured my b4j (V7.0) to use the open java 11. and tried the code above Code: Copy Dim H As HttpJob H.Initialize("",Me) H.Download("https://http2.pro/api/v1") Wait For (H) JobDone(J As HttpJob) If J.Success Then Log(J.GetString) Else Log(J.ErrorMessage) End If This is the result: {"http2":1,"protocol":"HTTP\/2.0","push":1,"user_agent":"okhttp\/3.5.0"} Click to expand... As a fazit i would suggest to switch to OpenJDK 11 Last edited: Jan 12, 2019 Upvote 0
I just searched for java 9 and realized that b4j can work with openjava 11 See https://www.b4x.com/b4j.html#installation I just configured my b4j (V7.0) to use the open java 11. and tried the code above Code: Copy Dim H As HttpJob H.Initialize("",Me) H.Download("https://http2.pro/api/v1") Wait For (H) JobDone(J As HttpJob) If J.Success Then Log(J.GetString) Else Log(J.ErrorMessage) End If This is the result: {"http2":1,"protocol":"HTTP\/2.0","push":1,"user_agent":"okhttp\/3.5.0"} Click to expand... As a fazit i would suggest to switch to OpenJDK 11
JanPRO Well-Known Member Licensed User Longtime User Jan 12, 2019 #9 Awesome, thank you very much DonManfred Upvote 0