mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
...
This commit is contained in:
parent
f9ed405bf5
commit
fcc13cb422
@ -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; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -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))
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user