About this project

OkHttp is an HTTP client library for the JVM, Android and GraalVM. According to its README, it is designed to be efficient by default: HTTP/2 support lets requests to the same host share a socket, connection pooling reduces request latency when HTTP/2 is unavailable, transparent GZIP shrinks download sizes, and response caching avoids the network entirely for repeat requests. The library is described as resilient on unreliable networks. It silently recovers from common connection problems, and when a service has multiple IP addresses it attempts alternate addresses if the first connect fails, which the README notes is useful for IPv4+IPv6 and services in redundant data centers. It supports modern TLS features including TLS 1.3, ALPN and certificate pinning, and can be configured to fall back for broad connectivity. The API uses fluent builders and immutable request/response objects, and supports both synchronous blocking calls and asynchronous calls with callbacks. The README includes short examples for downloading a URL and posting JSON to a server, and points to a recipes page for more. OkHttp follows modern HTTP specifications, including RFC 9110 (HTTP semantics), RFC 9111 (caching), RFC 9112 (HTTP/1.1), RFC 9113 (HTTP/2), RFC 6455 (WebSockets) and the WHATWG server-sent events specification. Where specs are ambiguous, it follows the behavior of modern user agents. The README states that OkHttp deliberately avoids being overly configurable, particularly for working around buggy servers or invalid scenarios, and lists example limitations such as not allowing GET with a body and not exposing the cache as an interface with alternative implementations. Requirements: Android 5.0+ (API level 21+) and Java 8+. On Android it uses AndroidX Startup; if the initializer is disabled in the manifest, apps must call OkHttp.initialize(applicationContext) in Application.onCreate. It depends on Okio for high-performance I/O and the Kotlin standard library. The README recommends keeping OkHttp up to date as a defense against security problems, and notes that it uses the platform's built-in TLS implementation, with optional Conscrypt support on Java platforms when Conscrypt is the first security provider. A legacy 3.12.x branch supports Android 2.3+ and Java 7+, but those platforms lack TLS 1.2 and should not be used. Distribution is via Maven Central, with a bill of materials (BOM) for version alignment, R8/ProGuard rules, and snapshot builds. OkHttp is published as a Kotlin Multiplatform project; Maven projects must choose between okhttp-jvm and okhttp-android because the okhttp artifact is empty in Maven projects. OkHttp 5.2+ implements Java 9 modules, and the README lists the stable public modules, including okhttp3, okhttp3.brotli, okhttp3.coroutines, okhttp3.dnsoverhttps, okhttp3.logging, okhttp3.sse, okhttp3.tls, okhttp3.urlconnection, mockwebserver3 and its JUnit 4/5 variants. MockWebServer is included for testing HTTP, HTTPS and HTTP/2 clients. The README describes it as primarily used for internal testing and basic testing of apps using the OkHttp client, not a full-featured standalone HTTP testing library, and notes it is not actively developed for new features; users may outgrow it and consider alternatives such as MockServer. GraalVM native image builds are said to work automatically, with the okcurl module as an example. The project is licensed under Apache License 2.0, copyright Square, Inc.