Skip to content

Commit 9536299

Browse files
author
nbn01
committed
add: remove_http_request_header convenient func
Signed-off-by: nbn01 <[email protected]>
1 parent 3f4274e commit 9536299

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/hostcalls.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,15 @@ pub fn set_map_value(map_type: MapType, key: &str, value: Option<&str>) -> Resul
318318
}
319319
}
320320

321+
pub fn remove_map_value(map_type: MapType, key: &str) -> Result<(), Status> {
322+
unsafe {
323+
match proxy_remove_header_map_value(map_type, key.as_ptr(), key.len()) {
324+
Status::Ok => Ok(()),
325+
status => panic!("unexpected status: {}", status as u32),
326+
}
327+
}
328+
}
329+
321330
pub fn set_map_value_bytes(
322331
map_type: MapType,
323332
key: &str,

src/traits.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,10 @@ pub trait HttpContext: Context {
351351
hostcalls::add_map_value_bytes(MapType::HttpRequestHeaders, name, value).unwrap()
352352
}
353353

354+
fn remove_http_request_header(&self, name: &str) {
355+
hostcalls::remove_map_value(MapType::HttpRequestHeaders, name).unwrap()
356+
}
357+
354358
fn on_http_request_body(&mut self, _body_size: usize, _end_of_stream: bool) -> Action {
355359
Action::Continue
356360
}

0 commit comments

Comments
 (0)