wire 1.0.1

High-performance, zero-allocation HTTP parser for D - wrapping llhttp


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

Wire

High-performance, zero-allocation HTTP parser for D.

Built on llhttp, the HTTP parser that powers Node.js.

DUB License D

Overview

Wire provides a @nogc nothrow HTTP/1.x parser with zero heap allocations. All string data is accessed via StringView slices into the original request buffer.

Key characteristics:

  • Zero GC allocations during parsing
  • Complete @nogc nothrow API
  • 64-byte aligned structures for cache efficiency
  • Thread-local parser pool with automatic reuse

Installation

Add to your dub.json:

"dependencies": {
    "wire": "~>1.0.0"
}

Or with dub.sdl:

dependency "wire" version="~>1.0.0"

Building from Source

git clone https://github.com/federikowsky/Wire.git
cd Wire
make        # Build and run tests
make lib    # Build static library only

Quick Start

import wire;

void handleRequest(const(ubyte)[] data) @nogc nothrow {
    auto req = parseHTTP(data);
    
    if (!req) return;  // Parse error
    
    auto method = req.getMethod();     // "GET"
    auto path = req.getPath();         // "/api/users"
    auto host = req.getHeader("Host"); // "example.com"
    
    auto page = req.getQueryParam("page");
    
    if (req.shouldKeepAlive()) {
        // Reuse connection
    }
}

API Reference

Parsing

auto parseHTTP(const(ubyte)[] data) @nogc nothrow;

Returns a ParserWrapper with RAII cleanup. The parser is automatically returned to the thread-local pool on scope exit.

Request Methods

MethodReturnsDescription
getMethod()StringViewHTTP method
getPath()StringViewRequest path
getQuery()StringViewQuery string (without ?)
getHeader(name)StringViewHeader value (case-insensitive)
getQueryParam(name)StringViewQuery parameter value
getBody()StringViewRequest body
shouldKeepAlive()boolConnection keep-alive status
isUpgrade()boolWebSocket upgrade request
getErrorCode()intError code (0 = success)

All methods are @nogc nothrow and return zero-copy views.

Header Iteration

foreach (header; req.getHeaders()) {
    writeln(header.name, ": ", header.value);
}

Performance

Benchmarked on Apple M2 with LDC 1.41:

Request TypeSizeParse TimeThroughput
Simple GET37 B7 μs5 MB/s
Browser (Chrome)1.0 KB1 μs983 MB/s
REST API + JWT1.5 KB1 μs1,442 MB/s
Stripe Webhook2.1 KB1 μs2,023 MB/s

Memory usage:

  • Per thread: ~1 KB (parser pool)
  • Per request: 0 bytes (zero allocation)
  • Header limit: 64 headers

Building

Requirements

  • D Compiler: LDC 1.35+ (recommended) or DMD 2.105+
  • C Compiler: clang or gcc (C99)

Make Targets

TargetDescription
makeBuild and run tests
make libBuild libwire.a
make test-verboseTests with timing
make debugDebug build
make cleanClean artifacts

Documentation

Contributing

Contributions are welcome. Please ensure:

  1. All code maintains @nogc nothrow compatibility
  2. Tests pass (make test)
  3. Code follows D style guidelines

License

MIT License — see LICENSE for details.

Authors:
  • Federico Filippi
Dependencies:
none
Versions:
1.0.1 2025-Dec-07
1.0.0 2025-Dec-07
~main 2025-Dec-07
~copilot/translate-italian-comments 2025-Dec-02
Show all 4 versions
Download Stats:
  • 2 downloads today

  • 7 downloads this week

  • 7 downloads this month

  • 7 downloads total

Score:
0.1
Short URL:
wire.dub.pm