Fix HttpProxySocket early data return value

This commit is contained in:
klzgrad 2020-09-10 19:42:43 +08:00
parent 458c165811
commit 4a944da697

View File

@ -148,16 +148,17 @@ int HttpProxySocket::Read(IOBuffer* buf,
DCHECK(callback); DCHECK(callback);
if (!buffer_.empty()) { if (!buffer_.empty()) {
was_ever_used_ = true;
int data_len = buffer_.size(); int data_len = buffer_.size();
if (data_len <= buf_len) { if (data_len <= buf_len) {
std::memcpy(buf->data(), buffer_.data(), data_len); std::memcpy(buf->data(), buffer_.data(), data_len);
buffer_.clear(); buffer_.clear();
return data_len;
} else { } else {
std::memcpy(buf->data(), buffer_.data(), buf_len); std::memcpy(buf->data(), buffer_.data(), buf_len);
buffer_ = buffer_.substr(buf_len); buffer_ = buffer_.substr(buf_len);
return buf_len;
} }
was_ever_used_ = true;
return OK;
} }
int rv = transport_->Read( int rv = transport_->Read(