Skip to content

Commit ebffc08

Browse files
authored
Merge pull request #222 from saulecabrera/introduce-http-module
Introduce the `http` module
2 parents 539494d + bb6b18d commit ebffc08

5 files changed

Lines changed: 30 additions & 55 deletions

File tree

tests/rust/wasm32-wasip3/src/bin/http-fields.rs

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,5 @@
1-
extern crate wit_bindgen;
2-
3-
wit_bindgen::generate!({
4-
inline: r"
5-
package test:test;
6-
7-
world test {
8-
import wasi:http/types@0.3.0-rc-2026-02-09;
9-
include wasi:cli/command@0.3.0-rc-2026-02-09;
10-
}
11-
",
12-
additional_derives: [PartialEq, Eq, Hash, Clone],
13-
features:["clocks-timezone"],
14-
generate_all
15-
});
16-
17-
use wasi::http::types::Fields;
18-
use wasi::http::types::HeaderError;
1+
use test_wasm32_wasip3::cli::{export, exports::wasi::cli::run::Guest};
2+
use test_wasm32_wasip3::http::wasi::http::types::{Fields, HeaderError};
193

204
fn test_empty_fields_inner(fields: Fields) {
215
assert!(!fields.has("foo"));
@@ -348,7 +332,7 @@ fn test_field_name_case_insensitivity() {
348332

349333
struct Component;
350334
export!(Component);
351-
impl exports::wasi::cli::run::Guest for Component {
335+
impl Guest for Component {
352336
async fn run() -> Result<(), ()> {
353337
test_empty_fields();
354338
test_fields_with_foo();

tests/rust/wasm32-wasip3/src/bin/http-request.rs

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,8 @@
1-
extern crate wit_bindgen;
2-
3-
wit_bindgen::generate!({
4-
inline: r"
5-
package test:test;
6-
7-
world test {
8-
import wasi:http/types@0.3.0-rc-2026-02-09;
9-
include wasi:cli/command@0.3.0-rc-2026-02-09;
10-
}
11-
",
12-
additional_derives: [PartialEq, Eq, Hash, Clone],
13-
features:["clocks-timezone"],
14-
generate_all
15-
});
16-
17-
use wasi::http::types::{Fields, HeaderError, Method, Request, Scheme};
1+
use test_wasm32_wasip3::cli::{export, exports::wasi::cli::run::Guest};
2+
use test_wasm32_wasip3::http::{
3+
wasi::http::types::{Fields, HeaderError, Method, Request, Scheme},
4+
wit_future,
5+
};
186

197
fn test_request_field_default_values(request: &Request) {
208
assert_eq!(request.get_method(), Method::Get);
@@ -284,7 +272,7 @@ fn test() {
284272
struct Component;
285273
export!(Component);
286274

287-
impl exports::wasi::cli::run::Guest for Component {
275+
impl Guest for Component {
288276
async fn run() -> Result<(), ()> {
289277
test();
290278
Ok(())

tests/rust/wasm32-wasip3/src/bin/http-response.rs

Lines changed: 6 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,8 @@
1-
extern crate wit_bindgen;
2-
3-
wit_bindgen::generate!({
4-
inline: r"
5-
package test:test;
6-
7-
world test {
8-
import wasi:http/types@0.3.0-rc-2026-02-09;
9-
include wasi:cli/command@0.3.0-rc-2026-02-09;
10-
}
11-
",
12-
additional_derives: [PartialEq, Eq, Hash, Clone],
13-
features:["clocks-timezone"],
14-
generate_all
15-
});
16-
17-
use wasi::http::types::{Fields, HeaderError, Response};
1+
use test_wasm32_wasip3::cli::{export, exports::wasi::cli::run::Guest};
2+
use test_wasm32_wasip3::http::{
3+
wasi::http::types::{Fields, HeaderError, Response},
4+
wit_future,
5+
};
186

197
fn test_response_field_default_values(response: &Response) {
208
assert_eq!(response.get_status_code(), 200);
@@ -65,7 +53,7 @@ async fn test_response() -> Response {
6553
struct Component;
6654
export!(Component);
6755

68-
impl exports::wasi::cli::run::Guest for Component {
56+
impl Guest for Component {
6957
async fn run() -> Result<(), ()> {
7058
test_response().await;
7159
Ok(())
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
wit_bindgen::generate!({
2+
inline: r"
3+
package wasi-testsuite:test;
4+
5+
world http-test {
6+
import wasi:http/types@0.3.0-rc-2026-02-09;
7+
}
8+
",
9+
additional_derives: [PartialEq, Eq, Hash, Clone],
10+
pub_export_macro: true,
11+
default_bindings_module: "test_wasm32_wasip3::http",
12+
features:["clocks-timezone"],
13+
generate_all
14+
});
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
pub mod cli;
22
pub mod clocks;
3+
pub mod http;
34
pub mod random;
45
pub mod sockets;

0 commit comments

Comments
 (0)