Fix lua_xml_http_request dataSize incorrect

This commit is contained in:
halx99 2022-01-18 18:39:58 +08:00
parent 3359ac211f
commit 5486d94646
1 changed files with 3 additions and 6 deletions

View File

@ -100,7 +100,7 @@ public:
void getByteData(unsigned char* byteData) const; void getByteData(unsigned char* byteData) const;
inline const char* getData() { return !_data.empty() ? _data.data() : ""; } inline const char* getData() { return !_data.empty() ? _data.data() : ""; }
inline size_t getDataSize() const { return _dataSize; } inline size_t getDataSize() const { return _data.size(); }
inline void setErrorFlag(bool errorFlag) { _errorFlag = errorFlag; } inline void setErrorFlag(bool errorFlag) { _errorFlag = errorFlag; }
inline bool getErrorFlag() const { return _errorFlag; } inline bool getErrorFlag() const { return _errorFlag; }
@ -113,7 +113,6 @@ private:
std::string _meth; std::string _meth;
std::string _type; std::string _type;
yasio::sbyte_buffer _data; yasio::sbyte_buffer _data;
size_t _dataSize;
int _readyState; int _readyState;
int _status; int _status;
std::string _statusText; std::string _statusText;
@ -133,7 +132,6 @@ LuaMinXmlHttpRequest::LuaMinXmlHttpRequest()
: _url("") : _url("")
, _meth("") , _meth("")
, _type("") , _type("")
, _dataSize(0)
, _readyState(UNSENT) , _readyState(UNSENT)
, _status(0) , _status(0)
, _statusText("") , _statusText("")
@ -254,7 +252,6 @@ void LuaMinXmlHttpRequest::_sendRequest()
_status = 200; _status = 200;
_readyState = DONE; _readyState = DONE;
_data = std::move(*buffer); _data = std::move(*buffer);
_dataSize = buffer->size();
} }
else else
{ {
@ -279,8 +276,8 @@ void LuaMinXmlHttpRequest::_sendRequest()
void LuaMinXmlHttpRequest::getByteData(unsigned char* byteData) const void LuaMinXmlHttpRequest::getByteData(unsigned char* byteData) const
{ {
if (_dataSize > 0) if (!_data.empty())
memcpy((char*)byteData, _data.data(), _dataSize); memcpy((char*)byteData, _data.data(), _data.size());
} }
/* function to regType */ /* function to regType */