Skip to content

How do I get http_call_response #257

Open
@alexhu20

Description

@alexhu20

Description

I have use case that need to make a separate http call in wasm and getting a response back. I only see that the base context has an API called on_http_call_response to fetch the entire response body.

Is there a way to do so in my client implementation?


Another question:
The response body example seems incorrect, I have to do the following in order to buffer the entire response body, am I doing it wrong?

    fn on_http_request_body(&mut self, _body_size: usize, _end_of_stream: bool) -> Action {
        let msg = &format!("[on_http_request_body] ContextID {} on request body.", self.context_id);
        log(Info, msg);

        if !_end_of_stream {
            info!("[on_http_request_body] ContextID {} current body size: {}", self.context_id, self.request_body_length);
            
            if let Some(body_size) = self.get_http_request_body(self.request_body_length, _body_size) {
                let mut body_slice: Vec<u8> = body_size;
                self.request_body.append(&mut body_slice);
            }
            else { 
                info!("[on_http_request_body] ContextID {} else request body error???", self.context_id);
            }
            self.request_body_length += _body_size;
            return Action::Pause
        }
        
        Action::Continue
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions