aboutsummaryrefslogtreecommitdiff
path: root/advtrains/textures/advtrains_copytool.png
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2021-03-13 11:29:44 +0100
committerorwell96 <orwell@bleipb.de>2021-03-13 11:29:44 +0100
commita224027b1687b9a56a8daf7aabaad536d1537754 (patch)
tree6fb5825c1723eb6624cb4a0ee8756bfe247e34bf /advtrains/textures/advtrains_copytool.png
parentb82e10051d69730b7459cceae4e4e8719b4445d0 (diff)
parenta6e8b8b4353863ad563a4d5187f40fea702ea2de (diff)
downloadadvtrains-a224027b1687b9a56a8daf7aabaad536d1537754.tar.gz
advtrains-a224027b1687b9a56a8daf7aabaad536d1537754.tar.bz2
advtrains-a224027b1687b9a56a8daf7aabaad536d1537754.zip
Add 'serialize_lib/' from commit 'a6e8b8b4353863ad563a4d5187f40fea702ea2de'
git-subtree-dir: serialize_lib git-subtree-mainline: b82e10051d69730b7459cceae4e4e8719b4445d0 git-subtree-split: a6e8b8b4353863ad563a4d5187f40fea702ea2de
Diffstat (limited to 'advtrains/textures/advtrains_copytool.png')
0 files changed, 0 insertions, 0 deletions
ref='#n163'>163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
/*
Minetest
Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>

This program is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/

#include "lua_api/l_internal.h"
#include "common/c_converter.h"
#include "common/c_content.h"
#include "lua_api/l_http.h"
#include "httpfetch.h"
#include "settings.h"
#include "debug.h"
#include "log.h"

#include <algorithm>
#include <iomanip>
#include <cctype>

#define HTTP_API(name) \
	lua_pushstring(L, #name); \
	lua_pushcfunction(L, l_http_##name); \
	lua_settable(L, -3);

#if USE_CURL
void ModApiHttp::read_http_fetch_request(lua_State *L, HTTPFetchRequest &req)
{
	luaL_checktype(L, 1, LUA_TTABLE);

	req.caller = httpfetch_caller_alloc_secure();
	getstringfield(L, 1, "url", req.url);
	lua_getfield(L, 1, "user_agent");
	if (lua_isstring(L, -1))
		req.useragent = getstringfield_default(L, 1, "user_agent", "");
	lua_pop(L, 1);
	req.multipart = getboolfield_default(L, 1, "multipart", false);
	req.timeout = getintfield_default(L, 1, "timeout", 3) * 1000;

	// post_data: if table, post form data, otherwise raw data
	lua_getfield(L, 1, "post_data");
	if (lua_istable(L, 2)) {
		lua_pushnil(L);
		while (lua_next(L, 2) != 0) {
			req.post_fields[readParam<std::string>(L, -2)] = readParam<std::string>(L, -1);
			lua_pop(L, 1);
		}
	} else if (lua_isstring(L, 2)) {
		req.post_data = readParam<std::string>(L, 2);
	}
	lua_pop(L, 1);

	lua_getfield(L, 1, "extra_headers");
	if (lua_istable(L, 2)) {
		lua_pushnil(L);
		while (lua_next(L, 2) != 0) {
			req.extra_headers.emplace_back(readParam<std::string>(L, -1));