Skip to content

关于使用 rust wasm 插件在处理 http body 时遇到的问题 #1465

Answered by jaymie9019
jaymie9019 asked this question in Q&A
Discussion options

You must be logged in to vote

我成功了!最终的代码

多了一行,每次把原来的 body 给擦掉

self.replace_http_response_body(Vec::new().as_slice());

    fn on_http_response_body(&mut self, _body_size: usize, _end_of_stream: bool) -> DataAction {
        if !self.need_zip {
            return DataAction::Continue;
        }

        let mut trace_id = String::new();
        if let Some(trace_header) = self.res_headers.get("trace_id") {
            trace_id = trace_header.clone();
        }

        self.log.info(&format!("httpContext on_http_response_body _body_size: {}, _end_of_stream: {}, trace_id: {}",
                               _body_size, _end_of_stream,
                               trace_id));

        // 自己缓存
        self.res_body_len +…

Replies: 2 comments 16 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
16 replies
@jaymie9019
Comment options

@007gzs
Comment options

007gzs Oct 31, 2024
Collaborator

@jaymie9019
Comment options

@jaymie9019
Comment options

Answer selected by jaymie9019
@007gzs
Comment options

007gzs Oct 31, 2024
Collaborator

@jaymie9019
Comment options

@007gzs
Comment options

007gzs Oct 31, 2024
Collaborator

@007gzs
Comment options

007gzs Oct 31, 2024
Collaborator

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants