[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:183 — payload.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:
- 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
- Custom IrohRequest class — extend Request to carry the original
httpi:// URL and expose it cleanly
- 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
- Server handler can read the
httpi:// scheme from the incoming request
new URL(req.url).pathname still works for routing
- 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
[ISS-002] Incoming request URL uses http:// scheme instead of httpi://
Summary
When handling incoming requests on the server side,
req.urlshowshttp://as the protocol scheme instead ofhttpi://. The serve layer inserve.tsdeliberately replaceshttpi:withhttp:because the nativeRequestconstructor rejects non-standard URL schemes.Evidence
packages/iroh-http-shared/src/serve.ts:183—payload.url.replace(/^httpi:/, "http:")http://inreq.urlhttpi://correctly, but the JS layer overwrites itImpact
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:
http://(required by the spec) but shadowreq.urlwith the originalhttpi://URL viaObject.defineProperty, similar to how trailers are attachedhttpi://URL and expose it cleanlyreq.urlshould always be parseable by standard URL tooling, document this as intentional and provide alternative access to the original schemeAcceptance criteria
httpi://scheme from the incoming requestnew URL(req.url).pathnamestill works for routingRegression test
Requestconstructor acceptshttpi://URLs in both Deno and Node.js — no subclassing neededhttp://instead ofhttpi://).replace(/^httpi:/, "http:")inpackages/iroh-http-shared/src/serve.ts:183