Skip to content

Incoming request URL used http:// scheme instead of httpi:// [FIXED] #2

Description

@momics

[ISS-002] Incoming request URL uses http:// scheme instead of httpi://

Summary

When handling incoming requests on the server side, req.url shows http:// as the protocol scheme instead of httpi://. The serve layer in serve.ts deliberately replaces httpi: with http: because the native Request constructor rejects non-standard URL schemes.

Evidence

  • packages/iroh-http-shared/src/serve.ts:183payload.url.replace(/^httpi:/, "http:")
  • Observed during live testing: server handler sees http:// in req.url
  • The Rust core sends httpi:// correctly, but the JS layer overwrites it

Impact

Server handlers cannot distinguish iroh-http requests from regular HTTP by looking at req.url. The URL scheme contradicts the protocol spec. Routing logic that inspects the scheme will behave incorrectly.

Remediation

Options to investigate:

  1. Preserve httpi:// via defineProperty — construct the Request with http:// (required by the spec) but shadow req.url with the original httpi:// URL via Object.defineProperty, similar to how trailers are attached
  2. Custom IrohRequest class — extend Request to carry the original httpi:// URL and expose it cleanly
  3. Accept the http:// mapping — if we decide req.url should always be parseable by standard URL tooling, document this as intentional and provide alternative access to the original scheme

Acceptance criteria

  1. Server handler can read the httpi:// scheme from the incoming request
  2. new URL(req.url).pathname still works for routing
  3. Documented behavior

Regression test

  • Layer: type-check
  • Test: Confirmed native Request constructor accepts httpi:// URLs in both Deno and Node.js — no subclassing needed
  • Verified failing before fix: yes (req.url showed http:// instead of httpi://)
  • Fix: removed .replace(/^httpi:/, "http:") in packages/iroh-http-shared/src/serve.ts:183

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1High priorityprotocolWire format or protocol spec

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions