#http #https #client #wasmedge #webassembly

http_req_wasi

HTTP client for the WasmEdge network socket API. Derived from the http_req library.

2 releases

0.10.1 Oct 1, 2022
0.10.0 Sep 29, 2022

#1927 in Network programming

Download history 16/week @ 2022-09-24 46/week @ 2022-10-01 14/week @ 2022-10-08 13/week @ 2022-10-15 25/week @ 2022-10-22 26/week @ 2022-10-29 58/week @ 2022-11-05 2/week @ 2022-11-12 24/week @ 2022-11-19 6/week @ 2022-11-26

111 downloads per month

MIT license

110KB
2.5K SLoC

http_req_wasi

Simple and lightweight HTTP client for the low level wasmedge_wasi_socket library. It is to be compiled into WebAssembly bytecode targets and runs in the WasmEdge Runtime as a lightweight and secure alternative to natively compiled apps in Linux container.

This project is forked and derived from the http_req project created by jayjamesjay.

Example

Basic GET request

use http_req::request;

fn main() {
    let mut writer = Vec::new(); //container for body of a response
    let res = request::get("http://eu.httpbin.org/get?msg=WasmEdge", &mut writer).unwrap();

    println!("Status: {} {}", res.status_code(), res.reason());
    println!("Headers {}", res.headers());
    println!("{}", String::from_utf8_lossy(&writer));
}

How to use:

[dependencies]
http_req_wasi  = "0.10"

HTTPS support

The HTTP and HTTPS APIs are the same. But you will need to get the WasmEdge https_req plugin and unzip it into the plugin directory of your WasmEdge install.

See examples here.

Dependencies

~175KB