Open jcwcmimik opened 5 years ago
p->nread
is only for tracking if we moved past HTTP_MAX_HEADER_SIZE
. At line 1788, that doesn't matter anymore because we're done parsing headers.
I've fixed off-by-one errors in the past but that's not that useful here, it'd only benefit downstream users that inappropriately use p->nread
. It's private and marked as such in http_parser.h but some projects still use it.
master branch as of commit 4dae120, http_parser.c:1788
Neither SET_ERRNO nor RETURN are necessarily called in this case (s_headers_almost_done) and thus when on_headers_complete(parser) is called, parser still contains an old nread value (0 if it's the first parse attempt).
In my test cases, inserting
parser->nread = nread;
just before line 1788 solves the issue, but based on that assignment being contained solely within the SET_ERRNO and RETURN defines, someone more familiary with the code may wish to implement it elsewhere.