diff --git a/src/hostcalls.rs b/src/hostcalls.rs index 15687888..ed14d542 100644 --- a/src/hostcalls.rs +++ b/src/hostcalls.rs @@ -318,6 +318,15 @@ pub fn set_map_value(map_type: MapType, key: &str, value: Option<&str>) -> Resul } } +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), + } + } +} + pub fn set_map_value_bytes( map_type: MapType, key: &str, diff --git a/src/traits.rs b/src/traits.rs index bd54bcbe..b996a60c 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -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 }