Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ChainedStream to handle partial reads #143

Closed
wants to merge 1 commit into from

Conversation

jdasilva
Copy link

@jdasilva jdasilva commented Jun 9, 2015

I was working with MimeKit to read an HttpWebResponse and found that the content was not being fully read. Apparently Stream.Read can return fewer bytes than requested and the response stream will. This fixes ChainedStream to continue reading until the entire expected read is fulfilled. An alternative solution would be to pass partial reads through.

I also modified the ChainedStream tests to utilize a stream that always partial reads. This causes the last three tests to fail and the fix corrects them. I wasn't sure if this would be better a separate test or not. I can also confirm that this did fix my issue with HttpWebResponse.

Let me know if there is anything else I can do to make this a better fit for the project.

jstedfast added a commit that referenced this pull request Jun 9, 2015
This patch fixes the case where the underlying stream does not
read the full number of bytes requested.

Fixes issue #143
jstedfast added a commit that referenced this pull request Jun 9, 2015
@jstedfast
Copy link
Owner

I ended up fixing it a slightly different way, but I added your unit test. Thanks for the bug report and patch!

@jstedfast jstedfast closed this Jun 9, 2015
@jdasilva
Copy link
Author

jdasilva commented Jun 9, 2015

Great - and thank you for all the work on MimeKit!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants