Skip to content

Commit

Permalink
tests(hostcalls) drop url dependency; improve load time
Browse files Browse the repository at this point in the history
Removing the `url` crate, reduces `hostcalls` load time in Wasmtime by 25%.
  • Loading branch information
casimiro authored and thibaultcha committed Feb 8, 2024
1 parent ce785b7 commit c37b8ef
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 79 deletions.
67 changes: 0 additions & 67 deletions t/lib/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion t/lib/proxy-wasm-tests/hostcalls/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ crate-type = ["cdylib"]

[dependencies]
proxy-wasm = "0.2"
url = "2.2"
log = "0.4"
http = "0.2"
chrono = "0.4"
Expand Down
16 changes: 5 additions & 11 deletions t/lib/proxy-wasm-tests/hostcalls/src/types/test_http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use http::StatusCode;
use log::*;
use proxy_wasm::{traits::*, types::*};
use std::time::Duration;
use url::Url;

pub struct TestHttp {
pub on_phases: Vec<TestPhase>,
Expand All @@ -22,19 +21,14 @@ impl TestHttp {

fn serve_echo(&mut self, path: &str) {
if path.starts_with("/t/echo/header/") {
let url = Url::options()
.base_url(Some(&Url::parse("http://localhost").unwrap()))
.parse(path)
.expect("bad path");

/* /t/echo/header/{header_name: String} */
let header_name = url
.path()
let header_name = path
.split('/')
.collect::<Vec<&str>>()
.split_off(4)
.pop()
.unwrap();
.remove(4)
.split('?')
.collect::<Vec<&str>>()
.remove(0);

echo_header(self, header_name);
}
Expand Down

0 comments on commit c37b8ef

Please sign in to comment.