Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/daadu/http_plus
package:http compatible client that can speak HTTP/2, maintain connections and fallback to HTTP/1.1.
https://github.com/daadu/http_plus
dart dart2 flutter http http-client http2 http2-client
Last synced: 20 days ago
JSON representation
package:http compatible client that can speak HTTP/2, maintain connections and fallback to HTTP/1.1.
- Host: GitHub
- URL: https://github.com/daadu/http_plus
- Owner: daadu
- License: mit
- Created: 2022-02-25T07:48:06.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2023-06-14T05:55:44.000Z (over 1 year ago)
- Last Synced: 2024-10-18T07:36:29.678Z (about 1 month ago)
- Topics: dart, dart2, flutter, http, http-client, http2, http2-client
- Language: Dart
- Homepage: https://pub.dev/packages/http_plus
- Size: 50.8 KB
- Stars: 10
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# http_plus
`http_plus` is a drop-in replacement for [`http`](https://pub.dev/packages/http) with `HTTP/2`
goodies! Under the hood, it wraps [http2](https://pub.dev/packages/http2) to make it compatible with
APIs of `http`. Additionally, it fallbacks to `HTTP/1.1` if H2 is not supported by the server.> **CREDIT:** This is a fork of [`http2_client`](https://pub.dev/packages/http2_client) package, which is no longer maintained.
This package is in active development.
***Any contribution, idea, criticism or feedback is welcomed.***## Quick links
| | |
| ----------------- | ------------------------------------------------|
| **Package** | https://pub.dev/packages/http_plus |
| **API Docs** | https://pub.dev/documentation/http_plus/latest/ |
| **Git Repo** | https://github.com/daadu/http_plus |
| **Issue Tracker** | https://github.com/daadu/http_plus/issues |## Using
The easiest way to use this library is via the top-level functions. They allow you to make
individual HTTP requests with minimal hassle:```dart
import 'package:http_plus/http_plus.dart' as http;void main() async {
final url = Uri.https('example.com', '/whatsit/create');
final body = {'name': 'doodle', 'color': 'blue'};
// Await http post request
final response = await http.post(url, body: body);
print('Response status: ${response.statusCode}');
print('Response body: ${response.body}');
// Close all open connection - if not required
http.closeAllConnections();
}
```> For more detail on it check API docs of [top-level functions](https://pub.dev/documentation/http_plus/latest/http_plus/http_plus-library.html#functions).
Underneath it uses a default client with `maxOpenConnection` set as `8`, this client is re-used
among all top-level functions. If you want to have more fine-control over the client, then you can
define a custom `HttpPlusClient`:```dart
import 'package:http_plus/http_plus.dart';void main() async {
final client = HttpPlusClient(
enableHttp2: true,
context: SecurityContext(withTrustedRoots: true),
badCertificateCallback: (cert, host, port) => false,
connectionTimeout: Duration(seconds: 15),
autoUncompress: true,
maintainOpenConnections: true,
maxOpenConnections: -1,
enableLogging: false,
);final url = Uri.https('example.com', '/whatsit/create');
final body = {'name': 'doodle', 'color': 'blue'};
// Await http post request
final response = await client.post(url, body: body);
print('Response status: ${response.statusCode}');
print('Response body: ${response.body}');
// Close all open connection
client.close();
}
```> For more details on it check API docs of [`HttpPlusClient`](https://pub.dev/documentation/http_plus/latest/http_plus/HttpPlusClient-class.html).
## Todo
- Web platform support (use `BrowserClient` directly)
- Automatic testing
- Handle HTTP/2 server side push
- API for basic stats for each request - HTTP/2 vs 1.1, Connection Reuse vs New, etc
- Allow user to customize logic for connection re-cycling
- API to close connection to particular socket
- Live web demo## Contribute
Check the [Todo](#todo) section above, before you begin with any contribution.
1. You'll need a GitHub account.
2. Fork the [repository](https://github.com/daadu/http_plus).
3. Pick an issue to work on from [issue tracker](https://github.com/daadu/http_plus/issues).
4. Implement it.
5. Add your name and email in `authors` section in `pubspec.yaml` file.
6. Send merge request.
7. Star this project.
8. Become a hero!!## Features and bugs
Please file feature requests and bugs at
the [issue tracker](https://github.com/daadu/http_plus/issues).## Contributors ✨
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
Harsh Bhikadia
💻 🤔
Luka S
💻
busslina
💻
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors)
specification. Contributions of any kind welcome!