forked from cory/tildefriends
		
	js: Move the global 404 response to C.
This commit is contained in:
		| @@ -1177,13 +1177,6 @@ loadSettings() | |||||||
| 				return blobHandler(request, response, match[1], match[2]); | 				return blobHandler(request, response, match[1], match[2]); | ||||||
| 			} else if ((match = /^(.*)(\/(?:save|delete)?)$/.exec(request.uri))) { | 			} else if ((match = /^(.*)(\/(?:save|delete)?)$/.exec(request.uri))) { | ||||||
| 				return blobHandler(request, response, match[1], match[2]); | 				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); | 		let port = httpd.start(tildefriends.http_port); | ||||||
|   | |||||||
| @@ -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_connection_destroy(tf_http_connection_t* connection, const char* reason); | ||||||
| static void _http_timer_reset(tf_http_connection_t* connection); | static void _http_timer_reset(tf_http_connection_t* connection); | ||||||
| static void _http_tls_update(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) | 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) | static void _http_request_destroy(tf_http_request_t* request) | ||||||
| { | { | ||||||
| 	tf_http_close_callback* on_close = request->on_close; | 	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) | 	if (on_close) | ||||||
| 	{ | 	{ | ||||||
| 		tf_trace_t* trace = request->http->trace; | 		tf_trace_t* trace = request->http->trace; | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user