NB: this example uses an experimental wasi-http that incorporates an
experimental HTTP client library being developed as part of the WASI specification.
Use at your own risk, things may change in the future.
For easy porting: This directory includes a libcurl-compatible API shim (curl_shim.h / curl_shim.c) that implements common libcurl easy interface functions. This allows you to port existing libcurl-based code to WASM with minimal changes.
See LIBCURL_SHIM.md for detailed documentation and examples.
Quick example:
make run-curl-exampleThe wasi_http_request() function in wasi_http.c provides the main HTTP functionality. See main.c for usage examples showing GET, POST, and PUT requests. Key differences from traditional libraries:
- URLs must be split into authority (host) and path components
- Response buffer must be pre-allocated by caller
- Call
free_response()to release header memory after use
make main.wasmmake clean; make runmake server.wasmmake clean; make run-server