OkHttpUtils2 source code: [B4X] OkHttpUtils2 / iHttpUtils2 / HttpUtils2 source code
It is included as an internal library.
Usage: [B4X] OkHttpUtils2 with Wait For
The current Http library is based on the Android version of Apache HttpClient. Google has stopped updating this SDK a long time ago and they are removing it from Android M. This means that it is a good time now to switch to a different implementation.
Note that if you are using HttpUtils2 (as you should) it is also based on Http library.
The OkHttp library is based on the OkHttp SDK: http://square.github.io/okhttp/
As this is a newer SDK it supports new features such as SSL SNI, SPDY, Patch requests and better performance.
The OkHttp wrapper API is almost identical to Http library API. The main difference is that the object names start with Ok (OkHttpClient, OkHttpResponse and OkHttpRequest).
This library requires Android 2.3+.
Attached is a modified version of HttpUtils2 library (v2.12) that is based on OkHttp instead of Http.
If you want to use the new HttpUtils2 library you need to copy it to the internal libraries folder.
V1.01 - Compatible with B4J.
V1.00 - Adds support for digest authentication.
OkHttpUtils2 v2.20 is attached. It adds support for multipart requests.
Example:
OkHttp and OkHttpUtils2 libraries are included in the IDE.
It is included as an internal library.
Usage: [B4X] OkHttpUtils2 with Wait For
The current Http library is based on the Android version of Apache HttpClient. Google has stopped updating this SDK a long time ago and they are removing it from Android M. This means that it is a good time now to switch to a different implementation.
Note that if you are using HttpUtils2 (as you should) it is also based on Http library.
The OkHttp library is based on the OkHttp SDK: http://square.github.io/okhttp/
As this is a newer SDK it supports new features such as SSL SNI, SPDY, Patch requests and better performance.
The OkHttp wrapper API is almost identical to Http library API. The main difference is that the object names start with Ok (OkHttpClient, OkHttpResponse and OkHttpRequest).
This library requires Android 2.3+.
Attached is a modified version of HttpUtils2 library (v2.12) that is based on OkHttp instead of Http.
If you want to use the new HttpUtils2 library you need to copy it to the internal libraries folder.
V1.01 - Compatible with B4J.
V1.00 - Adds support for digest authentication.
OkHttpUtils2 v2.20 is attached. It adds support for multipart requests.
Example:
B4X:
Dim j As HttpJob
j.Initialize("j", Me)
Dim fd As MultipartFileData
fd.Initialize
fd.KeyName = "file"
fd.Dir = File.DirAssets
fd.FileName = "image.png"
fd.ContentType = "image/png"
j.PostMultipart("http://...", CreateMap("param1": "value1"), Array(fd))
OkHttp and OkHttpUtils2 libraries are included in the IDE.
Last edited: