changeset 13964:36d361722889

mod_http_errors: Fix traceback on missing Accept header Also guards against the request being missing from the event entirely, as is the case with errors from net.http.server runner_callbacks:error()
author Kim Alvefur <zash@zash.se>
date Sun, 28 Sep 2025 00:55:41 +0200
parents 44f859531df7
children e7c52d0b0e0d
files plugins/mod_http_errors.lua
diffstat 1 files changed, 1 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/mod_http_errors.lua	Sat Sep 27 18:26:18 2025 +0200
+++ b/plugins/mod_http_errors.lua	Sun Sep 28 00:55:41 2025 +0200
@@ -83,7 +83,7 @@
 
 -- Return error object as JSON if that's what requester prefers
 module:hook_object_event(server, "http-error", function (event)
-	if event.request.headers.accept:match("^application/json") then
+	if event.request and (event.request.headers.accept or ""):match("^application/json") then
 		event.response.headers.content_type = "application/json";
 		local error = event.request and event.error;
 		if not error then