persist_http 0.0.1-beta
persist_http: ^0.0.1-beta copied to clipboard
This library provides an efficient way to handle HTTP requests by reusing the same HTTP handshake. It's designed for Dart environments and supports all platforms except Flutter Web due to the use of dart:io.
persist_http #
This library provides an efficient way to handle HTTP requests by reusing the same HTTP handshake. It's designed for Dart environments and supports all platforms except Flutter Web due to the use of dart:io.
Installation #
dependencies:
persist_http: ^0.0.1-beta
Example #
import 'package:flutter/foundation.dart';
import 'package:persist_http/persist_http.dart';
void main() async {
await connectionsCheck();
await multiCallWithPersistConnection();
}
Future<void> connectionsCheck() async {
var client = PresistHttp("example.com");
await client.connect();
await client.close();
}
Future<void> multiCallWithPersistConnection() async {
final persistHttp = PresistHttp('randomuser.me');
await persistHttp.connect();
for (var i = 0; i < 10; i++) {
final response = await persistHttp.get('/api');
debugPrint(response);
}
await persistHttp.close();
}