Commits
Tarun Sukhani authored bbf1319a73d
refactor(ws): migrate WSAsync from JDK HttpClient to OkHttp 5 (PF-104) The framework's outbound WS API now sits on OkHttp 5.3.2 instead of java.net.http.HttpClient. Two reasons drove this: 1. h2c upgrade hang. The JDK client sends `Upgrade: h2c` on cleartext HTTP to advertise HTTP/2 willingness. Servers that echo the header without actually delivering the upgrade preface (notably LM Studio's Express front-end) wedge the JDK client until the request timeout fires. OkHttp does not send the upgrade on cleartext, so this failure mode is structurally absent. 2. Virtual-thread cleanliness. Okio 3's read path has no synchronized blocks, so an OkHttpClient.Dispatcher backed by Executors.newVirtualThreadPerTaskExecutor() lets blocking socket reads unmount during the read. The JDK client only got the same property via AsynchronousSocketChannel. The public WS surface (`WS.url(...).get()`, `WSRequest`, `HttpResponse`) is unchanged. Internals: - Two shared OkHttpClient instances (follow-redirects on/off) over one ConnectionPool (32 idle / 5min keep-alive) and one Dispatcher (VT executor). - Per-call timeout is applied via newBuilder().callTimeout(...) so the shared client stays unmodified. - Proxy auth migrated to okhttp3.Authenticator (Proxy-Authorization on 407). - ssl.keyStore / ssl.cavalidation=false still respected via OkHttp's sslSocketFactory() + hostnameVerifier(). - BodyPublishers -> RequestBody; InputStream bodies wrapped in a one-shot RequestBody backed by okio.Source. - HttpJdkResponse renamed to HttpAsyncResponse (no external callers). - Response body is read eagerly into a byte[] inside the constructor with try-with-resources on the Response, matching the prior eager-bytes semantics and avoiding leaked connections. Dependency changes (transitiveDependencies: false means everything is declared explicitly): - com.squareup.okhttp3:okhttp:5.3.2 (alias pom, 767-byte jar) - com.squareup.okhttp3:okhttp-jvm:5.3.2 (actual bytecode) - com.squareup.okhttp3:okhttp-sse:5.3.2 - com.squareup.okio:okio:3.16.4 (alias) - com.squareup.okio:okio-jvm:3.16.4 (actual bytecode) - org.jetbrains.kotlin:kotlin-stdlib:2.2.21 Documentation: libs.textile claimed WS used the long-removed Async HTTP Client. Updated to reflect OkHttp 5 + virtual-thread dispatcher. Verified: `ant test` (clean + jar + unittest + integration-test) green. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>