dev_http_proxy 0.0.2 copy "dev_http_proxy: ^0.0.2" to clipboard
dev_http_proxy: ^0.0.2 copied to clipboard

A real-world HTTP/HTTPS proxy server for Flutter/Dart with optional authentication and logging.

🔄 DevHttpProxy #

Dart Flutter License: MIT Proxy

A lightweight, powerful HTTP/HTTPS proxy server for Flutter and Dart applications with optional authentication and comprehensive logging capabilities.

✨ Features #

  • 🔒 Optional Basic Authentication - Secure your proxy with username/password
  • 🔄 HTTP & HTTPS Support - Full tunneling for both protocols
  • 📝 Detailed Request/Response Logging - Debug network traffic with ease
  • 🚀 Simple API - Start a proxy server with just a few lines of code
  • 📦 Zero External Dependencies - Uses only Dart standard libraries
  • 📱 Flutter Compatible - Works with Flutter and pure Dart projects

📋 Table of Contents #

📥 Installation #

Add this to your package's pubspec.yaml file:

dependencies:
  dev_http_proxy: ^0.0.1

Then run:

flutter pub get

🚀 Quick Start #

import 'package:dev_http_proxy/dev_http_proxy.dart';

void main() async {
  final proxy = DevHttpProxy(
    port: 8080,
    username: 'admin',    // Optional
    password: '1234',     // Optional
    logRequests: true,    // Optional
  );

  await proxy.start();
  print('Proxy running at http://localhost:8080');
  
  // To stop the proxy server
  // await proxy.stop();
}

📚 API Reference #

DevHttpProxy Class #

Parameter Type Default Description
port int 8080 Port number for the proxy server
username String? null Optional username for Basic Auth
password String? null Optional password for Basic Auth
logRequests bool true Enable/disable request logging

Methods #

Method Return Type Description
start() Future<void> Starts the proxy server
stop() Future<void> Stops the proxy server

🏗️ Architecture #

The package has a simple and efficient architecture:

lib/
├── dev_http_proxy.dart    # Main implementation
└── example/
    └── main.dart          # Usage example

Core Components #

  • DevHttpProxy Class: The main class that handles all proxy functionality
  • HTTP Request Handler: Processes and forwards HTTP requests
  • HTTPS Connect Handler: Establishes TCP tunnels for HTTPS connections
  • Authentication Module: Implements Basic Authentication
  • Logging System: Detailed request/response logging

🔄 Data Flow #

graph LR
    A[Client] -->|HTTP/HTTPS Request| B[DevHttpProxy]
    B -->|Authentication Check| C{Auth OK?}
    C -->|No| D[401 Response]
    C -->|Yes| E{Request Type}
    E -->|HTTP| F[Forward HTTP Request]
    E -->|HTTPS CONNECT| G[Establish TCP Tunnel]
    F -->|Request| H[Target Server]
    G -->|Bidirectional Data| H
    H -->|Response| I[Client Response]
    F -->|Log| J[Console Output]
    G -->|Log| J

📝 Examples #

Basic Proxy Server #

final proxy = DevHttpProxy(port: 8080);
await proxy.start();

Authenticated Proxy Server #

final proxy = DevHttpProxy(
  port: 8080,
  username: 'admin',
  password: 'secure_password',
);
await proxy.start();

Silent Proxy (No Logging) #

final proxy = DevHttpProxy(
  port: 8080,
  logRequests: false,
);
await proxy.start();

🔍 How It Works #

HTTP Request Handling #

When an HTTP request is received:

  1. The proxy authenticates the request (if credentials are set)
  2. Headers and body are forwarded to the target server
  3. The response is piped back to the client
  4. All traffic is logged (if enabled)

HTTPS Tunneling #

For HTTPS connections:

  1. Client sends a CONNECT request to establish a tunnel
  2. Proxy creates a socket connection to the target server
  3. A bidirectional data pipe is established between client and server
  4. Raw TCP data flows through the tunnel without inspection

📄 License #

This package is licensed under the MIT License - see the LICENSE file for details.


Developed with ❤️ by DevTestify Labs

1
likes
160
points
41
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A real-world HTTP/HTTPS proxy server for Flutter/Dart with optional authentication and logging.

Homepage

License

MIT (license)

Dependencies

flutter

More

Packages that depend on dev_http_proxy