Skip to content

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.

License

Notifications You must be signed in to change notification settings

JAYDARANIYA/persist_http

Repository files navigation

persist_http

pub License: MIT Github issues contributions welcome

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();
}

About

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.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages