Incorrect parse error detection
At line 174 of Messages.cpp, you detect errors by checking if (used < size). However, if you call http_parser_execute with size of 0 (indicating EOF) it returns 1 to indicate an error (i.e., used > size). The check employed in the http_parser documentation is (used != size) for this reason.
Can anyone explain why call http_parser_execute here is needed?
if (used < size)
{
if (error == HPE_PAUSED)
{
// Make sure the byte that triggered the pause
// after the headers is properly processed.
if (!myComplete)
{
used += ::http_parser_execute
(&myParser, &mySettings, data+used, 1);
}
}
....
Why not just return used?
I believe it is related to this issue https://github.com/nodejs/http-parser/issues/97 which is how I found httpxx in the first place.
I suspect http_parser_pause() was only ever intended to be called in the on_message_complete callback, and calling in on_headers_complete prevents the last byte of the headers from being fully processed by the parser. As a result, the value of used is off by one byte until the additional call to http_parser_execute.
From: junfx [mailto:[email protected]] Sent: 07 September 2016 09:10 AM To: AndreLouisCaron/httpxx [email protected] Cc: AndrewKlopper [email protected]; Author [email protected] Subject: Re: [AndreLouisCaron/httpxx] Incorrect parse error detection (#25)
Can anyone explain why call http_parser_execute here is needed?
if (used < size)
{
if (error == HPE_PAUSED)
{
// Make sure the byte that triggered the pause
// after the headers is properly processed.
if (!myComplete)
{
used += ::http_parser_execute
(&myParser, &mySettings, data+used, 1);
}
}
....
Why not just return used?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/AndreLouisCaron/httpxx/issues/25#issuecomment-245194435 , or mute the thread https://github.com/notifications/unsubscribe-auth/AIDDHsvmXFtJGO0UMgnQfNEXt1n7YSaFks5qnmM0gaJpZM4JoUEt . https://github.com/notifications/beacon/AIDDHgS0IYUgRq-RirGXTeQOxzhhrHW_ks5qnmM0gaJpZM4JoUEt.gif