mitmproxy_ri_client 0.1.1 copy "mitmproxy_ri_client: ^0.1.1" to clipboard
mitmproxy_ri_client: ^0.1.1 copied to clipboard

A client for the mitmproxy Remote Interceptions addon.

example/mitmproxy_ri_client_example.dart

// ignore_for_file: avoid_print

import 'package:mitmproxy_ri_client/mitmproxy_ri_client.dart' as mitm_ri;

void main() async {
  final client = mitm_ri.Client.connect(
    // Leave requests as they are.
    getRequestSetSettings: (flowId, requestSummary, responseSummary) =>
        mitm_ri.MessageSetSettings.skip,

    // Only the responses are getting modified here - the requests don't need to
    // be sent to the client.
    // In more complex use-cases, the [requestSummary] and [responseSummary]
    // objects can be used to implement dynamic filtering.
    getResponseSetSettings: (flowId, requestSummary, responseSummary) =>
        mitm_ri.MessageSetSettings.includeResponseOnly,

    // Add a header to every response.
    handleResponse: (flowId, request, response) {
      return mitm_ri.MessageSet(
        response: response!.copyWith(
          headers: {
            ...response.headers,
            'X-MITM-Dart-Example': ['Hello, world!'],
          },
        ),
      );
    },

    // Handle errors.
    onError: (error, stackTrace) {
      print('An error was encountered communicating with mitmproxy: $error');
    },
  );

  print('Connected.');

  // Wait for the addon server to close.
  await client.done;

  // Alternatively, the client can disconnect from the addon manually.
  // await stdin.first;
  // await client.disconnect();

  print('Disconnected.');
}
copied to clipboard
4
likes
130
points
36
downloads

Publisher

verified publisherhacker1024.tk

Weekly Downloads

2024.09.20 - 2025.04.04

A client for the mitmproxy Remote Interceptions addon.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

freezed_annotation, json_annotation, web_socket_channel

More

Packages that depend on mitmproxy_ri_client