This commit is contained in:
blueloveTH 2023-04-30 22:29:04 +08:00
parent f9ed405bf5
commit fcc13cb422
2 changed files with 2 additions and 3 deletions

View File

@ -82,6 +82,7 @@ struct Bytes{
Bytes() : _data(), _ok(false) {} Bytes() : _data(), _ok(false) {}
Bytes(std::vector<char>&& data) : _data(std::move(data)), _ok(true) {} Bytes(std::vector<char>&& data) : _data(std::move(data)), _ok(true) {}
Bytes(const std::string& data) : _data(data.begin(), data.end()), _ok(true) {}
operator bool() const noexcept { return _ok; } operator bool() const noexcept { return _ok; }
}; };

View File

@ -65,13 +65,11 @@ inline void add_module_requests(VM* vm){
} }
auto _to_resp = [=](const httplib::Result& res){ auto _to_resp = [=](const httplib::Result& res){
std::vector<char> buf(res->body.size());
for(int i=0; i<res->body.size(); i++) buf[i] = res->body[i];
return vm->call( return vm->call(
vm->_modules[m_requests]->attr(m_Response), vm->_modules[m_requests]->attr(m_Response),
VAR(res->status), VAR(res->status),
VAR(res->reason), VAR(res->reason),
VAR(Bytes(std::move(buf))) VAR(Bytes(res->body))
); );
}; };