Skip to content

Commit

Permalink
feat(wasm): 优化 PluginHttpWrapper 中 res_headers 获取
Browse files Browse the repository at this point in the history
  • Loading branch information
jaymie9019 committed Sep 10, 2024
1 parent ebf482c commit cea757a
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions plugins/wasm-rust/src/plugin_wrapper.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ where
Err(_) => {
log(
LogLevel::Warn,
format!("http header contains non-ASCII characters header: {}", k ).as_str(),
format!("request http header contains non-ASCII characters header: {}", k ).as_str(),
).unwrap();
}
}
Expand Down Expand Up @@ -202,9 +202,20 @@ where
num_headers: usize,
end_of_stream: bool,
) -> HeaderAction {
for (k, v) in self.get_http_response_headers() {
self.res_headers.insert(k, v);
for (k, v) in self.get_http_response_headers_bytes() {
match String::from_utf8(v) {
Ok(header_value) => {
self.res_headers.insert(k, header_value);
}
Err(_) => {
log(
LogLevel::Warn,
format!("response http header contains non-ASCII characters header: {}", k ).as_str(),
).unwrap();
}
}
}

let ret = self
.http_content
.on_http_response_headers(num_headers, end_of_stream);
Expand Down

0 comments on commit cea757a

Please sign in to comment.