From b25e19e8763b2537a444ec1cf619e3ce5dc1ca4a Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Wed, 8 Apr 2015 14:39:27 +0900 Subject: [PATCH] nghttpx: HTTP backend: Check parser error first so that we can get error msg --- src/shrpx_http_downstream_connection.cc | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/shrpx_http_downstream_connection.cc b/src/shrpx_http_downstream_connection.cc index fc2f9d86..e1b90383 100644 --- a/src/shrpx_http_downstream_connection.cc +++ b/src/shrpx_http_downstream_connection.cc @@ -720,13 +720,6 @@ int HttpDownstreamConnection::on_read() { http_parser_execute(&response_htp_, &htp_hooks, reinterpret_cast(buf.data()), nread); - if (nproc != static_cast(nread)) { - if (LOG_ENABLED(INFO)) { - DCLOG(INFO, this) << "nproc != nread"; - } - return -1; - } - auto htperr = HTTP_PARSER_ERRNO(&response_htp_); if (htperr != HPE_OK) { @@ -739,6 +732,13 @@ int HttpDownstreamConnection::on_read() { return -1; } + if (nproc != static_cast(nread)) { + if (LOG_ENABLED(INFO)) { + DCLOG(INFO, this) << "nproc != nread"; + } + return -1; + } + if (downstream_->response_buf_full()) { downstream_->pause_read(SHRPX_NO_BUFFER); return 0;