Skip to content

c-api: Add wasi:http support #12943

Closed

Description

@chaynabors

There's no C API equivalent of wasmtime_component_linker_add_wasip2 for wasi:http. Anyone using the C API or language bindings like wasmtime-py can't host components that make outbound HTTP calls through wasi:http/outgoing-handler.

wasmtime-wasi-http already has add_only_http_to_linker_sync so the changes needed on the C API side are small, following the same pattern as wasip2. I have an implementation here: https://github.com/chaynabors/wasmtime/tree/add-wasi-http-c-api

The wasi-http feature implies wasi and is disabled by default since it brings in a lot of dependencies. Our team needs this for hosting components from Python. Is there any interest in this upstream?

One open question: since wasmtime-py ships a single prebuilt dylib, there's no way to optionally include wasi-http without distributing a separate artifact. Would it make sense to include it in the default release build, or would this need to be a separate distribution?

Activity

  1. pchickey commented on Apr 2, 2026

    @pchickey
    Contributor

    I don't think we ever reasoned through exactly why wasmtime-wasi-http was left out of the c-api aloud - I think its just an omission because nobody got to it. You're correct that it does bring in a lot of dependencies. However, it is also pretty important functionality, and generally speaking the wasmtime project wants to make your use case as easy as possible.

    Maybe other maintainers can think of good reasons we shoudn't include wasmtime-wasi-http in the c-api. The c-api already depends on tokio (behind a default-enabled feature) as part of wasmtime-wasi, which is fairly heavyweight compared to the bygone pre-component non-async era, so I'm hopeful that adding hyper and the tls implementation is also acceptable.

    If no objections exist, I think we should default to adding wasmtime-wasi-http to the c-api behind a feature, and enabling the feature by default. This should get it into wasmtime-py with the least amount of drama.

    If for some reason we shouldnt take that path, right now the c-api doesn't appear to me to have the right sort of interfaces for applying wasmtime_wasi_http::add_only_http_to_linker_sync to a component::Linker without the c-api crate directly using the WasiHttpCtx struct and impling WasiHttpView in the manner your branch does. So, if we wanted to insist that wasmtime-wasi-http get packaged for the c-api as a separate static library, we would need to come up with interfaces in c-api that allow it.

  2. pchickey commented on Apr 2, 2026

    @pchickey
    Contributor

    I've completed a brief survey of the other maintainers and there are no objections at this time, so please send us a PR that adds wasmtime-wasi-http like in your branch, with feature on by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions