Skip to content

Commit 14d17f3

Browse files
committed
Add configuration option "ignore_unknown_upgrade"
In case when upgrade should be ignored
1 parent 20abe16 commit 14d17f3

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

Diff for: http/server.lua

+16-13
Original file line numberDiff line numberDiff line change
@@ -988,8 +988,10 @@ local function httpd_http11_handler(session)
988988
local proto_name = p.headers['upgrade']:lower()
989989
local proto = session.server.upgrades[proto_name]
990990
if not proto then
991-
session:write('HTTP/1.1 400 Bad Request\r\n\r\n')
992-
return false
991+
if not session.server.options.ignore_unknown_upgrade then
992+
session:write('HTTP/1.1 400 Bad Request\r\n\r\n')
993+
return false
994+
end
993995
else
994996
local ok, upgrade_ok = pcall(proto.upgrade, session, p)
995997
if not ok then
@@ -1249,17 +1251,18 @@ local httpd_mt = {
12491251
}
12501252

12511253
local httpd_options_default = {
1252-
max_header_size = 4096,
1253-
header_timeout = 100,
1254-
handler = handler,
1255-
app_dir = '.',
1256-
charset = 'utf-8',
1257-
cache_templates = true,
1258-
cache_controllers = true,
1259-
cache_static = true,
1260-
log_requests = true,
1261-
log_errors = true,
1262-
display_errors = true,
1254+
max_header_size = 4096,
1255+
header_timeout = 100,
1256+
handler = handler,
1257+
app_dir = '.',
1258+
charset = 'utf-8',
1259+
cache_templates = true,
1260+
cache_controllers = true,
1261+
cache_static = true,
1262+
log_requests = true,
1263+
log_errors = true,
1264+
display_errors = true,
1265+
ignore_unknown_upgrade = true,
12631266
}
12641267

12651268
local function httpd_new(host, port, options)

0 commit comments

Comments
 (0)