Skip to content

fixed read timeout in chucked content response for sync keep-alive client #327

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

Merged
merged 2 commits into from
Nov 24, 2013

Conversation

mepahoo
Copy link

@mepahoo mepahoo commented Nov 24, 2013

After some testing, i noticed the keep-alive sync http client waited about 20 seconds before returning a trivial content (about 111 bytes). I tracked it down to this fix. The problem was that boost::asio::read is called, even if there are enough bytes in the current stream buffer. This causes read to wait until timeout (which on my windows platform was 20 secs, apparently). The fix is to not read if there are enough bytes in the current stream buffer. I am also counting 2 extra bytes for "\r\n" that comes after each chunk.

@ghost ghost assigned deanberris Nov 24, 2013
throw boost::system::system_error(error);
stopping_inner = true;
if (response_buffer.size() < (chunk_size+2)){
std::size_t toRead = (chunk_size+2) - response_buffer.size();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I would prefer you call this variable bytes_to_read.

@deanberris
Copy link
Member

Generally, LGTM -- but if you have time to address that nit, I would appreciate it very much. :)

Thanks @mepahoo !

@deanberris
Copy link
Member

Cool, thanks -- this LGTM. Sorry for the delay, I didn't know it was ready for another look. :)

deanberris added a commit that referenced this pull request Nov 24, 2013
fixed read timeout in chucked content response for sync keep-alive client
@deanberris deanberris merged commit 472a4ad into cpp-netlib:0.10-devel Nov 24, 2013
leecoder pushed a commit to leecoder/cpp-netlib that referenced this pull request Apr 14, 2015
fixed read timeout in chucked content response for sync keep-alive client
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.

3 participants