You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Parser in response mode does not reset on finish #128
I noticed some unexpected behavior when parsing responses. If the response does not include a content-length header, calling llhttp_finish does not seem to reset the parser. Here's an example:
I think this is expected, but willing to be shown otherwise. Without a content-length, the parser has no way to know the length of the response. The point of llhttp_finish is not to reset the parser, it's to figure out the final state of the current parse, possibly based on a call to on_message_complete. Once you are done with the parser, to reuse it you need to call llhttp_reset to put it back in its initial state, preserving any flags, callbacks, & cookies you've set on it.
Activity
pallas commentedon Sep 9, 2021
I think this is expected, but willing to be shown otherwise. Without a content-length, the parser has no way to know the length of the response. The point of
llhttp_finishis not to reset the parser, it's to figure out the final state of the current parse, possibly based on a call toon_message_complete. Once you are done with the parser, to reuse it you need to callllhttp_resetto put it back in its initial state, preserving any flags, callbacks, & cookies you've set on it.bryanp commentedon Sep 9, 2021
Ah, the issue is with my implementation. Thank you for pointing me in the right direction, I already have things fixed.