Make FtpStream::get read the final response#15
Open
oscarwcl wants to merge 1 commit intodani-garcia:masterfrom
Open
Make FtpStream::get read the final response#15oscarwcl wants to merge 1 commit intodani-garcia:masterfrom
oscarwcl wants to merge 1 commit intodani-garcia:masterfrom
Conversation
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 AsyncRead type (FileReader) that wraps the data stream and reads the status message once the data stream is finished. There is one caveat to this - if the FileReader 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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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