# HG changeset patch # User Kim Alvefur # Date 1570897674 -7200 # Node ID 3f4c254255896ebeb5117a8235069d3d651684bf # Parent 73938168681cd3225599a2dcc68c855b8466f847 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. diff -r 73938168681c -r 3f4c25425589 CHANGES --- a/CHANGES Sat Oct 12 18:27:02 2019 +0200 +++ b/CHANGES Sat Oct 12 18:27:54 2019 +0200 @@ -11,6 +11,7 @@ - Rewritten migrator - SCRAM-SHA-256 - Bi-directional server-to-server (XEP-0288) +- Built-in HTTP server now handles HEAD requests 0.11.0 ====== diff -r 73938168681c -r 3f4c25425589 net/http/server.lua --- a/net/http/server.lua Sat Oct 12 18:27:02 2019 +0200 +++ b/net/http/server.lua Sat Oct 12 18:27:54 2019 +0200 @@ -229,6 +229,11 @@ 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 @@ 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