Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to read the request body #78

Open
funky-eyes opened this issue Aug 18, 2023 · 1 comment
Open

How to read the request body #78

funky-eyes opened this issue Aug 18, 2023 · 1 comment

Comments

@funky-eyes
Copy link

funky-eyes commented Aug 18, 2023

  onRequestBody(body_buffer_length: usize, end_of_stream: bool): FilterDataStatusValues { 
    const contentType: String = stream_context.headers.request.get("Content-Type");
    if (contentType.toLowerCase()==="application/json") {
      const arrayBuffer: ArrayBuffer = get_buffer_bytes(BufferTypeValues.HttpRequestBody,0, end_of_stream);
      arrayBuffer
    }
    if (contentType.toLowerCase()==="application/x-www-form-urlencoded") {
      const arrayBuffer: ArrayBuffer = get_buffer_bytes(BufferTypeValues.HttpRequestBody,0, end_of_stream);
    }
    return FilterDataStatusValues.Continue;
   }

How do I convert ArrayBuffer to the corresponding data, such as map, json

@funky-eyes
Copy link
Author

My requirement is to parse the body, read the corresponding parameters, and put them in the header to pass them upstream

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant