From a2b809c6fb0472e6771b4506b8774c6b720f49b9 Mon Sep 17 00:00:00 2001 From: Kharkunov Eugene Date: Sat, 11 May 2024 12:15:41 +0300 Subject: [PATCH] Add 'path' parameter handling for html5 implementation in http.request function. --- engine/gamesys/src/gamesys/scripts/script_http.cpp | 2 +- engine/gamesys/src/gamesys/scripts/script_http_js.cpp | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/engine/gamesys/src/gamesys/scripts/script_http.cpp b/engine/gamesys/src/gamesys/scripts/script_http.cpp index a5e9b1540c..f120825b7f 100644 --- a/engine/gamesys/src/gamesys/scripts/script_http.cpp +++ b/engine/gamesys/src/gamesys/scripts/script_http.cpp @@ -93,7 +93,7 @@ namespace dmGameSystem * @param [options] [type:table] optional table with request parameters. Supported entries: * * - [type:number] `timeout`: timeout in seconds - * - [type:string] `path`: path on disc where to download the file. Only overwrites the path if status is 200. [icon:attention] Not available in HTML5 build + * - [type:string] `path`: path on disc where to download the file. Only overwrites the path if status is 200. [icon:attention] Path should be absolute * - [type:boolean] `ignore_cache`: don't return cached data if we get a 304. [icon:attention] Not available in HTML5 build * - [type:boolean] `chunked_transfer`: use chunked transfer encoding for https requests larger than 16kb. Defaults to true. [icon:attention] Not available in HTML5 build * diff --git a/engine/gamesys/src/gamesys/scripts/script_http_js.cpp b/engine/gamesys/src/gamesys/scripts/script_http_js.cpp index 727d2cd573..e42cde0dd6 100644 --- a/engine/gamesys/src/gamesys/scripts/script_http_js.cpp +++ b/engine/gamesys/src/gamesys/scripts/script_http_js.cpp @@ -53,6 +53,7 @@ namespace dmGameSystem { dmMessage::URL m_Requester; void* m_RequestData; + const char* m_Path; int m_Callback; }; @@ -98,6 +99,7 @@ namespace dmGameSystem resp.m_HeadersLength = headers_length; resp.m_Response = (uint64_t) response; resp.m_ResponseLength = response_length; + resp.m_Path = ctx->m_Path; resp.m_Headers = (uint64_t) malloc(headers_length); memcpy((void*) resp.m_Headers, headers, headers_length); @@ -143,6 +145,7 @@ namespace dmGameSystem int top = lua_gettop(L); int callback = 0; + const char* path = 0; dmMessage::URL sender; if (dmScript::GetURL(L, &sender)) { RequestParams request_params; @@ -205,6 +208,10 @@ namespace dmGameSystem { request_params.m_ReportProgress = lua_toboolean(L, -1); } + else if (strcmp(attr, "path") == 0) + { + path = luaL_checkstring(L, -1); + } lua_pop(L, 1); } lua_pop(L, 1); @@ -214,6 +221,7 @@ namespace dmGameSystem ctx->m_Callback = callback; ctx->m_Requester = sender; ctx->m_RequestData = request_params.m_SendData; + ctx->m_Path = path; request_params.m_Args = ctx;