Comparison

plugins/mod_http.lua @ 9503:3456496d5218

Merge 0.10->trunk
author Kim Alvefur <zash@zash.se>
date Sun, 14 Oct 2018 14:19:21 +0200
parent 9376:220468f7a103
parent 9502:09e7b0048ebe
child 9504:cfbea3064aa9
comparison
equal deleted inserted replaced
9501:8715961bfa13 9503:3456496d5218
19 server.set_default_host(module:get_option_string("http_default_host")); 19 server.set_default_host(module:get_option_string("http_default_host"));
20 20
21 server.set_option("body_size_limit", module:get_option_number("http_max_content_size")); 21 server.set_option("body_size_limit", module:get_option_number("http_max_content_size"));
22 server.set_option("buffer_size_limit", module:get_option_number("http_max_buffer_size")); 22 server.set_option("buffer_size_limit", module:get_option_number("http_max_buffer_size"));
23 23
24 local function normalize_path(path) 24 local function normalize_path(path, is_dir)
25 if path:sub(-1,-1) == "/" then path = path:sub(1, -2); end 25 if is_dir then
26 if path:sub(-1,-1) ~= "/" then path = path.."/"; end
27 else
28 if path:sub(-1,-1) == "/" then path = path:sub(1, -2); end
29 end
26 if path:sub(1,1) ~= "/" then path = "/"..path; end 30 if path:sub(1,1) ~= "/" then path = "/"..path; end
27 return path; 31 return path;
28 end 32 end
29 33
30 local function get_http_event(host, app_path, key) 34 local function get_http_event(host, app_path, key)
75 for port, service in pairs(ports) do -- luacheck: ignore 512 79 for port, service in pairs(ports) do -- luacheck: ignore 512
76 local url = { 80 local url = {
77 scheme = (external_url.scheme or service[1].service.name); 81 scheme = (external_url.scheme or service[1].service.name);
78 host = (external_url.host or module:get_option_string("http_host", module.host)); 82 host = (external_url.host or module:get_option_string("http_host", module.host));
79 port = tonumber(external_url.port) or port or 80; 83 port = tonumber(external_url.port) or port or 80;
80 path = normalize_path(external_url.path or "/").. 84 path = normalize_path(external_url.path or "/", true)..
81 (get_base_path(module, app_name, default_path or "/"..app_name):sub(2)); 85 (get_base_path(module, app_name, default_path or "/"..app_name):sub(2));
82 } 86 }
83 if ports_by_scheme[url.scheme] == url.port then url.port = nil end 87 if ports_by_scheme[url.scheme] == url.port then url.port = nil end
84 return url_build(url); 88 return url_build(url);
85 end 89 end