interceptly_http 1.2.0 copy "interceptly_http: ^1.2.0" to clipboard
interceptly_http: ^1.2.0 copied to clipboard

HTTP client wrapper for Interceptly network inspector.

interceptly_http #

pub package license

Standard http.Client wrapper adapter for the Interceptly network inspector in Flutter.

InterceptlyHttpClient intercepts all requests sent through Dart's standard package:http, accurately capturing headers, request bodies, streamed responses, and error conditions while preserving single-subscription stream integrity.


Installation #

Add both interceptly (the core inspector) and interceptly_http to your project:

flutter pub add interceptly
flutter pub add interceptly_http

Quick Start #

Wrap your standard http.Client:

import 'package:http/http.dart' as http;
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:interceptly/interceptly.dart';
import 'package:interceptly_http/interceptly_http.dart';

final navigatorKey = GlobalKey<NavigatorState>();

// Wrap any http.Client instance:
final client = InterceptlyHttpClient(http.Client());

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(MyApp(navigatorKey: navigatorKey));

  if (kDebugMode || kProfileMode) {
    Interceptly.init(navigatorKey: navigatorKey);
  }

  // Use the client normally:
  final response = await client.get(Uri.parse('https://api.example.com/data'));
  print('Status: ${response.statusCode}');
}

Features #

  • Stream Teeing: Seamlessly splits StreamedResponse.stream into dual broadcast paths so your consuming code receives the exact untouched response bytes while Interceptly records traffic.
  • Cancellation & Error Safe: Stream cancellations or socket exceptions are handled cleanly without memory leaks or hanging futures.
  • Zero Configuration: Drop-in replacement for any http.BaseClient or http.Client.
  • Global Network Simulation: Respects latency, bandwidth throttling, and offline profiles defined in Interceptly.

Configuration Options & SPI Injection #

InterceptlyHttpClient implements HttpCaptureAdapter. By default it uses DefaultHttpTrafficCollector(), which automatically coordinates with InspectorSession.instance. You can also inject a custom HttpTrafficCollector:

// Inject a custom HttpTrafficCollector:
final collector = MyCustomHttpTrafficCollector();
final customClient = InterceptlyHttpClient(
  http.Client(),
  collector,
);

License #

MIT License - see LICENSE for details.

0
likes
160
points
72
downloads

Documentation

API reference

Publisher

verified publisherstormx.dev

Weekly Downloads

HTTP client wrapper for Interceptly network inspector.

Repository (GitHub)
View/report issues
Contributing

License

MIT (license)

Dependencies

flutter, http, interceptly

More

Packages that depend on interceptly_http