From 3579a931a4a68fd5efe45e75e91d2e52c020e829 Mon Sep 17 00:00:00 2001 From: xiongziliang <771730766@qq.com> Date: Sun, 23 Sep 2018 21:21:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Http/HttpClient.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/Http/HttpClient.cpp b/src/Http/HttpClient.cpp index 010ae111..0f010d27 100644 --- a/src/Http/HttpClient.cpp +++ b/src/Http/HttpClient.cpp @@ -141,18 +141,19 @@ int64_t HttpClient::onRecvHeader(const char *data, uint64_t len) { if(_parser["Content-Length"].empty()){ //没有Content-Length字段 - if(!_parser.Content().empty()){ - //如果http回复未声明Content-Length字段,但是却有content内容,那说明可能是个不限长度的content - _totalBodySize = INT64_MAX; - _recvedBodySize = 0; - //返回-1代表不限制content回复大小 - return -1; + if(_parser.Content().empty()){ + //content长度为0,本次http请求结束 + onResponseCompleted_l(); + return 0; } - //content长度为0,本次http请求结束 - onResponseCompleted_l(); - return 0; + //如果http回复未声明Content-Length字段,但是却有content内容,那说明可能是个不限长度的content + _totalBodySize = INT64_MAX; + _recvedBodySize = 0; + //返回-1代表不限制content回复大小 + return -1; } + //有Content-Length字段 _recvedBodySize = 0; _totalBodySize = atoll(_parser["Content-Length"].data());