Skip to content

Commit

Permalink
add: remove_http_request_header convenient func
Browse files Browse the repository at this point in the history
Signed-off-by: nbn01 <[email protected]>
  • Loading branch information
nbn01 committed Aug 28, 2024
1 parent 3f4274e commit 9536299
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/hostcalls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 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

0 comments on commit 9536299

Please sign in to comment.