Skip to content

Commit 88298c8

Browse files
committed
http/server: Refactor ALPN checking logic
1 parent 19a0128 commit 88298c8

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

http/server.lua

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,17 @@ local function wrap_socket(self, socket, timeout)
6363
if not ok then
6464
return nil, err, errno
6565
end
66-
local ssl = socket:checktls()
67-
if ssl and http_tls.has_alpn then
66+
local ssl = assert(socket:checktls())
67+
if http_tls.has_alpn then
6868
local proto = ssl:getAlpnSelected()
69-
if proto == "h2" and (version == nil or version == 2) then
70-
version = 2
71-
elseif (proto == "http/1.1") and (version == nil or version < 2) then
72-
version = 1.1
73-
elseif proto ~= nil then
74-
return nil, "unexpected ALPN protocol: " .. proto, ce.EILSEQNOSUPPORT
69+
if proto then
70+
if proto == "h2" and (version == nil or version == 2) then
71+
version = 2
72+
elseif proto == "http/1.1" and (version == nil or version < 2) then
73+
version = 1.1
74+
else
75+
return nil, "unexpected ALPN protocol: " .. proto, ce.EILSEQNOSUPPORT
76+
end
7577
end
7678
end
7779
end

0 commit comments

Comments
 (0)