Skip to content

wasmtime-wasi-http includes absolute URI in HTTP requests #7737

@arlyon

Description

@arlyon

Thanks for filing a bug report! Please fill out the TODOs below.

Note: if you want to report a security issue, please read our security policy!

Steps to Reproduce

The default outgoing handler inserts the URI as-is into the request in absolute form which should only be used for proxies. It seems we can fix this fairly easily by stripping out the other parts from the uri in here https://github.com/bytecodealliance/wasmtime/blob/main/crates/wasi-http/src/types.rs#L142

+    // remove the scheme and authority from the request
+    *request.uri_mut() = Uri::builder()
+        .path_and_query(
+            request
+                .uri()
+                .path_and_query()
+                .map(|p| p.as_str())
+                .unwrap_or("/"),
+        )
+        .build()
+        .expect("ok");

Otherwise, the absolute form uri will be used as-is, as described here https://github.com/hyperium/hyper/blob/master/src/client/conn/http1.rs#L175-L190.

Expected Results

I expect the http handler not to serialize requests using the absolute uri, since the support for this format is spotty (and potentially goes against the RFC)

Actual Results

The absolute form of the uri ends up in the http packet.

Versions and Environment

Version: Git master + hyper 1.1.0
Operating system: N/A
Architecture: N/A

Extra Info

N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugIncorrect behavior in the current implementation that needs fixing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions