aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKim Alvefur <zash@zash.se>2019-10-12 18:27:54 +0200
committerKim Alvefur <zash@zash.se>2019-10-12 18:27:54 +0200
commit8e485ec3200359adcc00731a371b4455d24bb562 (patch)
tree6d89e9b7839f308411ff2cf78ee71cc705326b12
parent89a6f8d8c108bdf633d7d6589c260de833c56bf5 (diff)
downloadprosody-8e485ec3200359adcc00731a371b4455d24bb562.tar.gz
prosody-8e485ec3200359adcc00731a371b4455d24bb562.zip
net.http.server: Re-fire unhandled HEAD requsts as GET events (fixes #1447)
BC: This overloads the GET event. Previous commit ensures HEAD requests are sent without a body.
-rw-r--r--CHANGES1
-rw-r--r--net/http/server.lua11
2 files changed, 12 insertions, 0 deletions
diff --git a/CHANGES b/CHANGES
index 11f1837d..bddf32c6 100644
--- a/CHANGES
+++ b/CHANGES
@@ -11,6 +11,7 @@ TRUNK
- Rewritten migrator
- SCRAM-SHA-256
- Bi-directional server-to-server (XEP-0288)
+- Built-in HTTP server now handles HEAD requests
0.11.0
======
diff --git a/net/http/server.lua b/net/http/server.lua
index 47680455..b649ff5f 100644
--- a/net/http/server.lua
+++ b/net/http/server.lua
@@ -229,6 +229,11 @@ function handle_request(conn, request, finish_cb)
local payload = { request = request, response = response };
log("debug", "Firing event: %s", global_event);
local result = events.fire_event(global_event, payload);
+ if result == nil and is_head_request then
+ local global_head_event = "GET "..request.path:match("[^?]*");
+ log("debug", "Firing event: %s", global_head_event);
+ result = events.fire_event(global_head_event, payload);
+ end
if result == nil then
if not hosts[host] then
if hosts[default_host] then
@@ -249,6 +254,12 @@ function handle_request(conn, request, finish_cb)
local host_event = request.method.." "..host..request.path:match("[^?]*");
log("debug", "Firing event: %s", host_event);
result = events.fire_event(host_event, payload);
+
+ if result == nil and is_head_request then
+ local host_head_event = "GET "..host..request.path:match("[^?]*");
+ log("debug", "Firing event: %s", host_head_event);
+ result = events.fire_event(host_head_event, payload);
+ end
end
if result ~= nil then
if result ~= true then