From fcc13cb42297c45037291a377d9357f76fde6a45 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Sun, 30 Apr 2023 22:29:04 +0800 Subject: [PATCH] ... --- src/obj.h | 1 + src/requests.h | 4 +--- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/obj.h b/src/obj.h index 9cc17c63..a504b597 100644 --- a/src/obj.h +++ b/src/obj.h @@ -82,6 +82,7 @@ struct Bytes{ Bytes() : _data(), _ok(false) {} Bytes(std::vector&& 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; } }; diff --git a/src/requests.h b/src/requests.h index 2574b77c..cc4b4423 100644 --- a/src/requests.h +++ b/src/requests.h @@ -65,13 +65,11 @@ inline void add_module_requests(VM* vm){ } auto _to_resp = [=](const httplib::Result& res){ - std::vector buf(res->body.size()); - for(int i=0; ibody.size(); i++) buf[i] = res->body[i]; return vm->call( vm->_modules[m_requests]->attr(m_Response), VAR(res->status), VAR(res->reason), - VAR(Bytes(std::move(buf))) + VAR(Bytes(res->body)) ); };