From 90155dd05bca2478d052235c24ecf0bb6bbf37de Mon Sep 17 00:00:00 2001 From: MihailRis Date: Sun, 24 Nov 2024 07:58:07 +0300 Subject: [PATCH] rename functions --- src/logic/scripting/lua/libs/libnetwork.cpp | 8 ++++---- src/network/Network.cpp | 3 ++- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/logic/scripting/lua/libs/libnetwork.cpp b/src/logic/scripting/lua/libs/libnetwork.cpp index 0add7721..edd35bcc 100644 --- a/src/logic/scripting/lua/libs/libnetwork.cpp +++ b/src/logic/scripting/lua/libs/libnetwork.cpp @@ -5,7 +5,7 @@ using namespace scripting; -static int l_http_get(lua::State* L) { +static int l_get(lua::State* L) { std::string url(lua::require_lstring(L, 1)); lua::pushvalue(L, 2); @@ -19,7 +19,7 @@ static int l_http_get(lua::State* L) { return 0; } -static int l_http_get_binary(lua::State* L) { +static int l_get_binary(lua::State* L) { std::string url(lua::require_lstring(L, 1)); lua::pushvalue(L, 2); @@ -37,7 +37,7 @@ static int l_http_get_binary(lua::State* L) { } const luaL_Reg networklib[] = { - {"http_get", lua::wrap}, - {"http_get_binary", lua::wrap}, + {"get", lua::wrap}, + {"get_binary", lua::wrap}, {NULL, NULL} }; diff --git a/src/network/Network.cpp b/src/network/Network.cpp index c4e9b004..aec84372 100644 --- a/src/network/Network.cpp +++ b/src/network/Network.cpp @@ -29,6 +29,7 @@ struct Request { OnResponse onResponse; OnReject onReject; long maxSize; + bool followLocation = false; }; class CurlRequests : public Requests { @@ -79,7 +80,7 @@ public: curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, write_callback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &buffer); - curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, true); + curl_easy_setopt(curl, CURLOPT_FOLLOWLOCATION, request.followLocation); if (request.maxSize == 0) { curl_easy_setopt( curl, CURLOPT_MAXFILESIZE, std::numeric_limits::max()