MG_EV_CLOSE, when use http client as file downloader #3122
-
When I referenced the code from http-streaming-client to implement a file download, I found that the file triggered the MG_EV_CLOSE event during the second read operation. After tracing the code, I discovered that manually calling mg_http_parse in the read function caused the Mongoose library to skip the standard HTTP header processing in the http_cb callback. Subsequent data entering http_cb then triggered a re-parsing due to c->is_resp = 0, resulting in an error and closing the connection. I performed the following steps: after obtaining the HTTP headers via mg_http_parse in MG_EV_READ, I manually set c->is_resp = 1, and the file was downloaded correctly. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
If you want to do a file transfer, read the file transfer tutorials and examine the file transfer code examples. Please see our documentation, and follow the guidelines in our tutorials. https://mongoose.ws/documentation/tutorials/http/file-uploads/ |
Beta Was this translation helpful? Give feedback.
If you want to do a file transfer, read the file transfer tutorials and examine the file transfer code examples.
Please see our documentation, and follow the guidelines in our tutorials.
https://mongoose.ws/documentation/tutorials/http/file-uploads/
https://github.com/cesanta/mongoose/tree/master/tutorials/http/file-transfer