blueloveTH il y a 2 ans
Parent
commit
fcc13cb422
2 fichiers modifiés avec 2 ajouts et 3 suppressions
  1. 1 0
      src/obj.h
  2. 1 3
      src/requests.h

+ 1 - 0
src/obj.h

@@ -82,6 +82,7 @@ struct Bytes{
 
     Bytes() : _data(), _ok(false) {}
     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; }
 };
 

+ 1 - 3
src/requests.h

@@ -65,13 +65,11 @@ inline void add_module_requests(VM* vm){
         }
 
         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(
                 vm->_modules[m_requests]->attr(m_Response),
                 VAR(res->status),
                 VAR(res->reason),
-                VAR(Bytes(std::move(buf)))
+                VAR(Bytes(res->body))
             );
         };