forked fromglynos/cpp-netlib
- Notifications
You must be signed in to change notification settings - Fork425
Fix chunk and content-length encoding#759
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
deanberris merged 2 commits intocpp-netlib:0.13-releasefromLoopinFool:0.13-release-integrationMay 15, 2017
Merged
Fix chunk and content-length encoding#759
deanberris merged 2 commits intocpp-netlib:0.13-releasefromLoopinFool:0.13-release-integrationMay 15, 2017
Uh oh!
There was an error while loading.Please reload this page.
Conversation
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
…irect the callback to append any more data
Don't potentially access memory beyond the end of the string buffer.In the case of a partial chunk, exit the loop. Continuing to search for crlf in the middle of a binary data chunk can result in an infinite loop, and wasn't the right logic.
LGTM. |
deanberris approved these changesMay 15, 2017
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
LGTM
Sign up for freeto 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.
I used the 0.13-release branch because we're updating an existing application to Visual Studio 2017 and it would build, and build against the latest boost 1.64.
At first, things didn't work at all. After using the simple_wget sample to debug it, I found that a bunch of the content (starting with the headers) had been appended after the BODY. I narrowed it down and fixed the new EOF callback when the server has sent a content-length header.
Next, Visual Studio's iterator debugging found the problem with the "len + 2" statement where it could go beyond the end of the string if the buffer didn't yet contain the crlf terminator after the current chunk. After fixing that, things mostly worked but I encountered an occasional infinite loop. From that state I figured out that the existing logic couldn't handle having a partial chunk in the buffer when checking if the chunks have all been received.
The new chunk handling code isn't overly efficient, but my changes got it to work reliably without any major changes to the partial buffer handling.