diff --git a/core/core.js b/core/core.js index ace5f49c..5a508b4e 100644 --- a/core/core.js +++ b/core/core.js @@ -1177,13 +1177,6 @@ loadSettings() return blobHandler(request, response, match[1], match[2]); } else if ((match = /^(.*)(\/(?:save|delete)?)$/.exec(request.uri))) { return blobHandler(request, response, match[1], match[2]); - } else { - let data = 'File not found.'; - response.writeHead(404, { - 'Content-Type': 'text/plain; charset=utf-8', - 'Content-Length': data.length.toString(), - }); - return response.end(data); } }); let port = httpd.start(tildefriends.http_port); diff --git a/src/http.c b/src/http.c index 13f521b3..5233b964 100644 --- a/src/http.c +++ b/src/http.c @@ -107,6 +107,7 @@ static const char* _http_connection_get_header(const tf_http_connection_t* conne static void _http_connection_destroy(tf_http_connection_t* connection, const char* reason); static void _http_timer_reset(tf_http_connection_t* connection); static void _http_tls_update(tf_http_connection_t* connection); +static void _http_builtin_404_handler(tf_http_request_t* request); tf_http_t* tf_http_create(uv_loop_t* loop) { @@ -196,6 +197,10 @@ static void _http_connection_on_close(uv_handle_t* handle) static void _http_request_destroy(tf_http_request_t* request) { tf_http_close_callback* on_close = request->on_close; + if (request->connection && !request->connection->is_response_sent) + { + _http_builtin_404_handler(request); + } if (on_close) { tf_trace_t* trace = request->http->trace;