Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

(Wannabe-awesome) list of methods to make outbound HTTP(S) requests from within WebAssembly in many languages

License

NotificationsYou must be signed in to change notification settings

vasilev/HTTP-request-from-inside-WASM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 

Repository files navigation

(Wannabe-awesome) list of approaches (recipes, frameworks, http client libraries, etc) to send outbound HTTP(S) requests from inside WebAssembly.

Contents

LanguageBrowsers and V8-based runtimesStandalone / server-side / WASI runtimes
Ada

AdaWebPack

AssemblyScript

as-fetch

wasi-http

BASIC

EndBASIC, gobasic

C# / .Net

Blazor, OpenSilver, RestSharp, System.Net.Http.HttpClient, Uno Platform

Extism PDK for .NET, Spin SDK for .NET, wasi-http

C / C++

Emscripten, xxhr

Extism PDK for C, httpclient_wasmedge_socket, wasi-http

Crystal

crystal-js

Dart

package:http, package:web, dio, fetch_api, fetch_client, dart:js_interop, requests, Cloudflare Workers SDK

Forth

WAForth

Golang / TinyGo

net/http, wasm-fetch, Nigel2392/requester, Anko, Risor, Tengo, Hogosuru, Vecty, Vugu, Yaegi

Capsule, Extism PDK for Go, go-plugin, Spin SDK for Go, dispatchrun/net, wasi-http,wasi-http-go, Wasm Workers Server

Haskell

Extism PDK for Haskell

Java

Bytecoder

spin-teavm-example

JavaScript

Goja, gojax/fetch, Jint, libcurl.js, Otto, quickjs-emscripten, sebastianwessel/quickjs

WasmEdge-QuickJs, Extism PDK for JS, Spin SDK for JS / TS, Wasm Workers Server

Kotlin

Kotlin/Wasm

Lisp

Janet

Lua

Wasmoon, gluahttp, lmodhttpclient, gopher-lua-libs, Pluto

PHP

php-wasm

Pascal

Free Pascal

Perl

WebPerl

Prolog

ichiban/prolog, Scryer Prolog, SWI-Prolog, trealla-js

Spin SDK for Prolog

Python

RustPython, Pyodide, pyodide-http, GPython, JupyterLite, PyScript, Panel, PocketPy, RPython, Stlite,urllib3, micropython-wasm

componentize-py, Extism PDK for Python, Spin SDK for Python

R

webR

Ruby

ruby.wasm

Rust

wasm-bindgen, Cloudflare Workers SDK, ehttp, gloo_net, httpc, http-client,iced, leptos, localghost, MoonZoon, quad-net,reqwasm, reqwest, sauron, seed, surf,sycamore Scripting:Rune

reqwest, http_req, Extism PDK for Rust, Spin SDK for Rust, waki,wasi-http, Wasm Workers Server

Starlark

starlark-go, starlark-go-nethttp, starlib, starlight, starlight-enhanced

Swift

SwiftWasm

Tcl

criTiCaL, Wacl

Wonkey

Wonkey/httprequest

Zig

Extism PDK for Zig, Spin SDK for Zig

Misc langs

Berry:berry, Expression:Cel-go, Expr, Rebol:rye

MoonBit:Extism PDK for MoonBit,Virgil:Extism PDK for Virgil

Browser WASM runtimes and V8-based runtimes like Node.js and Deno, also Bun

Ada

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

AdaWebPack

L   :aliased Listener;xhr : Web.XHR.Requests.XML_Http_Request;overridingprocedureHandle_Event  (Self :inout Listener; Event :inout Web.DOM.Events.Event'Class)isusetype Web.XHR.Requests.State;beginif xhr.Get_Ready_State = Web.XHR.Requests.DONEthen    WASM.Console.Log (xhr.Get_Response_Text);endif;endHandle_Event;procedureInitialize_Exampleisbegin  xhr := Web.XHR.Requests.Constructors.New_XML_Http_Request;  xhr.Open ("GET","https://httpbin.org/anything");  xhr.Send ("");  xhr.Add_Event_Listener ("readystatechange", L'Access);endInitialize_Example;

Example

Browser

Manual JSXMLHttpRequest interop by using thewrapperforimportedJS-sidecode.

AssemblyScript

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

as-fetch

import{fetch}from"as-fetch/assembly";export{responseHandler}from"as-fetch/assembly";fetch("https://httpbin.org/anything",{method:"GET",mode:"no-cors",headers:[],body:null,}).then((resp)=>{consttext=resp.text();});

Example

Readme

Browser, Node.js, and Deno

JSfetch interopbyimporting the function from runtime

BASIC

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

EndBASIC

DIM resAS STRING' Custom functionres= HTTPGET("https://httpbin.org/anything")PRINT res

Example forLOGIN command

Some info

Playground

TypeLOGIN "usr","pwd" there, and it will invoke a POST request

Browser

Usingreqwest for API calls in REPL

gobasic

REM Custom functionres$= HTTPGET ("https://httpbin.org/anything")PRINT res$

Example

Readme

Browser,Bun,andDeno.

UsesGolang's"net/http" inacustom functioninjectedinto the language.

Berry

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

Berry

# custom functionprint(httpget('https://httpbin.org/anything'))

Example

Browser

JSXMLHttpRequest interop byinvokingemscripten_fetch()from a customhost functioninjected as native function into Berry.

C#

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

Blazor

@usingSystem.Net.Http.Json@inject HttpClient HttpClient@code{vardata=awaitHttpClient.GetFromJsonAsync<JsonElement>("https://httpbin.org/anything");}

Example

Demoby JasonWatmoreDemo source

Browser, alsonative server-side

JSfetch interopbycallingto TSwrapper

OpenSilver

Silverlight / WPF revived in WASM form

usingSystem;usingSystem.Net.Http;HttpClientclient=newHttpClient();stringuri="https://httpbin.org/anything";stringresponseText=awaitclient.GetStringAsync(uri);Console.WriteLine("text: "+responseText);

Doc

Demo

Browser

RestSharp

usingSystem;usingRestSharp;varclient=newRestClient();varreq=newRestRequest("http://httpbin.org/anything");varres=awaitclient.ExecuteGetAsync(req);Console.WriteLine("text: "+res.Content);

Doc

Browser,Node,Bun,andDeno.

wrapperaround.NET's"Http.HttpClient".

System.Net. Http.HttpClient

Standard library

usingSystem;usingSystem.Net.Http;HttpClientclient=newHttpClient();stringuri="https://httpbin.org/anything";stringresponseText=awaitclient.GetStringAsync(uri);Console.WriteLine("body: "+responseText);

Example

Browser,Node,Bun,andDeno.

JSfetch interop(for Node)frommanaged codebyimportinga TSwrapper.

Uno Platform

usingSystem;usingSystem.Net.Http;HttpClientclient=newHttpClient();stringuri="https://httpbin.org/anything";stringtxt=awaitclient.GetStringAsync(uri);Console.WriteLine("text: "+txt);

Example

Tutorial

Browser

Using.NET's"Http.HttpClient".

C / C++

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

Emscripten

#include<emscripten/fetch.h>voidrequestOnSuccess(emscripten_fetch_t*fetch){chardat[fetch->numBytes+1];memcpy(dat,fetch->data,fetch->numBytes);dat[fetch->numBytes]='\0';printf("data: %s \n",dat);emscripten_fetch_close(fetch);}emscripten_fetch_attr_tattr;emscripten_fetch_attr_init(&attr);strcpy(attr.requestMethod,"GET");attr.attributes=EMSCRIPTEN_FETCH_LOAD_TO_MEMORY;attr.onsuccess=requestOnSuccess;emscripten_fetch(&attr,"https://httpbin.org/anything");

Doc

Browser

JSXMLHttpRequest interopmapped to beused inemscripten_fetch().

nxxm/xxhr

#include<xxhr/xxhr.hpp>usingnamespacexxhr;GET("https://httpbin.org/anything"s,   on_response = [](auto res) { std::cout << res.text; });

Example

Doc

Browser,Node.js, andDeno

JSXMLHttpRequest Interop

Crystal

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

lbguilherme/crystal-js

require"js"classXMLHttpRequest <JS::Reference  @[JS::Method]defself.new :self<<-js      return new XMLHttpRequest();    jsend  js_getter responseText :String  js_method send  js_method open(method :String, url :String, async :Int32)endreq=XMLHttpRequest.newreq.open("GET","https://httpbin.org/anything",0)req.sendJS.console.log req.response_text

Readme

Browser, Node.js, and Deno

Manual JSXMLHttpRequest interop by creating thewrapperusingcrystal-js shard.

Dart

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

package:dio

import'package:dio/dio.dart';final dio=Dio();Response response=await dio.get('https://httpbin.org/anything');print(response);

Readme

Browser with Wasm-GC support enabled1

JSXMLHttpRequestinteropinsideBrowserHttpClientAdapter class.

package:fetch_api

import'package:fetch_api/fetch_api.dart';final resp=awaitfetch('https://httpbin.org/anything');final txt=await resp.text();print('${txt}');

Some doc

Browser with Wasm-GC support enabled1,Node.js,andDeno.

JSfetchinteropusingimported by@JS function.

package:fetch_client

import'package:fetch_client/fetch_client.dart';final client=FetchClient(  mode:RequestMode.cors);final uri=Uri.parse('https://httpbin.org/anything');final resp=await client.get(uri);print('${resp.body}');client.close();

Some doc

Browser with Wasm-GC support enabled1,Node.js,andDeno.

Extends theBaseClientbyusingimportedpackage:fetch_api.

package:http

import'package:http/http.dart'as http;final resp=await http.get(Uri.parse('https://httpbin.org/anything'));print('${resp.body}');

Doc

Browser with Wasm-GC support enabled1

JSXMLHttpRequestinteropinsideBrowserClient class.

package:requests

import'package:requests/requests.dart';final resp=awaitRequests.get('https://httpbin.org/anything');print('body: ${resp.content()}');

Example

Readme

Browser with Wasm-GC support enabled1

Wrapper overpackage:http.

package:web

import'package:web/web.dart'as web;final resp=await web.window.fetch('https://httpbin.org/anything'.toJS).toDart;final txt=await resp.text().toDart;print('${txt}');

Example

Doc

Browser with Wasm-GC support enabled1

Directfetch interop withhelpofsome extension types.

dart:js_interop

import'dart:js_interop';@JS()externalJSPromise<Response>fetch(JSString _);extension typeResponse(JSObject _)implementsJSObject {@JS()externalJSPromise<JSString>text();}finalResponse resp=awaitfetch('https://httpbin.org/anything'.toJS).toDart;final txt=await resp.text().toDart;print('body: ${txt}');

Example

Doc

Browser with Wasm-GC support enabled1,Node.js,Bun,andDeno.

Direct JSfetch interop byimporting itandwrapping its promisewith an extension type.

SDK for writing Cloudflare Workers in Dart aka cf_workers.dart

import'package:http/http.dart';import'package:cf_workers/cf_workers.dart';import'package:cf_workers/http.dart';Future<void>main() {returnWorkers((JSRequest req)async {returnfetch(Request('GET',Uri.parse('https://httpbin.org/anything')).toJS);  }).serve();}

Example

Readme

workerd, Cloudflare's JavaScript/ Wasm Runtime

JSfetch interopusing thefetch()imported from CF Workers runtime.

Expression evaluation languages

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

Cel-go

Common Expression Language

// two custom functionsprintln(httpget('https://httpbin.org/anything'))

Example

Doc

Browser,Bun,andDeno.

UsingGolang's"net/http" viamappinga custom function into Cel-go.

Expr

// two custom functionsprintln(httpget('https://httpbin.org/anything'))

Example

Doc

Browser,Bun,andDeno.

UsingGolang's"net/http" viamappinga custom function into Expr-lang.

Forth

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

WAForth

: URL$S" https://httpbin.org/anything" ;( custom word )URL$ HTTPGET

Readme

Browser,NodeJS,Bun,andDeno.

JSfetch interop byinvokinga custom host function,boundinfo Forth's dictionary/namespace.

Golang

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

Golang

import"net/http"resp,err:=http.Get("https://httpbin.org/anything")

fetch options

Browser andNode.js

JSfetch Interop

marwan.io/wasm-fetch

Save 4 MB of wasm binary size

import"marwan.io/wasm-fetch"resp,err:=fetch.Fetch("https://httpbin.org/anything",&fetch.Opts{})iferr==nil {println(string(resp.Body))}

Example

Doc

Browser andNode.js

DirectJSfetch Interop

Nigel2392/requester

import"github.com/Nigel2392/requester"varclient=requester.NewAPIClient()client.Get("https://httpbin.org/anything").Do(func(response*http.Response) {body,err:=io.ReadAll(response.Body)iferr==nil {fmt.Println(string(body))    }  })

Sources

Browser and maybe Node.js

UsesGolang's"net/http"

Hogosuru

SPA framework

import ("github.com/realPy/hogosuru""github.com/realPy/hogosuru/base/fetch""github.com/realPy/hogosuru/base/promise""github.com/realPy/hogosuru/base/response")f,err:=fetch.New("https://httpbin.org/anything",nil)f.Then(func(r response.Response)*promise.Promise {txtpromise,_:=f.Then(func(r response.Response)*promise.Promise {ifprm,err:=r.Text();hogosuru.AssertErr(err) {return&prm      }returnnil    },nil)txtpromise.Then(func(iinterface{})*promise.Promise {fmt.Println(i.(string))returnnil  },nil)returnnil},nil)

Browser

Manual low-level JSfetch andXMLHttpRequest interop usingGo wrappers for Web API:fetch,XHR.

Vecty

UI library

import"io"import"log"import"net/http"gofunc() {resp,_:=http.Get(action.Url)deferresp.Body.Close()body,_:=io.ReadAll(resp.Body)log.Println(string(body))}()

Browser

Has no built-in solutions, just directlyinvokingGolang's"net/http"

Vugu

UI library

import"io"import"log"import"net/http"resp,_:=http.Get("https://httpbin.org/anything")deferresp.Body.Close()body,_:=io.ReadAll(resp.Body)log.Println(string(body))

Example

Possible withDev Container

Browser

Has no built-in solutions, just directly invoking Golang's"net/http"

Yaegi

It's VM / interpreter

import ("fmt";"io";"net/http")resp,_:=http.Get("https://httpbin.org/anything")deferresp.Body.Close()body,_:=io.ReadAll(resp.Body)fmt.Println(string(body))

Example

Some doc

Browser,Bun,andDeno.

Directly invokingGolang's"net/http" viamapping.

Golang-like languages

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

Anko

varhttp=import("net/http")varioutil=import("io/ioutil")varurl="https://httpbin.org/anything"res,_=http.DefaultClient.Get(url)b,_=ioutil.ReadAll(res.Body)println(toString(b))res.Body.Close()
Browser and maybe Node

Directly invokingGolang's"net/http" viamapping.

Risor

url:="https://httpbin.org/anything"resp:=fetch(url)print(resp.text())

Doc

Browser and maybe Node

UsingGolang's"net/http" viamapping.

TengoHTTP

forTengo

fmt:=import("fmt")http:=import("httpclient")resp:=http.request("https://httpbin.org/anything","GET")fmt.print(is_error(resp) ?resp :resp.body)

Readme

Browser,Bun,andDeno.

UsingGolang's"net/http" viamapping.

Java / JVM

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

mirkosertic/Bytecoder

transpile JVM bytecode to Wasm

importde.mirkosertic.bytecoder.api.web.*;finalWindowwin =Window.window();finalConsolecon =Console.console();win.fetch("https://httpbin.org/anything").then(newPromise.Handler<Response>() {@OverridepublicvoidhandleObject(finalResponseresp) {resp.text().then(newStringPromise.Handler() {@OverridepublicvoidhandleString(finalStringtext) {con.log(text);      }    });  }});

Test

Some doc

Browser, Node.js, and Deno

Directfetch
interop usingimportedJSwindow object.

JavaScript

Using browser's own JavaScript VM

Possible, but why?

Libraries to use from JavaScript
Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

libcurl.js

Requires server-side counterpart

libcurl.set_websocket('wss://your-wisp-proxy.yoursite.tld/');letres=awaitlibcurl.fetch('https://httpbin.org/anything');console.log(awaitres.text());

Doc

Browser

Tunneling TCP to WebSocket using protocols "wisp" or "wsproxy" .

JavaScript VM or interpreter compiled to WASM

JavaScript built with Emscripten
Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

quickjs-emscripten

// Host functionconsttxt=awaitfetch('https://httpbin.org/anything');console.log(txt);

Example

Doc

Browser,Bun,Deno,andNode.

JSfetch interop byinjectinga customhost functioninto QuickJS's global namespace.

sebastianwessel/quickjs

constfn=async()=>{// Host functionconstres=awaitfetch('https://httpbin.org/anything');returnres.text();}exportdefaultawaitfn();

Doc

Browser,Bun,Deno,andNode.

Wrapper overquickjs-emscripten.Uses host functionfetch().

JavaScript implemented in .NET
Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

Jint

// custom objecthttp.get('https://httpbin.org/anything');

Example

Readme

Browser

Using.NET's"Http.HttpClient" viamappinga custom object inside JS.

JavaScript implemented in Golang
Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

Goja

constres=httpget('https://httpbin.org/anything');console.log(res);

Example

Some doc

Browser,Bun,andDeno.

UsingGolang's"net/http" viamappinga custom function inside JS.

gojax/fetch

fetch('https://httpbin.org/anything').then(function(res){returnres.text();}).then(function(txt){console.log(txt);exitloop();});

Readme

Browser,Bun,andDeno.

Injecting a custom function into JS.That funcuses the goproxy as HTTP client,which is awrapper for Golang's"net/http".

Otto

constres=httpget('https://httpbin.org/anything');console.log(res);

Example

Some doc

Browser,Bun,andDeno.

UsingGolang's"net/http" viamappinga custom function inside JS.

Kotlin

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

Kotlin/Wasm

still Alpha

importkotlinx.browser.windowwindow.fetch("https://httpbin.org/anything").then {if (it.ok) {    it.text().then {println(it)null    }  }null}

Readme

Browser with Wasm-GC and Wasm-Exception-Handling support enabled1, Node v21 and above, Deno v1.38 and above.

Directfetch interop usingexposed JSwindow object.For Node/Deno, justimport.

Lisp

Clojure-like languages

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

Janet

# custom function(print (httpget`https://httpbin.org/anything`))

Example

Some doc

Browser and maybe Node

JSXMLHttpRequest interop byinvokingemscripten_fetch()from a customhost functioninjected into Janet.

Lua

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

Wasmoon

localresp=fetch('https://httpbin.org/anything'):await()localtext=resp:text():await()print(text)

Example

Some doc

Dev Container

Browser, Node.js, and Deno

Directfetch interop by manually importing it into Lua usinglua.global.set().

Lua implemented in Golang

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

cjoudrey/gluahttp

localhttp=require('http')localres,err=http.request('GET','https://httpbin.org/anything', {headers={    ['User-Agent']='gluahttp/wasm'  }})print(res.body)

Example

Readme

Browser and maybe Node

UsingGolang's"net/http" viamapping.

gopher-lua-libs

localhttp=require('http')localclient=http.client()localreq=http.request('GET','https://httpbin.org/anything')localres,err=client:do_request(req)print(res.body)

Doc

Browser and maybe Node

UsingGolang's"net/http" viamapping.

erdian718/lmodhttpclientaka ofunc/lmodhttpclient

localio=require('io')localhttpclient=require('http/client')localres=httpclient.get('https://httpbin.org/anything')io.copy(res,io.stdout)res:close()

Example

Readme

Browser and maybe Node

UsingGolang's"net/http" viamapping.

Lua dialects

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

Pluto

localhttp=require'pluto:http'http.request('https://httpbin.org/anything')|>print

Browser and maybe Node.

JSXMLHttpRequest interop byinvokingemscripten_fetch().

PHP

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

php-wasm

Fork ofPIB

$url ='https://httpbin.org/anything';$window =newVrzno();$window->fetch($url)->then(function($res) {return$res->text(); })->then(var_dump(...));

Browser,Bun,Deno,Node,andCloudFlare Workers.

Manual JSfetch interop usingvrzno PHP extension.

Pascal

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

Free Pascal

functionhttpGet(url: ShortString;Var str_out:    ShortString): ShortString;external'js';var out_str : ShortString;begin        out_str:= DupeString('' ,255 );        httpGet('https://httpbin.org/anything', out_str);        writeln(out_str);end.

Example

Browser and maybe Node

DirectXMLHttpRequest interop insync modeviaimportingthe JS function into Pascal withmapping.

Perl

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

WebPerl

use WebPerlqw/js js_new sub_once/;my$xhr = js_new('XMLHttpRequest');$xhr->addEventListener('load', sub_once {print'Done:'.$xhr->{responseText};});$xhr->open('GET','https://httpbin.org/anything', 0);$xhr->send();

Forum post

Browser, Node.js, and Deno

Manual JSXMLHttpRequest interop usingWebPerl.pm module.

Prolog

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

Scryer Prolog

:-use_module(library(wasm)).
?- js_eval("const xhr=new XMLHttpRequest(); xhr.open('GET','https://httpbin.org/anything',false); xhr.send(); xhr.responseText;", Txt), format("~s", [Txt]).

<--

Browser

Manual JSXMLHttpRequest interop usingjs_eval predicate.

SWI-Prolog

fetch('https://httpbin.org/anything',text,Out).

<--

Doc

Browser and Node

JSfetchinterop by declaring thepredicate.

trealla-js

js_eval("return fetch('https://httpbin.org/anything').then(r => r.text());",Txt).

Readme

Example code works inPlayground

Browser andNode

Manual invoking of JSfetch usingjs_eval predicate.

Prolog implemented in Golang
Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

ichiban/prolog

% custom predicatehttpget("https://httpbin.org/anything",RespTxt).

Readme

Browser,Bun,andDeno.

UsingGolang's"net/http" viamappinga custom predicate inside Prolog.

Python

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

RustPython

frombrowserimportfetchfetch('https://httpbin.org/anything').then(lambdaresp:print((resp)))

Example

Playground

source of demo

Browser,Node.js, and maybe Deno

JSfetch Interop

Pyodide

frompyodide.httpimportpyfetchresponse=awaitpyfetch("https://httpbin.org/anything")

Also note that thepyodide-http isbundled in Pyodide.

pyodide.http Doc

Browser, Node.js, andmaybe Deno

JSfetch Interop

koenvo/pyodide-http

requestsandurlopen in Pyodide

# needs `await micropip.install(['pyodide-http', 'requests'])`importpyodide_httppyodide_http.patch_all()importrequestsresponse=requests.get("https://httpbin.org/anything")

Supported packages

Playground

Browser and maybe Node.js

JSfetch andXMLHttpRequest Interopusing Pyodide'sjs scope.

urllib3

Since2.2.0

importmicropipawaitmicropip.install('urllib3')importurllib3res=urllib3.request('GET','https://httpbin.org/anything')print(res.data.decode('utf-8'))
# using requestsimportmicropipawaitmicropip.install('requests')importrequestsres=requests.get('https://httpbin.org/anything')print(res.text)

Doc

Playground

Browseronly (yet)

JSfetch interoporXMLHttpRequest interopiffetchis not available.

GPython

importhttpclientprint(httpclient.Get('https://httpbin.org/anything'))

Example

Some doc

Browser,Bun,andDeno.

UsingGolang's"net/http" viamapping.

PyScript

frompyodide.httpimportpyfetch,FetchResponseimportasyncioasyncdefreq()->FetchResponse:response=awaitpyfetch("https://httpbin.org/anything")print(awaitresponse.string())asyncio.ensure_future(req())

Example

Doc

Browser

Usespyodide's facilities

Panel

response=requests.get("https://httpbin.org/anything")

Doc

Browser

Employskoenvo/pyodide-http. Also directXMLHttpRequest interop for image data.

JupyterLite

# using Pandasimportpyodide_http;pyodide_http.patch_all()importpandasaspddata=pd.read_json('https://httpbin.org/json')data
# using js.fetchfromjsimportfetchres=awaitfetch('https://httpbin.org/anything')text=awaitres.text()print(text)
# using requestsimportmicropip;awaitmicropip.install(['requests'])importpyodide_http;pyodide_http.patch_all()importrequestsres=requests.get("https://httpbin.org/anything")print(res.text)

Doc

Playground

Browser

Employingpyodide-http andPyodide's own facilities.

micropython-wasm

importjsfetch=JS('fetch')response=fetch('https://httpbin.org/anything').wait()text=response.text().wait()print(text)

Readme

Browser and Node.js

Directfetch interop usingjs module, by employing Emscripten APIs.

Stlite

a port ofStreamlit to Wasm

frompyodide.httpimportpyfetchimportstreamlitasstresponse=awaitpyfetch("https://httpbin.org/anything")body=awaitresponse.string()st.write(body)

Readme

Playground

Browser

Usespyodide'sfacilities.

PocketPy

lightweight Python 3.x

# custom moduleimporthttpprint(http.get('https://httpbin.org/anything'))

Example

Some doc

Browser

JSXMLHttpRequest interop byinvokingemscripten_fetch()from a customhost functioninjected as module function into Python.

Python-like languages

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

soIu/rpython

It's compiler

fromjavascriptimportObject,asynchronous,JSON@asynchronousdefsend_request(url):fetch=Object('fetch')res=fetch.call(url).wait()text=res['text'].call().wait()print(text)returntextdeftarget(*args):returnmain,Nonedefmain(argv):send_request('https://httpbin.org/anything')return0if__name__=='__main__':importsysmain(sys.argv)

Example

Some doc

Browser, Node.js, and Deno

Directfetch interop usingjavascript module, by employing Emscripten APIs.

R

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

webR

df<- read.csv("https://httpbin.org/anything")print(df)//Allworks: read.table()variants, download.file(), scan(), url(),etc

Doc

Browser and Node

Implementedxhr transport which usesJSXMLHttpRequest interop bycallingweb workerusing Emscripten APIs.

Rebol

Rebol-like languages

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

Rye

go does { get https://httpbin.org/anything |print }

Some doc for embedding

Browser

UsingGolang's"net/http" viamappingto a Ryeword.

Ruby

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

ruby.wasm

require'js'resp=JS.global.fetch('https://httpbin.org/anything').awaitputsresp.text.await

Doc

Browser,Node.js, and maybe Deno

DirectJSfetch Interop

Rust

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

wasm-bindgen

let window = web_sys::window().unwrap();let resp_val =JsFuture::from(  window.fetch_with_str("https://httpbin.org/anything")).await?;

Example

Fetch API docs

Demo

Prints to browserconsole,source

Browser,Node.js,andDeno

JSfetch Interop

Rust SDK for writing Cloudflare Workers aka workers-rs

letmut resp =Fetch::Url("https://httpbin.org/anything".parse().unwrap(),).send().await?;let txt = resp.text().await?;

Doc

workerd, Cloudflare's JavaScript/ Wasm Runtime

JSfetch interop usingwasm-bindgen

ehttp

let request = ehttp::Request::get("https://httpbin.org/anything");ehttp::fetch(request,move |result: ehttp::Result<ehttp::Response>|{println!("Text: {:?}", result.unwrap().text());});

Example

Doc

Demo

Browser, Node.js, and Deno.

Alsonative

JSfetch Interop usingwasm-bindgen

httpc

let uri =Uri::from_static("https://httpbin.org/anything");let req =Request::get(uri).body(None).unwrap();let client = web_sys::window();let resp = client.issue(req).await.unwrap();println!("{}", resp.body());

Test

Doc

Browser, Node.js, and Deno.

Alsonative

JSfetch Interop usingwasm-bindgen

http-client

use http_client::HttpClient;use http_types::{Method,Request};use http_client::wasm::WasmClientasClient;let client =Client::new();let req =Request::new(Method::Get,"https://httpbin.org/anything");client.send(req).await.unwrap();dbg!(client);

Example

Doc

Browser, Node.js, and Deno

Alsonative (and others).

JSfetch Interop usingwasm-bindgen

Gloo'sgloo-net

use gloo_net::http::Request;let resp =Request::get("https://httpbin.org/anything").send().await.unwrap();

Doc

Demo

source

Browser, Node.js, and Deno

JSfetch Interop usingwasm-bindgen

Iced

// uses reqwestlet txt = reqwest::get("https://httpbin.org/anything").await?.text().await?;log::info!("text: {}", txt);

Browser

Has no built-in solutions, just uses any suitable 3rd-party lib, such as:reqwest.

Leptos

// uses reqwasm or gloo_net for CSRuse leptos_dom::logging::console_log;let txt = reqwasm::http::Request::get("https://httpbin.org/anything").send().await?.text().await?;console_log(txt.as_str());

Browser

Also server-side rendering (SSR)

Has no built-in solutions, just uses any suitable 3rd-party lib, such as:reqwest,gloo_net,reqwasm.

localghost

use localghost::prelude::*;use localghost::{log, net};let res = net::Request::get("https://httpbin.org/anything").send().await?;log::info!("text: {:?}", res.body_string().await?);

Doc

Browser and maybe Node

JSfetch Interop usingwasm-bindgen

MoonZoon

use zoon::{println,*};let txt = reqwest::get("https://httpbin.org/anything").await?.error_for_status()?.text().await?;println!("text: {}", txt);

Example

Doc

Browser

Has no built-in solutions, just uses any suitable 3rd-party lib, such as:reqwest.

quad-net

Plugin forminiquad andmacroquad

use quad_net::http_request::RequestBuilder;letmut request =RequestBuilder::new("https://httpbin.org/anything").send();loop{ifletSome(data) = request.try_recv(){info!("Done! {}", data.unwrap());}next_frame().await;}

Example

Some Readme

Browser

JSXMLHttpRequestinteropin theimported host function.

reqwest

let txt = reqwest::get("https://httpbin.org/anything").await?.text().await?;println!("Text: {:?}", txt);

Doc

Browser, Node.js, and Deno

Alsonative

JSfetch Interop usingwasm-bindgen

reqwasm

use reqwasm::http::Request;let resp =Request::get("https://httpbin.org/anything").send().await.unwrap();

Example

Doc

Browser, Node.js, and Deno

Wrapper forgloo_net

sauron

use sauron::dom::{Http, spawn_local};spawn_local(asyncmove{let txt =Http::fetch_text("https://httpbin.org/anything").await.unwrap();  log::trace!("{}", txt);});

Doc

Browser

Also server-side rendering (SSR)

JSfetch interop usingwasm-bindgen

Seed

use seed::{prelude::*,*};let response =fetch("https://httpbin.org/anything").await?;let body = response.text().await?;

Example

Browser, Node.js, and Deno

JSfetch interop usingwasm-bindgen

surf

letmut resp = surf::get("https://httpbin.org/anything").await?;println!("{}", resp.body_string().await?);

Example

Doc

Browser, Node.js, and Deno

Alsonative

Useshttp-rs/http-client as WASM backend

sycamore

// uses reqwasmuse reqwasm::http::Request;let url ="https://httpbin.org/anything";let res =Request::get(&url).send().await?;let txt = res.text().await?;log::info!("{}", txt);

Browser

Has no built-in solutions, just uses any suitable 3rd-party lib, such as:reqwasm.

Scripting languages for Rust

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

Rune

let req = http::get("https://httpbin.org/anything").await?;let txt = req.text().await?;println(txt);

Some doc

Playground

Browser

Usesreqwest.

Starlark

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

starlark-go

# custom functionprint(httpget('https://httpbin.org/anything'))

Example

Readme

Browser,Bun,andDeno.

UsingGolang's"net/http" viamappinga custom function inside Starlark.

starlark-go-nethttp

res=http.get('https://httpbin.org/anything')print(res.body)

Readme

Browser,Bun,andDeno.

UsingGolang's"net/http" viamapping.

qri-io/starlib

"Starlark's missing stdlib"

load('http.star','http')res=http.get('https://httpbin.org/anything')print(res.body())

Doc

Browser,Bun,andDeno.

UsingGolang's"net/http" viamapping.

starlight-go/starlight

# custom functionprint(httpget('https://httpbin.org/anything'))

Example

Readme

Browser,Bun,andDeno.

UsingGolang's"net/http" viamappinga custom function inside Starlark.

Starlight Enhanced

Maintained fork of Starlight

# custom functionprint(httpget('https://httpbin.org/anything'))

Example

Readme

Browser,Bun,andDeno.

UsingGolang's"net/http" viamappinga custom function inside Starlark.

Swift

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

SwiftWasm

import JavaScriptEventLoopimport JavaScriptKitJavaScriptEventLoop.installGlobalExecutor()letfetch=JSObject.global.fetch.function!letresp=try!awaitJSPromise(fetch("https://httpbin.org/anything").object!)!.valuelettext=try!awaitJSPromise(resp.text().object!)!.valueprint(text)

Browser,Node.js, and Deno

Directfetch interop usingJavaScriptKit framework

Tcl

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

criTiCaL

# custom commandputs [httpget"https://httpbin.org/anything"]

Example

Readme

Browser,Bun,andDeno.

UsesGolang's"net/http" inacustom commandinjectedinto the language.

Wacl

set func_ptr_number 2puts [::wacl::jscall$func_ptr_number"string""string""https://httpbin.org/anything"]

Needs a JavaScript-side function registered usingjswrap():

wacl.onReady(function(interpreter){constwrappedFuncName=interpreter.jswrap(function(ptrUrl){consturl=interpreter.ptr2str(ptrUrl);constxhr=newXMLHttpRequest();xhr.open('GET',url,false);xhr.send();returninterpreter.str2ptr(xhr.responseText);},'string','string');});

Readme

Demo / Playground

Browser

Manual JSXMLHttpRequest interop byregisteringa function on JS side usingjswrap() via EmscriptenaddFunction() APIand thencalling itusing::wacl::jscallby its registration number.

Wonkey

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

Wonkey/httprequest

Local request:=New HttpRequestrequest.ReadyStateChanged= Lambda()If request.ReadyState= ReadyState.DoneThenPrint"Body:"+ request.ResponseTextEndEndrequest.Open("GET","https://httpbin.org/anything")request.Send()

Some doc

Browser

JSfetch interopusing Emscripten APIs.

Standalone and server-side runtimes (mostly WASI and WASI-Socket-enabled), incl containers, FaaS, Edge Computing, etc

AssemblyScript

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

wasi-http

implementations:

  1. wasmtime-wasi-http

  2. dispatchrun/wasi-go

import{Console}from"as-wasi/assembly";import{request}from"./request";exportfunctioncabi_realloc(a:usize,b:usize,c:usize,len:usize):usize{returnheap.alloc(len);}letresponse=request("GET","https://httpbin.org/anything",null,[{name:"User-Agent",value:"wasi-http"}]);Console.log(response.Body);

Example

Readme

Dev Containerby brendandburns

  1. Wasmtime version 9.0 and above.
  2. Wazero inwasi-go version 0.7 and above

Calling toimported

  1. Wasmtime'shost function,which, in turn,performs real request usinghyper:https,http.

  2. Wazero'shost function,whichperforms a request using"net/http".

C# / .Net

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

Extism Plug-in Development Kit (PDK) for .NET

usingExtism;varreq=newHttpRequest("https://httpbin.org/anything"){Method=HttpMethod.GET};varres=Pdk.SendRequest(req);Pdk.SetOutput(res.Body);

Doc

Dev Container

  • Extismuses Wasmtime
  • Extism CLIuses Wazero

CallingC-level-importedruntime'shost functionexported for plugins,whichmakes actual request usingureq.

Spin SDK for .NET

usingFermyon.Spin.Sdk;usingSystem.Net;varreq=newHttpRequest{Url="https://httpbin.org/anything"};varresp=HttpOutbound.Send(req);

Example

Doc

Spin(usesWasmtime)

C levelbinding to
Spin'shost function.

wasi-http

implementations:

  1. wasmtime-wasi-http

  2. dispatchrun/wasi-go

// *Still* identical to wasi-experimental-http's code.usingWasi.Http;varclient=newHttpClient(newWasiHttpHandler());varresult=awaitclient.GetAsync("https://httpbin.org/anything",System.Threading.CancellationToken.None);varcontent=awaitresult.Content.ReadAsStringAsync();Console.WriteLine(content);

Example

Readme

Dev Containerby brendandburns

  1. Wasmtime version 9.0 and above.
  2. Wazero inwasi-go version 0.7 and above

Sequence: .Net -> C -> WASI

CallingimportedC-levelMono bindingwhichcallsgenerated(bywit-bindgen from thewit template)code, which callsimported

  1. Wasmtime'shost function,which, in turn,performs real request usinghyper:https,http.

  2. Wazero'shost function,whichperforms a request using"net/http".

C / C++

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

Extism Plug-in Development Kit (PDK) for C

#defineEXTISM_IMPLEMENTATION#include"extism-pdk.h"#include<stdint.h>#include<string.h>int32_tEXTISM_EXPORTED_FUNCTION(httpget) {constchar *r ="{\"url\":\"https://httpbin.org/anything\"}";  ExtismHandle req =extism_alloc_buf_from_sz(r);  ExtismHandle res =extism_http_request(req,0);extism_output_set_from_handle(res,0,extism_length(res));return0;}

Doc

Dev Container

  • Extismuses Wasmtime
  • Extism CLIuses Wazero

CallingC-level-importedruntime'shost functionexported for plugins,whichmakes actual request usingureq.

httpclient_wasmedge_socket

// no SSL support yetstd::array<char,4096> buf{};fetchIO *io = fetchGetURL("http://httpbin.org/anything","4");int nbytes = fetchIO_read(io, buf.data(), buf.size());fetchIO_close(io);std::cout << buf.data() << std::endl;

Example

WasmEdge

Rawsocket writeusingWasmEdge Socket SDK for C/C++, whichimports Wasmedge's implementation of WASI Socket

wasi-http

implementations:

  1. wasmtime-wasi-http

  2. dispatchrun/wasi-go

// snippet, expand it for full codetypes_outgoing_request_trequest=types_new_outgoing_request(&method,&path,&query,&scheme,&domain,headers);response=default_outgoing_http_handle(request,NULL);types_future_incoming_response_get(response,&result);types_incoming_response_consume(result.val.ok,&stream);streams_read(stream,len,&body_res,&err);

#include"proxy.h"// Generated by wit-bindgen// from https://github.com/WebAssembly/wasi-http/tree/main/wit#include<stdio.h>voidhttp_handle(uint32_targ,uint32_targ0) {}intmain() {types_headers_theaders=types_new_fields(NULL);types_method_tmethod= {.tag=TYPES_METHOD_GET};types_scheme_tscheme= {.tag=TYPES_SCHEME_HTTPS};proxy_string_tpath,domain,query;proxy_string_set(&domain,"httpbin.org");proxy_string_set(&path,"/anything");proxy_string_set(&query,"");types_outgoing_request_trequest=types_new_outgoing_request(&method,&path,&query,&scheme,&domain,headers);types_future_incoming_response_tresponse;response=default_outgoing_http_handle(request,NULL);proxy_result_incoming_response_error_tresult;types_future_incoming_response_get(response,&result);types_incoming_stream_tstream;types_incoming_response_consume(result.val.ok,&stream);int32_tlen=16*1024;proxy_tuple2_list_u8_bool_tbody_res;streams_stream_error_terr;streams_read(stream,len,&body_res,&err);printf("Response body: %s\n",body_res.f0.ptr);proxy_tuple2_list_u8_bool_free(&body_res);types_drop_outgoing_request(request);streams_drop_input_stream(stream);types_drop_incoming_response(result.val.ok);return0;}

Example

Readme

Dev Containerby brendandburns

  1. Wasmtime version 9.0 and above.
  2. Wazero inwasi-go version 0.7 and above

Callinga functiongeneratedbywit-bindgen from thewit template,which calls the

  1. Wasmtime'shost function,which, in turn,performs real request usinghyper:https,http.

  2. Wazero'shost function,whichperforms a request using"net/http".

Golang (Tinygo)

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

Capsule

import (    hf"github.com/bots-garden/capsule/capsulemodule/hostfunctions")res,err:=hf.Http("https://httpbin.org/anything","GET",nil,"")

Example

HTTP request docs

wazero

wazero's Host Functions feature

Extism Plug-in Development Kit (PDK) for (Tiny)Go

import"github.com/extism/go-pdk"req:=pdk.NewHTTPRequest("GET","https://httpbin.org/anything")resp:=req.Send()pdk.OutputMemory(resp.Memory())

Example

Doc

Extismuses Wasmtime

CallingC-level-importedruntime'shost functionexported for plugins,whichmakes actual request usingureq.

knqyf263/go-plugin

hostFunctions:=protobufs.NewHostFunctions()resp,err:=hostFunctions.HttpGet(ctx,&protobufs.HttpGetRequest{Url:"https://httpbin.org/anything"})

Readme

Dev Container

go-pluginuses wazero

Invoking the
boundhost function.

Spin SDK for (Tiny)Go

import (    spinhttp"github.com/fermyon/spin/sdk/go/http")resp,err:=spinhttp.Get("https://httpbin.org/anything")

Spin(usesWasmtime)

C levelbinding to
Spin'shost function.

wasi-http

implementations:

  1. wasmtime-wasi-http

  2. dispatchrun/wasi-go

import ("io/ioutil""net/http"  wasiclient"github.com/dev-wasm/dev-wasm-go/client")client:= http.Client{Transport: wasiclient.WasiRoundTripper{},}response,err:=client.Get("https://httpbin.org/anything")deferresponse.Body.Close()body,err:=ioutil.ReadAll(response.Body)iferr==nil {println(string(body))}

Example

Readme

Dev Containerby brendandburnsneeds plenty of RAM to compile (~4G), so may cause OOM on 2-core instance

  1. Wasmtime version 9.0 and above.
  2. Wazero inwasi-go version 0.7 and above

Sequence: Go -> C -> WASI

Callingamethodgeneratedbywit-bindgen from thewit template.That methodcallsthe generated C-level-boundfunction,whichcallstheimported

  1. Wasmtime'shost function,which, in turn,performs real request usinghyper:https,http.

  2. Wazero'shost function,whichperforms a request using"net/http".

wasi-http-go

import ("io";"log";"net/http" _"github.com/ydnar/wasi-http-go/wasihttp")req,_:=http.NewRequest("GET","https://httpbin.org/anything",http.NoBody)resp,_:=http.DefaultClient.Do(req)deferresp.Body.Close()body,_:=io.ReadAll(resp.Body)log.Println(string(body))

Example

How to run

Dev Container

Runtime supporting wasip2-http (only Wasmtime at the moment)

Wrapper forwasi-http usingoverrides.

dispatchrun/net

f.k.a. stealthrocket/net

import ("fmt" ;"io" ;"net/http"  _"github.com/dispatchrun/net/http")response,err:=http.Get("http://httpbin.org/anything")iferr!=nil {fmt.Println(err)}deferresponse.Body.Close()body,err:=io.ReadAll(response.Body)iferr==nil {fmt.Println(string(body))}

Readme

Dev Container

Wazero and WasmEdge

Hotpatching on module importhttp.DefaultTransport withwasip1.DialContextwhich refers toimportedsock_conn() in the case of WasmEdgeand tosyscall.Connect() in the case of Wazero.

VMware OCTO / Wasm Workers Server

import ("log";"net/http""github.com/vmware-labs/wasm-workers-server/kits/go/worker")req,_:=http.NewRequest(http.MethodGet,"https://httpbin.org/anything",nil)res,_:=worker.SendHttpRequest(req)deferres.Body.Close()body,_:=io.ReadAll(res.Body)log.Println(string(body))

Example

Doc

Wasm Workers ServerusesWasmtime

Calling toGo-wrapped, toC-wrapped, toC-level importedhost functionwhichmakesrequest usingreqwest.

Haskell

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

Extism Plug-in Development Kit (PDK) for Haskell

moduleMainwhereimportExtism.PDKimportExtism.PDK.HTTPhttps_get=dolet url="https://httpbin.org/anything"let req= newRequest url  resp<- sendRequest reqNothing  outputMemory (memory resp)foreignexport ccall"https_get" https_get::IO()main= https_get

Example

Doc

Extismuses Wasmtime

Callingimportedruntime'shost functionexported for plugins,whichmakes actual request usingureq.

Java

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

dicej/spin-teavm-example

Usesforked TeaVM as compiler.

importwit_wasi_outbound_http.WasiOutboundHttp.*;Result<Response,HttpError>result =WasiOutboundHttp.request(newRequest(Method.GET,"https://httpbin.org/anything",newArrayList<>(),newArrayList<>(),null));Responseresp =result.getOk();Stringbody =newString(resp.body,UTF_8);

Example

Readme

Spin(usesWasmtime)

DirectinvocationofimportedSpin'shost function.

JavaScript and TypeScript

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

wasmedge-quickjs

import{fetch}from'http'constres=awaitfetch('https://httpbin.org/anything')print(awaitres.text())

Doc

Dev Container

WasmEdge

Distinguished by URL schemeraw socket writeto(1)WasiTcpConnwhich iswrapperto Wasmedge's implementation of WASI Socketor(2)WasiTlsConnwhich iswrappertowasmedge_rustls_api.

Extism Plug-in Development Kit (PDK) for JavaScript

functionhttps_get(){letresp=Http.request({url:'https://httpbin.org/anything',method:'GET',headers:{'User-Agent':'extism_pdk'}},null);Host.outputString(resp.body);}module.exports={ https_get}

Example

Some doc

Extismuses Wasmtime

Http objectinjected into QuickJS'sglobal namespace. Itcalls thehttp::request()fromExtism PDK for Rust.

Spin SDK for JavaScript

constresp=awaitfetch('https://httpbin.org/anything');constdecoder=newTextDecoder('utf-8');constbody=decoder.decode(awaitresp.arrayBuffer());

Example

Spin(usesWasmtime)

InvocationofboundJS SDK function,whichcallsviaRust Spin SDKSpin'shost function.

Spin SDK for TypeScript

constresp=awaitfetch('https://httpbin.org/anything');constbody=awaitresp.text();

Example

Spin(usesWasmtime)

InvocationofboundJS SDK function,whichcallsviaRust Spin SDKSpin'shost function.

VMware OCTO / Wasm Workers Server

constresp=awaitfetch('https://httpbin.org/anything');consttxt=awaitresp.text();console.log(txt);

Example

Doc

Wasm Workers ServerusesWasmtime

Callingbound to JSsend_http_request()thehost function
whichmakesrequest usingreqwest.

MoonBit

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

Extism Plug-in Development Kit (PDK) for MoonBit

Experimental

pubfnhttps_get() ->Int{let req:Unit = @http.new_request(    @http.Method::GET,"https://httpbin.org/anything",)let resp:Unit = req.send()  resp.output()return0}
  • Extismuses Wasmtime
  • Extism CLIuses Wazero

Callingimportedruntime'shost functionexported for plugins,whichmakes actual request usingureq.

Prolog

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

trealla-spin

Spin SDK for Prolog

:-use_module(library(spin)).http_fetch("https://httpbin.org/anything",Resp,[]),write(Resp),nl.

Example

Doc

Dev Container

Spin(usesWasmtime)

Invokingwasi-outbound-httpbybinding tohttp_fetch predicate.

Python

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

componentize-py

importpoll_loopfromproxy.imports.typesimport (SchemeHttps,OutgoingRequest )req=OutgoingRequest(Fields.from_list([]))req.set_scheme(SchemeHttps())req.set_authority('httpbin.org')req.set_path_with_query('/anything')resp=awaitpoll_loop.send(req)stream=poll_loop.Stream(resp.consume())buf=b''whileTrue:chunk=awaitstream.next()ifchunkisNone:breakelse:buf+=chunkprint(buf.decode('utf-8'))

Example

Readme

Wasmtime version 15.0, maybe incl. Spin.

Genetaring Python bindings to wasi-http based onwit files under the scenes duringcomponentize process.

Extism Plug-in Development Kit (PDK) for Python

importextism@extism.plugin_fndefhttpget():res=extism.Http.request('https://httpbin.org/anything')extism.output_str(res.data_str())

Example

Readme

Dev Container

  • Extismuses Wasmtime
  • Extism CLIuses Wazero

Http.request() methodcallstheFFI functioninjected into Python's "native"ffi module.Itcalls thehttp::request()fromExtism PDK for Rust.

Spin SDK for Python

fromspin_httpimportRequest,http_sendresponse=http_send(Request('GET','https://httpbin.org/anything',   {},None))print(str(response.body,'utf-8'))

Example

Spin(usesWasmtime)

A Pythonspin_http modulecallsimportedviaRust Spin SDKSpin'shost function.

Rust

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

Extism Plug-in Development Kit (PDK) for Rust

use extism_pdk::*;#[plugin_fn]pubfnhttps_get(_:()) ->FnResult<Memory>{let req =HttpRequest::new("https://httpbin.org/anything");let resp = http::request::<()>(&req,None)?;Ok(resp.into_memory())}

Possible withDev Containerby brendandburns

  • Extismuses Wasmtime
  • Extism CLIuses Wazero

CallingC-level-importedruntime'shost functionexported for plugins,whichmakes actual request usingureq.

http_req_wasi

use http_req::request;letmut writer =Vec::new();let res = request::get("https://httpbin.org/anything",&mut writer).unwrap();println!("body: {}",String::from_utf8_lossy(&writer));

Example

Doc

WasmEdge

Writes towasmedge_wasi_socket stream.For SSL, the stream iswrappedwithrustls's stream.

Spin SDK for Rust

letmut res = spin_sdk::http::send(  http::Request::builder().method("GET").uri("https://httpbin.org/anything").body(None)?,)?;

Spin(usesWasmtime)

CallingimportedSpin'shost function.

reqwest_wasi

as part of

WasmEdge Sockets

Any code based on WasmEdge's forks oftokio-rsormioisexpected to work in Wasmedge runtime

let res = reqwest::get("https://httpbin.org/anything").await?;let body = res.text().await?;println!("text: {}", body);

Example

WasmEdge

Wrappinginternal stream withWasmEdgeTls, which is built on top ofWasmEdge's implementation of WASI Socket.

Waki

new gen ofwasi-http-client

use waki::Client;let res =Client::new().get("https://httpbin.org/anything").send().unwrap();let body =String::from_utf8(  res.body().unwrap()).unwrap();println!("body:{}", body);

Example

Some doc

Dev Container

Wasmtime version17 and above

Usesimportedwasmtime-wasi-http.

wasi-http

implementations:

  1. wasmtime-wasi-http

  2. dispatchrun/wasi-go

let headers = types::new_fields(&[("User-agent","WASI-HTTP")]);let request = types::new_outgoing_request(  types::MethodParam::Get,"/anything","",Some(types::SchemeParam::Https),"httpbin.org", headers,);let future_response = default_outgoing_http::handle(request,None);types::drop_outgoing_request(request);let response = types::future_incoming_response_get(future_response).ok_or_else(||anyhow!("response is available immediately"))?.map_err(|err|anyhow!("response error: {err:?}"))?;types::drop_future_incoming_response(future_response);let stream = types::incoming_response_consume(response).map_err(|()|anyhow!("response has no body stream"))?;letmut body =Vec::new();letmut is_eof =false;while !is_eof{let(mut chunk, stream_at_end) = streams::read(stream, u64::MAX)?;  is_eof = stream_at_end;  body.append(&mut chunk);}streams::drop_input_stream(stream);types::drop_incoming_response(response);println!("body: {}",str::from_utf8(&body).unwrap());

Example

Readme

Possible withDev Containerby brendandburns

  1. Wasmtime version 9.0 and above.
  2. Wazero inwasi-go version 0.7 and above

Rust codegenerated(bywit-bindgen from thewit template)calls imported

  1. Wasmtime'shost function,which, in turn,performs real request usinghyper:https,http.

  2. Wazero'shost function,whichperforms a request using"net/http".

VMware OCTO / Wasm Workers Server

let req =Request::builder().uri("https://httpbin.org/anything").body(String::new()).unwrap();let res = bindings::send_http_request(req).unwrap();let data = res.body();let txt =String::from_utf8_lossy(&data);println!("text: {txt}");

Example

Doc

Wasm Workers ServerusesWasmtime

Callingimportedhost functionwhichmakesrequest usingreqwest.

Virgil

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

Extism Plug-in Development Kit (PDK) for Virgil

varreq=Http.newRequest(Method.GET,"https://httpbin.org/anything");defres=req.send(null);res.output();

Example

Readme

  • Extismuses Wasmtime
  • Extism CLIuses Wazero

CallingC-level-importedruntime'shost functionexported for plugins,whichmakes actual request usingureq.

Zig

Product / ImplementationTLDR: UsageTLDR: Example codeDocOnline demoWASM RuntimeInternals: method to do real request

Extism Plug-in Development Kit (PDK) for Zig

conststd=@import("std");constextism_pdk=@import("extism-pdk");constallocator=std.heap.wasm_allocator;exportfnhttps_get()i32 {constplugin=extism_pdk.Plugin.init(allocator);varreq=extism_pdk.http.HttpRequest.init(allocator,"GET","https://httpbin.org/anything");deferreq.deinit();req.setHeader("User-Agent","extism_pdk")catchunreachable;constresp=plugin.request(req,null)catchunreachable;deferresp.deinit();plugin.outputMemory(resp.memory);return0;}

Example

Some doc

Extismuses Wasmtime

Callingimportedruntime'shost functionexported for plugins,whichmakes actual request usingureq.

Spin SDK for Zig

constspin=@import("spin");constreq=spin.http.Request{ .method=.GET,   .url="https://httpbin.org/anything" };constres=spin.http.send(req)catchunreachable;

Example

Spin(usesWasmtime)

Callingto C-levelimportofSpin'shost function.

Footnotes

  1. Firefox 120+, and all based on Chrome(ium) 119+.2345678

About

(Wannabe-awesome) list of methods to make outbound HTTP(S) requests from within WebAssembly in many languages

Topics

Resources

License

Stars

Watchers

Forks


[8]ページ先頭

©2009-2025 Movatter.jp