Software /
code /
prosody
Comparison
plugins/mod_websocket.lua @ 10325:f2bbad04cf64
mod_websocket: Guard against upgrading to websocket from a HEAD request
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 12 Oct 2019 19:16:43 +0200 |
parent | 10111:0f335815244f |
child | 10582:6d4562acef81 |
comparison
equal
deleted
inserted
replaced
10324:3f4c25425589 | 10325:f2bbad04cf64 |
---|---|
134 local request, response = event.request, event.response; | 134 local request, response = event.request, event.response; |
135 local conn = response.conn; | 135 local conn = response.conn; |
136 | 136 |
137 conn.starttls = false; -- Prevent mod_tls from believing starttls can be done | 137 conn.starttls = false; -- Prevent mod_tls from believing starttls can be done |
138 | 138 |
139 if not request.headers.sec_websocket_key then | 139 if not request.headers.sec_websocket_key or request.method ~= "GET" then |
140 response.headers.content_type = "text/html"; | 140 response.headers.content_type = "text/html"; |
141 return [[<!DOCTYPE html><html><head><title>Websocket</title></head><body> | 141 return [[<!DOCTYPE html><html><head><title>Websocket</title></head><body> |
142 <p>It works! Now point your WebSocket client to this URL to connect to Prosody.</p> | 142 <p>It works! Now point your WebSocket client to this URL to connect to Prosody.</p> |
143 </body></html>]]; | 143 </body></html>]]; |
144 end | 144 end |