Currently, we are switching the API gateway engine made in c to tokio, hyper, rustls of rust.
While analyzing the echo server example provided by hyper_rustls (tokio_rustls), there is a part that I do not understand and ask for help. (I'm struggling with not many examples to refer to)
https://github.com/rustls/hyper-rustls/blob/main/examples/server.rs
Here's the flow I was thinking of: When a POST request with a large body size is received, all http bodies are read → After reading up to content-length, the future code passed to make_service_fn is executed (echo operation in the example).
However, as soon as the request is received, the code passed to make_service_fn is executed and a response is sent to the client, and the poll_read function of the tokio::io::AsyncRead trait is executed many times. This has been run.
Q: When exactly does the make_fn_service code run, and is this something I can control?
Q: When using hyper, it seems to store the body accumulating in memory. Therefore, if the body size is very large, I would like to work with such as downloading it to a separate file. Is there a way to directly control every time the body comes?
- Can I use the hyper::body::HttpBody trait?