fermyon / spin

Spin is the open source developer tool for building and running serverless applications powered by WebAssembly.
https://developer.fermyon.com/spin
Apache License 2.0
5.45k stars 254 forks source link

rust sdk: Inbound http inconsistency with `wasmtime serve` #2032

Open lann opened 1 year ago

lann commented 1 year ago

From https://github.com/fermyon/http-auth-middleware/pull/4#issue-1973344440

I believe this is due to the Rust SDK's conditional reconstruction of the full URI:

https://github.com/fermyon/spin/blob/1f7cc3f54a2c8d96a24767bfcaa93ebc3b8982f5/sdk/rust/src/http.rs#L450-L464

If scheme and/or authority is missing, this will return just the path.

While technically a URI must have a scheme and authority, it appears that http::Request::uri (amongst others) produces just a path for inbound requests on many servers.

For compatibility reasons I think we should align with that for inbound wasi-http, though it will be annoying to adjust the conversions.

kate-goldenring commented 1 year ago

I believe it is because we are explicitly modifying the request uri here: https://github.com/fermyon/spin/blob/9c888ff9ffddf4927184a21afd519ccd63202250/crates/trigger-http/src/lib.rs#L194. We could remove this line and be compatible

lann commented 1 year ago

That would change requests for all inbound requests including existing interfaces, which might break existing apps. Updated description to specify that this should change only for the new wasi inbound interface.