Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions src/hostcalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,20 +279,29 @@ pub fn get_map_value_bytes(map_type: MapType, key: &str) -> Result<Option<Bytes>
}

extern "C" {
fn proxy_replace_header_map_value(
fn proxy_remove_header_map_value(
map_type: MapType,
key_data: *const u8,
key_size: usize,
value_data: *const u8,
value_size: usize,
) -> Status;
}

pub fn remove_map_value(map_type: MapType, key: &str) -> Result<(), Status> {
unsafe {
match proxy_remove_header_map_value(map_type, key.as_ptr(), key.len()) {
Status::Ok => Ok(()),
status => panic!("unexpected status: {}", status as u32),
}
}
}

extern "C" {
fn proxy_remove_header_map_value(
fn proxy_replace_header_map_value(
map_type: MapType,
key_data: *const u8,
key_size: usize,
value_data: *const u8,
value_size: usize,
) -> Status;
}

Expand Down
16 changes: 16 additions & 0 deletions src/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,10 @@ pub trait HttpContext: Context {
hostcalls::add_map_value_bytes(MapType::HttpRequestHeaders, name, value).unwrap()
}

fn remove_http_request_header(&self, name: &str) {
hostcalls::remove_map_value(MapType::HttpRequestHeaders, name).unwrap()
}

fn on_http_request_body(&mut self, _body_size: usize, _end_of_stream: bool) -> Action {
Action::Continue
}
Expand Down Expand Up @@ -407,6 +411,10 @@ pub trait HttpContext: Context {
hostcalls::add_map_value_bytes(MapType::HttpRequestTrailers, name, value).unwrap()
}

fn remove_http_request_trailer(&self, name: &str) {
hostcalls::remove_map_value(MapType::HttpRequestTrailers, name).unwrap()
}

fn resume_http_request(&self) {
hostcalls::resume_http_request().unwrap()
}
Expand Down Expand Up @@ -459,6 +467,10 @@ pub trait HttpContext: Context {
hostcalls::add_map_value_bytes(MapType::HttpResponseHeaders, name, value).unwrap()
}

fn remove_http_response_header(&self, name: &str) {
hostcalls::remove_map_value(MapType::HttpResponseHeaders, name).unwrap()
}

fn on_http_response_body(&mut self, _body_size: usize, _end_of_stream: bool) -> Action {
Action::Continue
}
Expand Down Expand Up @@ -515,6 +527,10 @@ pub trait HttpContext: Context {
hostcalls::add_map_value_bytes(MapType::HttpResponseTrailers, name, value).unwrap()
}

fn remove_http_response_trailer(&self, name: &str) {
hostcalls::remove_map_value(MapType::HttpResponseTrailers, name).unwrap()
}

fn resume_http_response(&self) {
hostcalls::resume_http_response().unwrap()
}
Expand Down
Loading