Comparison

net/http.lua @ 9611:2700317f93e4 0.11

net.http: Manually merge settings (fixes #1231) Metatable table indexing is done raw, so metatables can't be chained
author Kim Alvefur <zash@zash.se>
date Fri, 09 Nov 2018 15:59:32 +0100
parent 9562:acf74ad0b795
child 10112:b327f2870382
child 10994:e2ce067bb59a
comparison
equal deleted inserted replaced
9609:1dfcea523200 9611:2700317f93e4
22 local pairs = pairs; 22 local pairs = pairs;
23 local tonumber, tostring, traceback = 23 local tonumber, tostring, traceback =
24 tonumber, tostring, debug.traceback; 24 tonumber, tostring, debug.traceback;
25 local xpcall = require "util.xpcall".xpcall; 25 local xpcall = require "util.xpcall".xpcall;
26 local error = error 26 local error = error
27 local setmetatable = setmetatable;
28 27
29 local log = require "util.logger".init("http"); 28 local log = require "util.logger".init("http");
30 29
31 local _ENV = nil; 30 local _ENV = nil;
32 -- luacheck: std none 31 -- luacheck: std none
271 local function new(options) 270 local function new(options)
272 local http = { 271 local http = {
273 options = options; 272 options = options;
274 request = request; 273 request = request;
275 new = options and function (new_options) 274 new = options and function (new_options)
276 return new(setmetatable(new_options, { __index = options })); 275 local final_options = {};
276 for k, v in pairs(options) do final_options[k] = v; end
277 if new_options then
278 for k, v in pairs(new_options) do final_options[k] = v; end
279 end
280 return new(final_options);
277 end or new; 281 end or new;
278 events = events.new(); 282 events = events.new();
279 }; 283 };
280 return http; 284 return http;
281 end 285 end