From 8c6e7f547cf88452ec9f33a0a7ce11235b384e30 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Fri, 14 Dec 2018 12:44:39 +0100 Subject: [PATCH] http: fix regression of binary upgrade response body PR-URL: https://github.com/nodejs/node/pull/25039 Fixes: https://github.com/nodejs/node/issues/24958 Reviewed-By: Myles Borins --- src/node_http_parser.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/node_http_parser.cc b/src/node_http_parser.cc index 5ad8afbdbf76b2..58bae3323c0484 100644 --- a/src/node_http_parser.cc +++ b/src/node_http_parser.cc @@ -605,8 +605,6 @@ class Parser : public AsyncWrap, public StreamListener { size_t nparsed = http_parser_execute(&parser_, &settings, data, len); - enum http_errno err = HTTP_PARSER_ERRNO(&parser_); - Save(); // Unassign the 'buffer_' variable @@ -621,7 +619,9 @@ class Parser : public AsyncWrap, public StreamListener { Local nparsed_obj = Integer::New(env()->isolate(), nparsed); // If there was a parse error in one of the callbacks // TODO(bnoordhuis) What if there is an error on EOF? - if ((!parser_.upgrade && nparsed != len) || err != HPE_OK) { + if (!parser_.upgrade && nparsed != len) { + enum http_errno err = HTTP_PARSER_ERRNO(&parser_); + Local e = Exception::Error(env()->parse_error_string()); Local obj = e->ToObject(env()->isolate()->GetCurrentContext()) .ToLocalChecked();