Skip to content

feat(ok_http): shared session#1877

Open
mertalev wants to merge 5 commits intodart-lang:masterfrom
mertalev:feat/external-session-okhttp
Open

feat(ok_http): shared session#1877
mertalev wants to merge 5 commits intodart-lang:masterfrom
mertalev:feat/external-session-okhttp

Conversation

@mertalev
Copy link

@mertalev mertalev commented Feb 5, 2026

This PR allows creating a client from a JNI global reference of an existing OkHttpClient. In this way, one can share the same session across an app beyond a single isolate, which is both optimal for performance and centralizes configuration. This is notably much simpler to accomplish with ok_http than with cupertino_http.

I've tested these changes in my app and added it to the conformance test suite. I don't expect behavior to be different from a normal client given that the send implementation is the same.

Based on #1880, which should be merged first to clean up the diff.


  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
Contribution guidelines:

Many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.

Note: The Dart team is trialing Gemini Code Assist. Don't take its comments as final Dart team feedback. Use the suggestions if they're helpful; otherwise, wait for a human reviewer.

@mertalev mertalev force-pushed the feat/external-session-okhttp branch from 6808179 to fc43a0b Compare February 5, 2026 15:52
@github-actions
Copy link

github-actions bot commented Feb 6, 2026

PR Health

Coverage ⚠️
File Coverage
pkgs/ok_http/example/integration_test/client_test.dart 💔 Not covered
pkgs/ok_http/lib/src/jni/bindings.dart 💔 Not covered
pkgs/ok_http/lib/src/ok_http_client.dart 💔 Not covered
pkgs/ok_http/lib/src/ok_http_web_socket.dart 💔 Not covered

This check for test coverage is informational (issues shown here will not fail the PR).

This check can be disabled by tagging the PR with skip-coverage-check.

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?
ok_http Non-Breaking 0.1.0 0.1.1-wip 0.1.1-wip ✔️

This check can be disabled by tagging the PR with skip-breaking-check.

Unused Dependencies ⚠️
Package Status
ok_http
❗ Show Issues
These packages are used outside lib/ but are not dev_dependencies:
* flutter_test
* http_client_conformance_tests
* http_image_provider
* integration_test
* provider
* test
* web_socket_conformance_tests
These packages are only used outside lib/ and should be downgraded to dev_dependencies:
* flutter
These packages may be unused, or you may be using assets from these packages:
* dart_flutter_team_lints
* plugin_platform_interface
Failed to update packages.

For details on how to fix these, see dependency_validator.

This check can be disabled by tagging the PR with skip-unused-dependencies-check.

Changelog Entry
Package Changed Files
package:ok_http pkgs/ok_http/lib/src/jni/bindings.dart
pkgs/ok_http/lib/src/ok_http_client.dart
pkgs/ok_http/lib/src/ok_http_web_socket.dart
pkgs/ok_http/pubspec.yaml

Changes to files need to be accounted for in their respective changelogs.

This check can be disabled by tagging the PR with skip-changelog-check.

License Headers ✔️
// Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
Files
no missing headers

All source files should start with a license header.

Unrelated files missing license headers
Files
pkgs/http/example/main.dart
pkgs/http_multi_server/test/cert.dart

This check can be disabled by tagging the PR with skip-license-check.

API leaks ⚠️

The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.

Package Leaked API symbol Leaking sources
ok_http PublicKey jni/bindings.dart::Certificate::getPublicKey
jni/bindings.dart::PublicKey::nullableType
jni/bindings.dart::PublicKey::type
jni/bindings.dart::Certificate::verify::publicKey
jni/bindings.dart::Certificate::verify$1::publicKey
jni/bindings.dart::Certificate::verify$2::publicKey
jni/bindings.dart::X509Certificate::verify2::publicKey
ok_http $PublicKey jni/bindings.dart::PublicKey::implementIn::$impl
jni/bindings.dart::PublicKey::implement::$impl
ok_http $PrivateKey jni/bindings.dart::PrivateKey::implementIn::$impl
jni/bindings.dart::PrivateKey::implement::$impl

This check can be disabled by tagging the PR with skip-leaking-check.

regenerate bindings

update client

fix nullability change
handle abort
@mertalev mertalev force-pushed the feat/external-session-okhttp branch from fc43a0b to cbe2199 Compare February 16, 2026 20:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant