Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare to publish package:cronet_http as 1.0.0 #1087

Merged
merged 2 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions pkgs/cronet_http/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.0.0

* No functional changes.

## 0.4.2

* Require `package:jni >= 0.7.2` to remove a potential buffer overflow.
Expand Down
80 changes: 55 additions & 25 deletions pkgs/cronet_http/README.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,61 @@
[![pub package](https://img.shields.io/pub/v/cronet_http.svg)](https://pub.dev/packages/cronet_http)
[![package publisher](https://img.shields.io/pub/publisher/cronet_http.svg)](https://pub.dev/packages/cronet_http/publisher)

An Android Flutter plugin that provides access to the
[Cronet](https://developer.android.com/guide/topics/connectivity/cronet/reference/org/chromium/net/package-summary)
[Cronet][]
HTTP client.

Cronet is available as part of
[Google Play Services](https://developers.google.com/android/guides/overview).
[Google Play Services][].

This package depends on
[Google Play Services](https://developers.google.com/android/guides/overview)
for its Cronet implementation.
This package depends on [Google Play Services][] for its [Cronet][]
implementation.
[`package:cronet_http_embedded`](https://pub.dev/packages/cronet_http_embedded)
is functionally identical to this package but embeds Cronet directly instead
of relying on
[Google Play Services](https://developers.google.com/android/guides/overview).

## Status: Experimental

**NOTE**: This package is currently experimental and published under the
[labs.dart.dev](https://dart.dev/dart-team-packages) pub publisher in order to
solicit feedback.

For packages in the labs.dart.dev publisher we generally plan to either graduate
the package into a supported publisher (dart.dev, tools.dart.dev) after a period
of feedback and iteration, or discontinue the package. These packages have a
much higher expected rate of API and breaking changes.

Your feedback is valuable and will help us evolve this package.
For general feedback and suggestions please comment in the
[feedback issue](https://github.com/dart-lang/http/issues/764).
For bugs, please file an issue in the
[bug tracker](https://github.com/dart-lang/http/issues).
is functionally identical to this package but embeds [Cronet][] directly
instead of relying on [Google Play Services][].

## Motivation

Using [Cronet][], rather than the socket-based [dart:io HttpClient][]
implemententation, has several advantages:

1. It automatically supports Android platform features such as HTTP proxies.
2. It supports configurable caching.
3. It supports more HTTP features such as HTTP/3.

## Using

The easiest way to use this library is via the the high-level interface
defined by [package:http Client][].

This approach allows the same HTTP code to be used on all platforms, while
still allowing platform-specific setup.

```dart
import 'package:cronet_http/cronet_http.dart';
import 'package:http/http.dart';
import 'package:http/io_client.dart';

void main() async {
late Client httpClient;
if (Platform.isAndroid) {
final engine = CronetEngine.build(
cacheMode: CacheMode.memory,
cacheMaxSize: 2 * 1024 * 1024,
userAgent: 'Book Agent');
httpClient = CronetClient.fromCronetEngine(engine);
} else {
httpClient = IOClient(HttpClient()..userAgent = 'Book Agent');
}

final response = await client.get(Uri.https(
'www.googleapis.com',
'/books/v1/volumes',
{'q': 'HTTP', 'maxResults': '40', 'printType': 'books'}));
}
```

[Cronet]: https://developer.android.com/guide/topics/connectivity/cronet/reference/org/chromium/net/package-summary
[dart:io HttpClient]: https://api.dart.dev/stable/dart-io/HttpClient-class.html
[Google Play Services]: https://developers.google.com/android/guides/overview
[package:http Client]: https://pub.dev/documentation/http/latest/http/Client-class.html
2 changes: 1 addition & 1 deletion pkgs/cronet_http/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: cronet_http
version: 0.4.2
version: 1.0.0
description: >-
An Android Flutter plugin that provides access to the Cronet HTTP client.
repository: https://github.com/dart-lang/http/tree/master/pkgs/cronet_http
Expand Down