Caution
Approaches listed on this page are deprecated or/and do not longer work. They are collected here for historical purposes.
Each item has hyperlink to up-to-date alternative in the main list.
| Language | Browsers and JS runtimes | Standalone / server-side / WASI runtimes |
|---|---|---|
| AssemblyScript | ||
| C# / .Net | ||
| C / C++ | ||
| Golang / TinyGo | ||
| PHP | ||
| Python | ||
| Rust | ||
| Zig |
Browser WASM runtimes and standalone JS runtimes like Node.js and Deno (and other V8-based), also Bun
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Caution
Tip Use |
// Uno Platform's own way
// Deprecated since .NET 6,
// use 'System.Net.Http.HttpClient' and 'HttpHandler' instead
// See https://github.com/unoplatform/uno/issues/9665
using System.Net.Http;
using (var handler = new Uno.UI.Wasm.WasmHttpHandler())
using (var client = new HttpClient(handler))
{
var request = new HttpRequestMessage(HttpMethod.Get,
new Uri("https://httpbin.org/anything"));
var response = await client.SendAsync(request);
var content = await response.Content.ReadAsStringAsync();
} |
Browser |
JS Interop invokes the TS
wrapper for |
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
PIB: PHP in Browser aka php-wasm Caution This code does not work in php-wasm v0.0.8. Tip Use up-to-date method instead. |
$js=<<<JSCODE
var xhr=new XMLHttpRequest();
xhr.open('GET', 'https://httpbin.org/anything', 0);
xhr.send();
xhr.responseText;
JSCODE;
var_dump(vrzno_eval($js)); |
Browser, Node.js, and maybe Deno |
Manual JS |
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
For pyjs Caution Repo was archived and package was dropped from recipes on Feb 6, 2024. Tip Use the official |
import requests
r = requests.get('https://httpbin.org/anything')
result = r.text
print(result) |
Browser |
Direct |
Standalone and server-side runtimes (mostly WASI and WASI-Socket-enabled), incl containers, FaaS, Edge Computing, etc
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Caution Repo was archived on Feb 22, 2024. Tip Use wasi-http instead. |
import {
Method, RequestBuilder, Response
} from "@deislabs/wasi-experimental-http";
import { Console } from "as-wasi/assembly";
let resp = new RequestBuilder("https://httpbin.org/anything")
.header("User-Agent", "wasm32-wasi-http")
.method(Method.GET)
.send();
let text = String.UTF8.decode(resp.bodyReadAll().buffer);
Console.log(text); |
Dev Container created by brendandburns |
Wasmtime with integrated |
Importing npm package which calls imported host function implemented in wasi-experimental-http-wasmtime Wasmtime's WASI module. |
||
|
Caution Repo was archived on Feb 22, 2024. Tip Use wasi-http instead. |
// Identical to wasi-experimental-http currently
// Needs `npm i https://github.com/brendandburns/wasi-http-ts`
import {
Method, RequestBuilder
} from "@brendandburns/wasi-http-ts";
import { Console } from "as-wasi/assembly";
let resp = new RequestBuilder("https://httpbin.org/anything")
.header("User-Agent", "wasm32-wasi-http")
.method(Method.GET)
.send();
let text = String.UTF8.decode(resp.bodyReadAll().buffer);
Console.log(text); |
<-- |
Readme from dev-wasm-ts |
Possible with Dev Container created by brendandburns |
Wasmtime with integrated |
Using client lib which calls imported host function implemented in wasi-experimental-http-wasmtime Wasmtime's WASI module. |
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Caution Repo was archived on Feb 22, 2024. Tip Use wasi-http instead. |
using Wasi.Http;
var client = new HttpClient(new WasiHttpHandler());
var result = await client.GetAsync("https://httpbin.org/anything",
System.Threading.CancellationToken.None);
var content = await result.Content.ReadAsStringAsync();
Console.WriteLine(content); |
Dev Container created by brendandburns |
Wasmtime with integrated |
Calling imported via C level bindings the host function implemented in wasi-experimental-http-wasmtime Wasmtime's WASI module. |
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Caution Repo was archived on Feb 22, 2024. Tip Use wasi-http instead. |
#include "req.h"
#include <string.h>
#include <stdio.h>
const char* url = "https://httpbin.org/anything";
const char* headers = "User-agent: wasm32-wasi-http";
size_t length = 1024 * 1024;
char* buffer = (char*) malloc(length);
uint16_t code;
ResponseHandle handle;
HttpError err = req(url, strlen(url), "GET", 3, headers,
strlen(headers), "", 0, &code, &handle);
size_t written;
err = bodyRead(handle, buffer, length, &written);
close(handle);
printf("%s\n", buffer);
free(buffer); |
Dev Container created by brendandburns |
Wasmtime with integrated |
Calling imported host function implemented in wasi-experimental-http-wasmtime Wasmtime's WASI module. |
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Caution Repo was archived on Feb 22, 2024. Tip Use wasi-http instead. |
response, err := Request(
"https://httpbin.org/anything", "GET",
"User-agent: wasm32-wasi-http", "")
defer response.Close()
body, err := response.Body()
if err == nil {
println(string(body))
} |
Dev Container created by brendandburns |
Wasmtime with integrated |
Calling imported host function implemented in wasi-experimental-http-wasmtime Wasmtime's WASI module. |
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Caution Repo was archived on Feb 22, 2024. Tip Use wasi-http instead. |
use http;
use wasi_experimental_http;
let req = http::request::Builder::new()
.uri("https://httpbin.org/anything").body(None).unwrap();
let resp = wasi_experimental_http::request(req);
let data = std::str::from_utf8(&resp.body_read_all().unwrap())
.unwrap().to_string();
println!("{}", data); |
Wasmtime with integrated |
Calling imported Wasmtime's host function. The actual request is here. |
| Product / Implementation | TLDR: Usage | TLDR: Example code | Doc | Online demo | WASM Runtime | Internals: method to do real request |
|---|---|---|---|---|---|---|
|
Caution Repo was archived on Feb 22, 2024. Tip Use wasi-http instead. |
var gp_all = std.heap.GeneralPurposeAllocator(.{}){};
const allocator = gp_all.allocator();
var status: u16 = 0;
var handle: u32 = 0;
_ = request("https://httpbin.org/anything", "GET", "", "", &status, &handle);
defer _ = close(@bitCast(i32, handle));
var headers_buffer = try allocator.alloc(u8, 1024);
var header_len: u32 = 0;
_ = header(handle, "content-length", headers_buffer, &header_len);
const length = try std.fmt.parseInt(u32, headers_buffer[0..header_len], 10);
var buffer = try allocator.alloc(u8, length + 1);
defer allocator.free(buffer);
var written: u32 = 0;
_ = body_read(handle, &buffer[0], @bitCast(i32, buffer.len), &written);
try std.io.getStdOut().writer().print("{s}\n", .{buffer[0..written]}); |
Dev Container by brendandburns |
Wasmtime with integrated |
Calling imported Wasmtime's host function. The actual request is here. |