rust_async_ftp icon indicating copy to clipboard operation
rust_async_ftp copied to clipboard

Make FtpStream::get read the final response

Open oscarwcl opened this issue 2 years ago • 0 comments

Once the client has finished reading a file from the server, the server sends a status message to the client. The current API of FtpStream::get doesn't allow us to read that response, since we return a BufReader that reads directly from the data stream. Instead of doing this, we can return a new future type that wraps the data stream and reads the status message once the data stream is finished.

There is one caveat to this - if this future is dropped then the data stream will be closed, and the server will send us an error message, which still needs to be read manually. There isn't really a nice way around this without an AsyncDrop trait.

Since this is already a breaking change, we also no longer use a BufReader at all - this lets the caller decide whether to buffer or not.

This fixes #13

oscarwcl avatar Apr 06 '22 09:04 oscarwcl