Add async events for upload
Currently, the async mode only generates events once the remote server responds. I'd like to be able to monitor the progress of a large upload using POST. This means generating events for the submission phase of the request as well as the response. At the very least, "chunk" events and an event for when the whole request has been transmitted (but before the response has been received). Is this a possibility?
This is not that easy. The only real thing you can retrieve on sent is the number of bytes already processed. There are no guarantee that these bytes have already been sent by the system except if you're using the connection option {nodelay, true} which isn't recommended on all systems. Also on pure TCP connections hackney is using the sendfile(2) API.
I think the best way to do that would be having
- a way to retrieve the number of bytes sent, processed The first one could be done by exposing the socket/port info from Erlang. The second by adding some metadata in hackney
- optionally add a log system so you can subscribe to the events and eventually provide a progress.
Thoughts?
That sounds reasonable, yeah. I just don't want to have it sit there for 30s without any clue as to how far it has gotten.
This is exactly what I'm looking for as well. Currently I have no options as far as I know to give user feedback on their upload progress when they are uploading a (bunch of) file(s) in the (web)interface.
Thanks for considering this :)
Gerard.
@smeevil i will provide the needed metrics for that