From fc8188aeb1fcabfdb4624671083d6fa96acdb2a3 Mon Sep 17 00:00:00 2001 From: Olivier Ligot Date: Mon, 3 Dec 2012 16:29:12 +0100 Subject: [PATCH 1/8] Logging filter The logging filter is now part of EWF core (before it was only available in the filter example) and can therefore be reused by others needing it. Note that this is a first implementation. It can certainly be improved in the future to support more fine grained logging. --- examples/filter/src/filter_server.e | 2 +- .../wsf/router/filter/wsf_logging_filter.e | 21 ++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) rename examples/filter/src/filter/logging_filter.e => library/server/wsf/router/filter/wsf_logging_filter.e (55%) diff --git a/examples/filter/src/filter_server.e b/examples/filter/src/filter_server.e index fff542ac..25d16fef 100644 --- a/examples/filter/src/filter_server.e +++ b/examples/filter/src/filter_server.e @@ -53,7 +53,7 @@ feature {NONE} -- Initialization setup_filter -- Setup `filter' local - l_logging_filter: LOGGING_FILTER + l_logging_filter: WSF_LOGGING_FILTER do create l_logging_filter filter.set_next (l_logging_filter) diff --git a/examples/filter/src/filter/logging_filter.e b/library/server/wsf/router/filter/wsf_logging_filter.e similarity index 55% rename from examples/filter/src/filter/logging_filter.e rename to library/server/wsf/router/filter/wsf_logging_filter.e index e6a8b89b..66bdf8d7 100644 --- a/examples/filter/src/filter/logging_filter.e +++ b/library/server/wsf/router/filter/wsf_logging_filter.e @@ -5,7 +5,7 @@ note revision: "$Revision$" class - LOGGING_FILTER + WSF_LOGGING_FILTER inherit WSF_FILTER @@ -15,24 +15,31 @@ feature -- Basic operations execute (req: WSF_REQUEST; res: WSF_RESPONSE) -- Execute the filter local - l_user_agent: STRING + l_user_agent, l_referer: STRING l_date: DATE_TIME do if attached req.http_user_agent as ua then - l_user_agent := ua.as_string_8 + l_user_agent := "%"" + ua.as_string_8 + "%"" else l_user_agent := "-" end - create l_date.make_now - io.put_string ("[" + l_date.formatted_out (Date_time_format) + "] %"" + req.request_method + " " + req.request_uri - + " " + {HTTP_CONSTANTS}.http_version_1_1 + "%" " + res.status_code.out + " " + l_user_agent) + if attached req.http_referer as r then + l_referer := "%"" + r + "%" " + else + l_referer := "" + end + create l_date.make_now_utc + io.put_string (req.remote_addr + " - - [" + l_date.formatted_out (Date_time_format) + " GMT] %"" + + req.request_method + " " + req.request_uri + + " " + {HTTP_CONSTANTS}.http_version_1_1 + "%" " + res.status_code.out + " " + + res.transfered_content_length.out + " " + l_referer + l_user_agent) io.put_new_line execute_next (req, res) end feature -- Constants - Date_time_format: STRING = "yyyy/[0]mm/[0]dd [0]hh:[0]mi:[0]ss.ff3" + Date_time_format: STRING = "[0]dd/[0]mm/yyyy [0]hh:[0]mi:[0]ss" note copyright: "2011-2012, Olivier Ligot, Jocelyn Fiat and others" From e9376b5d16d3cbe469e10421cf29888516a3552f Mon Sep 17 00:00:00 2001 From: Olivier Ligot Date: Mon, 3 Dec 2012 17:37:26 +0100 Subject: [PATCH 2/8] Fix ise_wizard * ewf.ini was used instead of template.ecf as configuration file * remove initialize_router otherwise the compilation failed * remove unused variables --- tools/ise_wizard/resources/ewf_application.e | 5 ----- tools/ise_wizard/src/ewf_wizard.e | 5 ++--- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/tools/ise_wizard/resources/ewf_application.e b/tools/ise_wizard/resources/ewf_application.e index af64909d..929cd433 100644 --- a/tools/ise_wizard/resources/ewf_application.e +++ b/tools/ise_wizard/resources/ewf_application.e @@ -26,8 +26,6 @@ feature -- Execution -- Default request handler if no other are relevant local mesg: WSF_HTML_PAGE_RESPONSE - s: STRING_8 - l_user_name: READABLE_STRING_32 do create mesg.make mesg.set_title ("Hello World!") @@ -44,9 +42,6 @@ feature {NONE} -- Initialization --| If you don't need any custom options, you are not obliged to redefine `initialize' Precursor - - --| Initialize router - initialize_router end end diff --git a/tools/ise_wizard/src/ewf_wizard.e b/tools/ise_wizard/src/ewf_wizard.e index 9d6f08a6..09bcdd21 100644 --- a/tools/ise_wizard/src/ewf_wizard.e +++ b/tools/ise_wizard/src/ewf_wizard.e @@ -119,15 +119,14 @@ feature -- Form tfn.add_extension ("ecf") copy_resource_template ("template.ecf", tfn.string) + create res.make (tfn.string, d.name) + create tfn.make_from_string (dn.string) tfn.set_file_name ("ewf") tfn.add_extension ("ini") copy_resource_template ("ewf.ini", tfn.string) - - create res.make (tfn.string, d.name) - create dn.make_from_string (pdn) dn.extend (pn) dn.extend ("src") From eb676bd14b54c98cd49d84d5eab1ae6ab8b84c42 Mon Sep 17 00:00:00 2001 From: Olivier Ligot Date: Tue, 4 Dec 2012 14:42:09 +0100 Subject: [PATCH 3/8] ise_wizard Unix shell scripts --- tools/ise_wizard/install_ise_wizard.sh | 15 +++++++++++++++ tools/ise_wizard/install_ise_wizard_custom.sh | 16 ++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100755 tools/ise_wizard/install_ise_wizard.sh create mode 100755 tools/ise_wizard/install_ise_wizard_custom.sh diff --git a/tools/ise_wizard/install_ise_wizard.sh b/tools/ise_wizard/install_ise_wizard.sh new file mode 100755 index 00000000..9b5496ea --- /dev/null +++ b/tools/ise_wizard/install_ise_wizard.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +mkdir tmp +ecb -config ewf_ise_wizard-safe.ecf -target wizard -finalize -c_compile -project_path tmp +mkdir -p spec/$ISE_PLATFORM +mv tmp/EIFGENs/wizard/F_code/wizard spec/$ISE_PLATFORM/wizard +rm -rf tmp + +WIZ_TARGET=$ISE_EIFFEL/studio/wizards/new_projects/ewf +rm -rf $WIZ_TARGET +mkdir $WIZ_TARGET +cp -r resources $WIZ_TARGET/resources +cp -r spec $WIZ_TARGET/spec +cp ewf.dsc $WIZ_TARGET/../ewf.dsc +rm -rf spec diff --git a/tools/ise_wizard/install_ise_wizard_custom.sh b/tools/ise_wizard/install_ise_wizard_custom.sh new file mode 100755 index 00000000..308e7d84 --- /dev/null +++ b/tools/ise_wizard/install_ise_wizard_custom.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +mkdir tmp +ecb -config ewf_ise_wizard-safe.ecf -target custom_wizard -finalize -c_compile -project_path tmp +mkdir -p custom/spec/$ISE_PLATFORM +mv tmp/EIFGENs/custom_wizard/F_code/wizard custom/spec/$ISE_PLATFORM/wizard +rm -rf tmp + +WIZ_TARGET=$ISE_EIFFEL/studio/wizards/new_projects/ewf_custom +rm -rf $WIZ_TARGET +mkdir $WIZ_TARGET +cp -r resources $WIZ_TARGET/resources +cp -f custom/resources/* $WIZ_TARGET/resources +cp -r custom/spec $WIZ_TARGET/spec +cp custom/ewf.dsc $WIZ_TARGET/../ewf_custom.dsc +rm -rf custom/spec From bbf63c1cc063a9abb0f714bbfc32dc69b37d1805 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Wed, 5 Dec 2012 17:01:45 +0100 Subject: [PATCH 4/8] removed fcgi(-safe).ecf files ... since there renamed libfcgi(-safe).ecf --- library/server/libfcgi/fcgi-safe.ecf | 52 ---------------------------- library/server/libfcgi/fcgi.ecf | 52 ---------------------------- 2 files changed, 104 deletions(-) delete mode 100644 library/server/libfcgi/fcgi-safe.ecf delete mode 100644 library/server/libfcgi/fcgi.ecf diff --git a/library/server/libfcgi/fcgi-safe.ecf b/library/server/libfcgi/fcgi-safe.ecf deleted file mode 100644 index 18fd9512..00000000 --- a/library/server/libfcgi/fcgi-safe.ecf +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - /\.svn$ - /\.git$ - /EIFGENs$ - - - - - - - - - - - - - - - - - - - - - - - - - - - - /linux$ - /fake$ - - - - - - /windows$ - /fake$ - - - - - - - diff --git a/library/server/libfcgi/fcgi.ecf b/library/server/libfcgi/fcgi.ecf deleted file mode 100644 index 05d15197..00000000 --- a/library/server/libfcgi/fcgi.ecf +++ /dev/null @@ -1,52 +0,0 @@ - - - - - - /\.svn$ - /\.git$ - /EIFGENs$ - - - - - - - - - - - - - - - - - - - - - - - - - - - - /linux$ - /fake$ - - - - - - /windows$ - /fake$ - - - - - - - From 78b161df16e1cbb4bf25407eef06fb3144d63b96 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Wed, 5 Dec 2012 22:19:59 +0100 Subject: [PATCH 5/8] Prepare upcoming support for unicode environment variables --- .../ewsgi/connectors/nino/src/wgi_nino_handler.e | 14 +++++++++++--- .../src/implementation/wgi_request_from_table.e | 6 +++--- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/library/server/ewsgi/connectors/nino/src/wgi_nino_handler.e b/library/server/ewsgi/connectors/nino/src/wgi_nino_handler.e index 07b683b2..7d03a525 100644 --- a/library/server/ewsgi/connectors/nino/src/wgi_nino_handler.e +++ b/library/server/ewsgi/connectors/nino/src/wgi_nino_handler.e @@ -61,7 +61,7 @@ feature -- Request processing process_request (a_handler: HTTP_CONNECTION_HANDLER; a_socket: TCP_STREAM_SOCKET) -- Process request ... local - env, vars: HASH_TABLE [STRING, STRING] + env: HASH_TABLE [STRING, STRING] p: INTEGER l_request_uri, l_script_name, l_query_string, l_path_info: STRING l_server_name, l_server_port: detachable STRING @@ -73,8 +73,16 @@ feature -- Request processing l_request_uri := a_handler.uri a_headers_map := a_handler.request_header_map create e - vars := e.starting_environment_variables - env := vars.twin + if attached e.starting_environment as vars then + create env.make (vars.count) + across + vars as c + loop + env.force (c.item.to_string_8, c.key.to_string_8) + end + else + create env.make (0) + end --| for Any Abc-Def-Ghi add (or replace) the HTTP_ABC_DEF_GHI variable to `env' from diff --git a/library/server/ewsgi/src/implementation/wgi_request_from_table.e b/library/server/ewsgi/src/implementation/wgi_request_from_table.e index 29dec9d2..1545e2a1 100644 --- a/library/server/ewsgi/src/implementation/wgi_request_from_table.e +++ b/library/server/ewsgi/src/implementation/wgi_request_from_table.e @@ -19,7 +19,7 @@ create feature {NONE} -- Initialization - make (a_vars: HASH_TABLE [READABLE_STRING_8, READABLE_STRING_8]; a_input: like input; a_wgi_connector: like wgi_connector) + make (a_vars: HASH_TABLE [READABLE_STRING_GENERAL, READABLE_STRING_GENERAL]; a_input: like input; a_wgi_connector: like wgi_connector) require vars_attached: a_vars /= Void do @@ -244,7 +244,7 @@ feature -- Access: Extension to CGI meta parameters - 1.1 feature {NONE} -- Element change: CGI meta parameter related to PATH_INFO - set_meta_variables (a_vars: HASH_TABLE [READABLE_STRING_8, READABLE_STRING_8]) + set_meta_variables (a_vars: HASH_TABLE [READABLE_STRING_GENERAL, READABLE_STRING_GENERAL]) -- Fill with variable from `a_vars' local s: like meta_string_variable @@ -264,7 +264,7 @@ feature {NONE} -- Element change: CGI meta parameter related to PATH_INFO until a_vars.after loop - table.force (a_vars.item_for_iteration, a_vars.key_for_iteration) + table.force (a_vars.item_for_iteration.to_string_8, a_vars.key_for_iteration.to_string_8) a_vars.forth end From 43df8f573b09a2ae67c7acb86dae2a1aa2b34b14 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Wed, 5 Dec 2012 22:20:56 +0100 Subject: [PATCH 6/8] Provide a way to log into a file, rather than just console output Minor optimization for WSF_LOGGING_FILTER --- .../wsf/router/filter/wsf_logging_filter.e | 78 +++++++++++++++---- 1 file changed, 62 insertions(+), 16 deletions(-) diff --git a/library/server/wsf/router/filter/wsf_logging_filter.e b/library/server/wsf/router/filter/wsf_logging_filter.e index 66bdf8d7..23b5db9a 100644 --- a/library/server/wsf/router/filter/wsf_logging_filter.e +++ b/library/server/wsf/router/filter/wsf_logging_filter.e @@ -9,31 +9,77 @@ class inherit WSF_FILTER + redefine + default_create + end + +create + default_create, + make_with_output + +feature {NONE} -- Initialization + + default_create + do + Precursor + output := io.output + end + + make_with_output (a_output: like output) + -- Create Current with `a_output' as `output' + require + a_output_opened: a_output.is_open_read + do + default_create + output := a_output + end + + output: FILE + -- Output file + --| Could be stdout, or a file... feature -- Basic operations execute (req: WSF_REQUEST; res: WSF_RESPONSE) -- Execute the filter local - l_user_agent, l_referer: STRING l_date: DATE_TIME + s: STRING do - if attached req.http_user_agent as ua then - l_user_agent := "%"" + ua.as_string_8 + "%"" - else - l_user_agent := "-" - end - if attached req.http_referer as r then - l_referer := "%"" + r + "%" " - else - l_referer := "" - end + create s.make (64) + s.append (req.remote_addr) + s.append (" - - [") create l_date.make_now_utc - io.put_string (req.remote_addr + " - - [" + l_date.formatted_out (Date_time_format) + " GMT] %"" - + req.request_method + " " + req.request_uri - + " " + {HTTP_CONSTANTS}.http_version_1_1 + "%" " + res.status_code.out + " " - + res.transfered_content_length.out + " " + l_referer + l_user_agent) - io.put_new_line + s.append (l_date.formatted_out (Date_time_format)) + s.append (" GMT] %"") + s.append (req.request_method) + s.append_character (' ') + s.append (req.request_uri) + s.append_character (' ') + s.append ({HTTP_CONSTANTS}.http_version_1_1) + s.append_character ('%"') + s.append_character (' ') + s.append_integer (res.status_code) + s.append_character (' ') + s.append_natural_64 (res.transfered_content_length) + s.append_character (' ') + if attached req.http_referer as r then + s.append_character ('%"') + s.append_character ('%"') + s.append (r) + s.append_character (' ') + end + + if attached req.http_user_agent as ua then + s.append_character ('%"') + s.append (ua) + s.append_character ('%"') + else + s.append_character ('-') + end + + output.put_string (s) + output.put_new_line execute_next (req, res) end From e1dffa542e045f86905ed2ec507a0aa83be3854e Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Wed, 5 Dec 2012 22:21:36 +0100 Subject: [PATCH 7/8] use libfcgi(-safe).ecf rather than fcgi(-safe).ecf --- library/server/libfcgi/tests/eiffelweb-safe.ecf | 2 +- library/server/libfcgi/tests/eiffelweb.ecf | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/server/libfcgi/tests/eiffelweb-safe.ecf b/library/server/libfcgi/tests/eiffelweb-safe.ecf index 31acd804..781bae86 100644 --- a/library/server/libfcgi/tests/eiffelweb-safe.ecf +++ b/library/server/libfcgi/tests/eiffelweb-safe.ecf @@ -10,7 +10,7 @@ - + diff --git a/library/server/libfcgi/tests/eiffelweb.ecf b/library/server/libfcgi/tests/eiffelweb.ecf index 35a36f2f..2167feb5 100644 --- a/library/server/libfcgi/tests/eiffelweb.ecf +++ b/library/server/libfcgi/tests/eiffelweb.ecf @@ -10,7 +10,7 @@ - + From 2ed861e3d958cb8ff570585941ae1a53ccc439b6 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Wed, 5 Dec 2012 22:26:58 +0100 Subject: [PATCH 8/8] added tests\all-safe.ecf to compile most of EWF's lib, to quickly check the compilation state --- library/server/request/router/OBSOLETE.txt | 1 - library/server/request/router/license.lic | 10 ------- library/server/request/router/router-safe.ecf | 16 ----------- library/server/request/router/router.ecf | 16 ----------- tests/all-safe.ecf | 28 +++++++++++++++++++ 5 files changed, 28 insertions(+), 43 deletions(-) delete mode 100644 library/server/request/router/OBSOLETE.txt delete mode 100644 library/server/request/router/license.lic delete mode 100644 library/server/request/router/router-safe.ecf delete mode 100644 library/server/request/router/router.ecf create mode 100644 tests/all-safe.ecf diff --git a/library/server/request/router/OBSOLETE.txt b/library/server/request/router/OBSOLETE.txt deleted file mode 100644 index aecee2d5..00000000 --- a/library/server/request/router/OBSOLETE.txt +++ /dev/null @@ -1 +0,0 @@ -Now the router library is part of ../../wsf library \ No newline at end of file diff --git a/library/server/request/router/license.lic b/library/server/request/router/license.lic deleted file mode 100644 index d4d72876..00000000 --- a/library/server/request/router/license.lic +++ /dev/null @@ -1,10 +0,0 @@ -${NOTE_KEYWORD} - copyright: "2011-${YEAR}, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" - license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" - source: "[ - Eiffel Software - 5949 Hollister Ave., Goleta, CA 93117 USA - Telephone 805-685-1006, Fax 805-685-6869 - Website http://www.eiffel.com - Customer support http://support.eiffel.com - ]" diff --git a/library/server/request/router/router-safe.ecf b/library/server/request/router/router-safe.ecf deleted file mode 100644 index 3af161c9..00000000 --- a/library/server/request/router/router-safe.ecf +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - /.git$ - /EIFGENs$ - /.svn$ - - - - - - diff --git a/library/server/request/router/router.ecf b/library/server/request/router/router.ecf deleted file mode 100644 index 3ffd7d4c..00000000 --- a/library/server/request/router/router.ecf +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - /.git$ - /EIFGENs$ - /.svn$ - - - - - - diff --git a/tests/all-safe.ecf b/tests/all-safe.ecf new file mode 100644 index 00000000..46d43a72 --- /dev/null +++ b/tests/all-safe.ecf @@ -0,0 +1,28 @@ + + + compile many lib from EWF + + + + /.git$ + /EIFGENs$ + /.svn$ + + + + + + + + + + + + + + + + + +