From c7eb12ad8ee72ba9372c228a8e4f1175fe93618d Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Mon, 18 Dec 2017 19:15:19 +0100 Subject: [PATCH] Return NotFound response for "/favicon.ico" request instead of returning wrong plain text response. --- examples/websocket/application_execution.e | 33 +++++++++++++--------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/examples/websocket/application_execution.e b/examples/websocket/application_execution.e index 99ae28cc..8ea751ea 100644 --- a/examples/websocket/application_execution.e +++ b/examples/websocket/application_execution.e @@ -26,22 +26,27 @@ feature -- Basic operations do -- To send a response we need to setup, the status code and -- the response headers. - if request.path_info.same_string_general ("/app") then - s := websocket_app_html (request.server_name, request.server_port) + if request.path_info.same_string_general ("/favicon.ico") then + response.put_header ({HTTP_STATUS_CODE}.not_found, <<["Content-Length", "0"]>>) else - s := "Hello World!" - create dt.make_now_utc - s.append (" (UTC time is " + dt.rfc850_string + ").") - s.append ("

Websocket demo

") + if request.path_info.same_string_general ("/app") then + s := websocket_app_html (request.server_name, request.server_port) + + else + s := "Hello World!" + create dt.make_now_utc + s.append (" (UTC time is " + dt.rfc850_string + ").") + s.append ("

Websocket demo

") + end + response.put_header ({HTTP_STATUS_CODE}.ok, <<["Content-Type", "text/html"], ["Content-Length", s.count.out]>>) + response.set_status_code ({HTTP_STATUS_CODE}.ok) + response.header.put_content_type_text_html + response.header.put_content_length (s.count) + if request.is_keep_alive_http_connection then + response.header.put_connection_keep_alive + end + response.put_string (s) end - response.put_header ({HTTP_STATUS_CODE}.ok, <<["Content-Type", "text/html"], ["Content-Length", s.count.out]>>) - response.set_status_code ({HTTP_STATUS_CODE}.ok) - response.header.put_content_type_text_html - response.header.put_content_length (s.count) - if request.is_keep_alive_http_connection then - response.header.put_connection_keep_alive - end - response.put_string (s) end feature -- Websocket execution