nghttpx: HTTP backend: Check parser error first so that we can get error msg

This commit is contained in:
Tatsuhiro Tsujikawa 2015-04-08 14:39:27 +09:00
parent e9660c3558
commit b25e19e876
1 changed files with 7 additions and 7 deletions

View File

@ -720,13 +720,6 @@ int HttpDownstreamConnection::on_read() {
http_parser_execute(&response_htp_, &htp_hooks, http_parser_execute(&response_htp_, &htp_hooks,
reinterpret_cast<char *>(buf.data()), nread); reinterpret_cast<char *>(buf.data()), nread);
if (nproc != static_cast<size_t>(nread)) {
if (LOG_ENABLED(INFO)) {
DCLOG(INFO, this) << "nproc != nread";
}
return -1;
}
auto htperr = HTTP_PARSER_ERRNO(&response_htp_); auto htperr = HTTP_PARSER_ERRNO(&response_htp_);
if (htperr != HPE_OK) { if (htperr != HPE_OK) {
@ -739,6 +732,13 @@ int HttpDownstreamConnection::on_read() {
return -1; return -1;
} }
if (nproc != static_cast<size_t>(nread)) {
if (LOG_ENABLED(INFO)) {
DCLOG(INFO, this) << "nproc != nread";
}
return -1;
}
if (downstream_->response_buf_full()) { if (downstream_->response_buf_full()) {
downstream_->pause_read(SHRPX_NO_BUFFER); downstream_->pause_read(SHRPX_NO_BUFFER);
return 0; return 0;