Nitromelon
Nitromelon
We really appreciate your effort. However we could not agree on this change. > I am tring to do some codes moving, to let codes became very easy to read...
Example codes: https://github.com/drogonframework/drogon/blob/ad2760823dd287595ec68c818f3c33ef6c8a18d1/examples/async_stream/main.cc#L34-L81 https://github.com/drogonframework/drogon/blob/ad2760823dd287595ec68c818f3c33ef6c8a18d1/examples/async_stream/RequestStreamExampleCtrl.cc#L1-L167 I think the current design is pretty good. But still, there are endless details to worry about... Here are some major problems. ### 1. which request...
越写越丑 提前开启 stream mode 才能走到 router, 如果匹配到的 handler 不是 stream handler 该怎么办?最新commit([9bffbb4](https://github.com/drogonframework/drogon/pull/2055/commits/9bffbb42886754b10500e785b353d97bef738b38))会自动等到所有body接收完之后再进入 handler. 如果接受body时遇到错误又该怎么办?
## 更新 ### 解决 [1. which request should enter stream mode](https://github.com/drogonframework/drogon/pull/2055#issuecomment-2156005154) 使用方案3 在 routing 完成之后检查是否匹配到 stream-handler, 如果没匹配到,则自动等到所有body读取完毕,再进入后续流程。 所以现在的情况是,开启stream-mode后,non-stream-handler 只有在 postRoutingAdvices 以及之后的流程中可以访问 request body.
还需要解决生命周期问题 用户调用 setStreamReader() 后,HttpRequestPtr 需要持有 StreamReaderPtr 的引用,否则后者会提前释放。此时如果用户在自己创建的 StreamReaderPtr 中捕获 req, 会导致循环引用。 因此需要择机释放持有的引用。现在选择的时机是当 streamFinish 或者 streamError 时, 清空 HttpRequestPtr 上的引用。 这导致一个问题:StreamReaderPtr 的生命周期比较奇怪。理想情况是 StreamReaderPtr 和 HttpRequestPtr 共享生命周期,但现在(如果用户不主动持有引用) StreamReaderPtr 在流结束时就会析构。
## 总结 此 PR 接近完结, 如有任何疑问或建议,欢迎在此提出 ### 解决的问题 1. 在超大文件上传时, drogon会将multipart格式的原始请求存入临时文件,使用mmap映射到内存。由于存储的是原始请求(包含multipart boundary 等信息),用户转存文件时必须经过一次全量复制, 无法向用户提供 move() 之类的接口转存文件。如果文件过大,会消耗时间,且会多浪费一倍的存储空间。 2. 32位系统中无法一次性上传超过4G的文件,使用流式接口可以解决这个问题 ### 开启方式 通过 `app().enableRequestStream(true);` 或配置文件 `"enable_request_stream": true` 开启 配合新的 controller function 类型...
I'm not quite following. Could you describe the situation in more detail? I'm not sure what you are refering by `subsequent routes` or `Aligned`.
The search order is the same as the config locations array. If you want to search "/static/images/pictures" first, you should put it in front of "/static/".
It will only check the first matched url_prefix.
I have a concern about creating large examples. As drogon release new version, old examples may have compatiblility issues. It's hard to say that example authors will keep maintaining them....