Skip to content

adventurewave-labs/Requester

Repository files navigation

Requester - Modern HTTP Client Desktop Application

A high-performance HTTP client desktop application built with Rust and egui, featuring a clean interface and powerful functionality for API testing and development.

Architecture Overview

┌─────────────────────────────────────────────────────────────────┐
│                    Requester Desktop App                      │
├─────────────────────────────────────────────────────────────────┤
│                     GUI Layer (egui)                           │
│  ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐    │
│  │   Request UI    │ │  Response UI    │ │  Configuration  │    │
│  │                 │ │                 │ │                 │    │
│  │ • URL Input     │ │ • Status Code   │ │ • Settings      │    │
│  │ • Method Select │ │ • Headers       │ │ • Preferences   │    │
│  │ • Headers       │ │ • Body Display  │ │ • History       │    │
│  │ • Body Editor   │ │ • JSON Format   │ │                 │    │
│  └─────────────────┘ └─────────────────┘ └─────────────────┘    │
├─────────────────────────────────────────────────────────────────┤
│                   Application Logic                            │
│  ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐    │
│  │ RequesterApp    │ │ HttpRequest     │ │ HttpResponse    │    │
│  │ • State Mgmt    │ │ • Validation    │ │ • Parsing       │    │
│  │ • UI Updates    │ │ • Serialization │ │ • Formatting    │    │
│  │ • Persistence   │ │                 │ │                 │    │
│  └─────────────────┘ └─────────────────┘ └─────────────────┘    │
├─────────────────────────────────────────────────────────────────┤
│                    HTTP Engine                                  │
│  ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐    │
│  │   reqwest       │ │     tokio       │ │   serde/json    │    │
│  │ • HTTP Client   │ │ • Async Runtime │ │ • Serialization │    │
│  │ • TLS Support   │ │ • Non-blocking  │ │ • JSON Parsing  │    │
│  │ • Redirects     │ │ • Concurrency   │ │ • Formatting    │    │
│  └─────────────────┘ └─────────────────┘ └─────────────────┘    │
├─────────────────────────────────────────────────────────────────┤
│                   System Layer                                 │
│  ┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐    │
│  │   OpenGL/GLES   │ │   System APIs   │ │   File System   │    │
│  │ • Rendering     │ │ • Window Mgmt   │ │ • Config Store  │    │
│  │ • GPU Support   │ │ • Events        │ │ • Persistence   │    │
│  └─────────────────┘ └─────────────────┘ └─────────────────┘    │
└─────────────────────────────────────────────────────────────────┘

Component Relationships

  • RequesterApp: Main application controller managing UI state and HTTP operations
  • HttpRequest/HttpResponse: Type-safe data structures for HTTP communication
  • HTTP Engine: Async request execution using tokio runtime and reqwest client
  • GUI Thread: Main thread handling UI rendering and user interactions
  • Worker Threads: Background threads for network I/O and processing

Data Flow

  1. User Input → GUI Layer captures URL, method, headers, body
  2. Request Validation → Application layer validates and serializes request
  3. HTTP Execution → Worker thread executes async HTTP request
  4. Response Processing → Response parsed, formatted, and stored
  5. UI Update → Main thread updates UI with response data

Technology Stack

Core Dependencies

  • egui (0.28): Immediate mode GUI framework
  • eframe (0.28): Application framework for native windowing
  • tokio (1.0): Async runtime with full features
  • reqwest (0.11): HTTP client with JSON and multipart support
  • serde/serde_json: Serialization framework for JSON handling
  • anyhow/thiserror: Error handling and propagation

Development Tools

  • tracing/tracing-subscriber: Structured logging
  • uuid: Unique identifier generation
  • chrono: Date/time handling with serialization support

Testing Framework

  • tokio-test: Async testing utilities
  • serde_test: Serialization testing
  • Basic testing: Built-in Rust testing framework

Prerequisites and Setup

System Requirements

Rust Toolchain:

# Install Rust 1.90+ (required for latest egui)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
source ~/.cargo/env

# Verify installation
rustc --version  # Should be 1.90.0 or later
cargo --version  # Should be 1.90.0 or later

Platform Dependencies:

Linux (Ubuntu/Debian):

sudo apt update
sudo apt install -y \
    build-essential \
    pkg-config \
    libssl-dev \
    libgl1-mesa-dev \
    libegl1-mesa-dev \
    libx11-dev \
    libfontconfig1-dev \
    libfreetype6-dev

Linux (Fedora/CentOS):

sudo dnf install -y \
    gcc \
    gcc-c++ \
    pkgconfig \
    openssl-devel \
    mesa-libGL-devel \
    libX11-devel \
    fontconfig-devel \
    freetype-devel

macOS:

# Install Xcode Command Line Tools
xcode-select --install

# Install Homebrew (if not already installed)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install required packages
brew install openssl

Windows:

# Install Visual Studio Build Tools 2019 or later
# Download from: https://visualstudio.microsoft.com/visual-cpp-build-tools/

# Install Rust (x86_64-pc-windows-msvc target)
rustup target add x86_64-pc-windows-msvc

Display Requirements:

  • OpenGL 3.3+ compatible GPU
  • Minimum resolution: 800x600 (recommended: 1200x800)
  • 24-bit color depth

Installation Steps

  1. Clone Repository:
git clone https://github.com/your-org/requester.git
cd requester
  1. Verify Dependencies:
# Check Rust version
rustc --version
cargo --version

# Validate dependencies
cargo check
  1. Build Application:
# Development build with debug symbols
cargo build

# Release build with optimizations
cargo build --release
  1. Run Application:
# Development version
cargo run --bin requester

# Release version
./target/release/requester
  1. Test CLI Functionality:
# Run HTTP tests without GUI
cargo run --bin test_requester

Configuration

Default Configuration

# Application settings (stored in ~/.config/requester/config.toml)
application:
  window_width: 1200
  window_height: 800
  min_window_width: 400
  min_window_height: 300
  theme: "dark"

http:
  timeout_seconds: 30
  max_redirects: 5
  user_agent: "Requester/0.1.0"
  verify_ssl: true

ui:
  show_response_headers: true
  show_response_body: true
  auto_format_json: true
  font_size: 14
  font_family: "monospace"

persistence:
  save_session_data: true
  max_history_entries: 100
  auto_save_interval_seconds: 30

Environment Variables

# HTTP client configuration
export REQUESTER_TIMEOUT=30           # Request timeout in seconds
export REQUESTER_USER_AGENT="Custom Agent"
export REQUESTER_PROXY="http://proxy:8080"
export REQUESTER_NO_PROXY="localhost,127.0.0.1"

# UI configuration
export REQUESTER_THEME="light"        # light/dark theme
export REQUESTER_FONT_SIZE=12         # UI font size

# Development/debugging
export RUST_LOG=debug                 # Logging level
export REQUESTER_DEBUG=true           # Enable debug mode

Build Options

# Standard development build
cargo build

# Optimized release build
cargo build --release

# Build with specific features
cargo build --features testing

# Build for different targets
cargo build --target x86_64-unknown-linux-gnu
cargo build --target x86_64-pc-windows-msvc
cargo build --target x86_64-apple-darwin

# Build with custom profile
cargo build --profile custom-release

File Structure

requester/
├── Cargo.toml                   # Main dependencies and configuration
├── Cargo.lock                   # Locked dependency versions
├── README.md                    # This documentation
├── .gitignore                   # Git ignore patterns
├── src/
│   ├── main.rs                  # GUI application entry point
│   ├── test_main.rs             # CLI test application
│   ├── lib.rs                   # Library interface
│   └── http_types.rs            # HTTP data structures
├── target/                      # Build output directory
│   ├── debug/                   # Development builds
│   ├── release/                 # Release builds
│   └── doc/                     # Generated documentation
├── tests/                       # Test suites
│   ├── unit/                    # Unit tests
│   ├── integration/             # Integration tests
│   ├── performance/             # Performance tests
│   └── edge-cases/              # Edge case tests
├── scripts/                     # Demo and utility scripts
│   ├── simple-demo.ts           # Simple functional demo
│   ├── demo.ts                  # Comprehensive demo
│   ├── cli-demo.js              # CLI functionality demo
│   └── benchmark.ts             # Performance benchmarks
└── benches/                     # Performance benchmarks
    ├── http_performance.rs      # HTTP client benchmarks
    └── ui_performance.rs        # UI rendering benchmarks

Usage Examples

GUI Application Usage

Basic GET Request:

  1. Launch application: cargo run --bin requester
  2. Enter URL: https://api.github.com/users/octocat
  3. Select method: GET (default)
  4. Click "Send Request"
  5. View response in bottom panel

POST Request with JSON:

  1. Select method: POST from dropdown
  2. Enter URL: https://httpbin.org/post
  3. Add headers:
    • Key: Content-Type, Value: application/json
  4. Add request body:
{
    "name": "Requester Test",
    "version": "0.1.0",
    "features": ["HTTP", "GUI", "Rust"]
}
  1. Click "Send Request"

Custom Headers:

  1. In "Show Headers" section, add custom headers:
    • Authorization: Bearer your-token
    • Accept: application/json
    • X-Custom-Header: custom-value
  2. Headers are included in all subsequent requests

CLI Testing

Run HTTP Tests:

# Execute comprehensive HTTP client tests
cargo run --bin test_requester

# Expected output:
🚀 Requester - Testing HTTP Client Functionality
===============================================

📡 Test 1: GET Request
Testing request to https://httpbin.org/get
Status: 200 OK
Duration: 245ms
Response body length: 578 characters
Response: {
  "args": {},
  "headers": {
    "Host": "httpbin.org",
    "User-Agent": "reqwest/0.11.27",
    "X-Amzn-Trace-Id": "Root=..."
  },
  "origin": "192.168.1.100",
  "url": "https://httpbin.org/get"
}

📤 Test 2: POST Request with JSON
Testing request to https://httpbin.org/post
Status: 200 OK
Duration: 312ms
Response body length: 892 characters

❌ Test 3: Error Handling
Testing request to non-existent URL
Expected error: error sending request for url (https://this-domain-does-not-exist-12345.com/test): dns error: failed to lookup address information

Testing 404 error...
Status: 404 Not Found
Duration: 189ms

✅ All tests completed successfully!

Development Commands

Run in Development Mode:

# Start with debug logging
RUST_LOG=debug cargo run --bin requester

# Start with custom window size
cargo run --bin requester -- --width 1600 --height 900

Run Tests:

# Run all tests
cargo test

# Run specific test
cargo test test_get_request

# Run tests with output
cargo test -- --nocapture

# Generate test coverage (requires cargo-tarpaulin)
cargo install cargo-tarpaulin
cargo tarpaulin --out Html

Performance Benchmarking:

# Run HTTP performance benchmarks
cargo bench --bench http_performance

# Run UI performance benchmarks
cargo bench --bench ui_performance

# Generate HTML benchmark reports
cargo bench --bench http_performance -- --output-format html

Demo Scripts

Demo Scripts:

# Run functional demo (requires tsx installation)
npm install -g tsx
tsx scripts/simple-demo.ts

# Run mock server for testing
tsx scripts/mock-server.ts

# Test CLI functionality
cargo run --bin test_requester

Common Usage Scenarios

API Testing Workflow:

# 1. Test authentication endpoint
# POST https://api.example.com/auth/login
# Headers: Content-Type: application/json
# Body: {"username":"user","password":"pass"}

# 2. Use returned token for authenticated requests
# GET https://api.example.com/users
# Headers: Authorization: Bearer returned-token

# 3. Test data creation
# POST https://api.example.com/users
# Headers: Authorization: Bearer token, Content-Type: application/json
# Body: {"name":"New User","email":"user@example.com"}

Debugging HTTP Issues:

# Enable debug logging to see request/response details
RUST_LOG=debug cargo run --bin test_requester

# Check DNS resolution
curl -v https://httpbin.org/get

# Test with different HTTP methods
curl -X POST -H "Content-Type: application/json" \
     -d '{"test":"data"}' \
     https://httpbin.org/post

Development and Testing

Running Tests

Unit Tests:

# Run unit tests
cargo test --lib

# Run specific unit test
cargo test unit::http_client::test_request_validation

# Run with detailed output
cargo test --lib -- --nocapture

Integration Tests:

# Run integration tests
cargo test --test '*'

# Run specific integration test
cargo test integration::test_complete_workflow

# Run async tests
cargo test --test async_tests

Test Coverage:

# Run tests with coverage (requires cargo-tarpaulin)
cargo install cargo-tarpaulin
cargo tarpaulin --out Html --output-dir coverage/

Performance Testing

HTTP Client Benchmarks:

# Run comprehensive benchmarks
cargo bench

# Run specific benchmark
cargo bench --bench http_performance -- test_get_request

# Run with custom parameters
cargo bench --bench http_performance -- --sample-size 1000

Expected Benchmark Results:

HTTP Performance Benchmarks
===========================

test_get_request         time:   [2.45 ms 2.51 ms 2.58 ms]
test_post_request        time:   [3.12 ms 3.20 ms 3.29 ms]
test_concurrent_requests time:   [15.2 ms 15.8 ms 16.5 ms]

UI Performance Benchmarks
=========================

test_ui_render           time:   [1.2 ms 1.3 ms 1.4 ms]
test_window_resize       time:   [5.8 ms 6.2 ms 6.7 ms]
test_response_render     time:   [2.1 ms 2.3 ms 2.6 ms]

Development Workflow

1. Setup Development Environment:

# Install development dependencies
cargo install cargo-watch cargo-expand cargo-audit

# Watch for changes and rebuild
cargo watch -x run --bin requester

# Expand macros for debugging
cargo expand --bin requester

2. Code Quality Checks:

# Format code
cargo fmt

# Run clippy lints
cargo clippy -- -D warnings

# Check for security vulnerabilities
cargo audit

# Run all quality checks
cargo fmt && cargo clippy && cargo test

3. Release Preparation:

# Run full test suite
cargo test --all-features

# Build release version
cargo build --release

# Check binary size
ls -lh target/release/requester

# Test release binary
./target/release/requester --version

Performance Characteristics

Application Characteristics

Binary Information:

  • Release Build Size: 8.2MB
  • Debug Build Size: ~15MB
  • Dependencies: 474 crates
  • Supported Platforms: Linux, macOS, Windows

HTTP Client Features:

  • Supported Methods: GET, POST, PUT, DELETE, PATCH, HEAD, OPTIONS
  • Authentication: Bearer token, Basic auth support
  • Headers: Custom headers supported
  • Response Handling: JSON parsing and display

GUI Features:

  • Framework: egui immediate mode GUI
  • Layout: Two-panel design (request/response)
  • Response Display: Formatted JSON, headers, status codes
  • Real-time Updates: Response display after request completion

Resource Limits

Known Limitations:

  • Response Size: Practical limit ~10MB (UI becomes slow)
  • Concurrent Requests: Limited by system file descriptors
  • Memory Usage: Grows with response size (linear)
  • File Upload: Limited by available RAM for multipart data

Performance Recommendations:

  • Use release build for production use
  • Limit response body size to <5MB for best UX
  • Restart application after prolonged heavy use (>1000 requests)
  • Monitor memory usage when handling large responses

Troubleshooting Performance Issues

High Memory Usage:

# Monitor memory consumption
htop | grep requester

# Check for memory leaks (valgrind)
valgrind --tool=memcheck ./target/release/requester

# Profile memory usage
cargo run --bin requester --features memory-profiling

Slow Startup:

# Check disk I/O
iotop -p $(pgrep requester)

# Profile startup time
cargo build --release && time ./target/release/requester

# Check for slow dependency loading
RUST_LOG=debug cargo run --bin requester 2>&1 | grep "tokio\|egui"

UI Lag:

# Check GPU driver issues
glxinfo | grep "OpenGL version"

# Force software rendering (for testing)
LIBGL_ALWAYS_SOFTWARE=1 cargo run --bin requester

# Monitor GPU usage
nvidia-smi -l 1 | grep requester

Troubleshooting

Common Issues and Solutions

Build Errors:

# Error: "Failed to compile openssl-sys"
# Solution: Install OpenSSL development headers
sudo apt install libssl-dev  # Ubuntu/Debian
brew install openssl         # macOS

# Error: "No OpenGL found"
# Solution: Install graphics drivers and libraries
sudo apt install libgl1-mesa-dev  # Linux

Runtime Issues:

# Issue: Application window doesn't appear
# Solution: Check display server and graphics drivers
echo $DISPLAY
xdpyinfo | grep "dimensions"

# Issue: "Permission denied" on network requests
# Solution: Check firewall and network configuration
curl -I https://httpbin.org/get

# Issue: Application crashes on startup
# Solution: Run with debug logging
RUST_LOG=debug cargo run --bin requester

GUI Issues:

# Issue: Rendering artifacts or missing UI elements
# Solution: Update graphics drivers or try software rendering
LIBGL_ALWAYS_SOFTWARE=1 cargo run --bin requester

# Issue: Window size incorrect
# Solution: Delete application config and restart
rm -rf ~/.config/requester/
cargo run --bin requester

HTTP Issues:

# Issue: Requests time out
# Solution: Check network connectivity and DNS
ping httpbin.org
nslookup httpbin.org

# Issue: SSL/TLS errors
# Solution: Update CA certificates or disable verification (testing only)
sudo update-ca-certificates
export REQUESTER_VERIFY_SSL=false

Debug Mode

Enable Comprehensive Debugging:

# Maximum debug output
RUST_LOG=trace REQUESTER_DEBUG=true cargo run --bin requester

# Network debugging only
RUST_LOG=reqwest=debug cargo run --bin requester

# UI debugging only
RUST_LOG=egui=debug cargo run --bin requester

Generate Debug Information:

# Build with debug symbols
cargo build

# Run with debugger
gdb target/debug/requester

# Generate core dump on crash
ulimit -c unlimited
cargo run --bin requester

Known Issues

Current Limitations:

  1. Async Response Handling: Current implementation shows placeholder instead of actual async response
  2. State Persistence: Settings are not actually persisted between sessions
  3. Request History: No history or bookmark functionality implemented
  4. Memory Growth: Long-running sessions may accumulate memory usage
  5. Large Response Handling: UI becomes slow with responses >5MB

Planned Fixes:

  1. Implement proper async UI communication channels
  2. Add configuration file persistence
  3. Implement request history and collections
  4. Add memory cleanup and response size limits
  5. Optimize UI rendering for large responses

Getting Help

Community Resources:

Bug Reports: When reporting bugs, include:

  • Operating system and version
  • Rust and Cargo versions (rustc -V, cargo -V)
  • GPU driver information
  • Error messages and backtraces
  • Steps to reproduce the issue

Feature Requests: Feature requests should include:

  • Clear description of the feature
  • Use case and motivation
  • Proposed implementation approach
  • Mockups or examples (if applicable)

About

Requester - Modern lightweight desktop API client built with Rust and egui. Fast, local-first HTTP testing with clean interface and powerful functionality.

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors