修复http拆包bug

This commit is contained in:
xiongziliang 2018-09-28 21:16:39 +08:00
parent 40c1ea9b4c
commit 5aa64c3651

View File

@ -75,7 +75,8 @@ splitPacket:
if(_content_len == 0){
//尚未找到http头缓存定位到剩余数据部分
_remain_data.assign(ptr,remain);
string str(ptr,remain);
_remain_data = str;
return;
}
@ -84,7 +85,8 @@ splitPacket:
//数据按照固定长度content处理
if(remain < _content_len){
//数据不够,缓存定位到剩余数据部分
_remain_data.assign(ptr,remain);
string str(ptr,remain);
_remain_data = str;
return;
}
//收到content数据并且接受content完毕
@ -97,12 +99,14 @@ splitPacket:
if(remain > 0){
//还有数据没有处理完毕
_remain_data.assign(ptr,remain);
string str(ptr,remain);
_remain_data = str;
data = ptr = (char *)_remain_data.data();
len = _remain_data.size();
goto splitPacket;
}
_remain_data.clear();
return;
}