1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

For #1508, check the error by http_errno for http-parser.

This commit is contained in:
winlin 2019-12-20 16:08:24 +08:00
parent 2b51cee3ef
commit 788b200e90

View file

@ -116,8 +116,12 @@ srs_error_t SrsHttpParser::parse_message_imp(ISrsReader* reader)
while (true) {
if (buffer->size() > 0) {
ssize_t nparsed = http_parser_execute(&parser, &settings, buffer->bytes(), buffer->size());
if (buffer->size() != nparsed) {
return srs_error_new(ERROR_HTTP_PARSE_HEADER, "parse failed, nparsed=%d, size=%d", nparsed, buffer->size());
// The error is set in http_errno.
enum http_errno code;
if ((code = HTTP_PARSER_ERRNO(&parser)) != HPE_OK) {
return srs_error_new(ERROR_HTTP_PARSE_HEADER, "parse %dB, nparsed=%d, err=%d/%s %s",
buffer->size(), nparsed, http_errno_name(code), http_errno_description(code));
}
// The consumed size, does not include the body.