diff --git a/proxygen/lib/http/codec/HTTP1xCodec.cpp b/proxygen/lib/http/codec/HTTP1xCodec.cpp index 66c34ea0a7..31518f53b7 100644 --- a/proxygen/lib/http/codec/HTTP1xCodec.cpp +++ b/proxygen/lib/http/codec/HTTP1xCodec.cpp @@ -1198,7 +1198,8 @@ int HTTP1xCodec::onHeadersComplete(size_t len) { ignoreBody = false; } else { is1xxResponse_ = msg_->is1xxResponse(); - if (connectRequest_ && (msg_->is4xxResponse() || msg_->is5xxResponse())) { + std::string contentLengthHeader = msg_->getHeaders().getSingleOrEmpty(HTTP_HEADER_CONTENT_LENGTH); + if (connectRequest_ && (msg_->is4xxResponse() || msg_->is5xxResponse()) && !contentLengthHeader.empty() && std::stol(contentLengthHeader) != 0) { ignoreBody = false; } else if (expectNoResponseBody_) { ignoreBody = true;