

Both are small libraries with strong backward-compatibility. OkHttp depends on Okio for high-performance I/O and the Kotlin standard library. OkHttp works on Android 5.0+ (API level 21+) and Java 8+. get ( "application/json charset=utf-8" ) OkHttpClient client = new OkHttpClient () String post ( String url, String json ) throws IOException įurther examples are on the OkHttp Recipes page. Public static final MediaType JSON = MediaType. This program downloads a URL and prints its contents as a string.

Supports both synchronous blocking calls and async calls with callbacks. Its request/response API is designed with fluent builders and immutability. It can beĬonfigured to fall back for broad connectivity. OkHttp supports modern TLS features (TLS 1.3, ALPN, certificate pinning). This is necessary for IPv4+IPv6 and services hosted in redundant dataĬenters. If your service has multiple IP addresses, OkHttp will attempt alternate addresses if theįirst connect fails. OkHttp perseveres when the network is troublesome: it will silently recover from common connection

