From 4907bc3085c1077733d52eb56670ea75ff1ec7ce Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Tue, 31 Mar 2015 14:50:20 +0200 Subject: [PATCH] Migrated most of the example and library to new design. --- .../custom-template/src/application.e | 81 +----- .../src/application_execution.e | 60 +++++ .../examples/custom/src/application.e | 81 +----- .../custom/src/application_execution.e | 60 +++++ .../wsf_js_widget/examples/demo/application.e | 148 +---------- .../examples/demo/application_execution.e | 114 +++++++++ examples/debug/debug.ecf | 6 +- .../launcher/any/application_launcher_i.e | 16 +- examples/desktop_app/desktop_app.ecf | 9 +- .../src/app_embedded_web_execution.e | 239 ++++++++++++++++++ .../src/app_embedded_web_service.e | 214 +--------------- examples/desktop_app/src/desktop_app.e | 46 +++- .../src/service/embedded_web_execution.e | 63 +++++ .../src/service/embedded_web_service.e | 86 +------ .../shared_embeded_web_service_information.e | 16 +- examples/filter/filter-safe.ecf | 22 +- examples/filter/src/database/database_api.e | 33 ++- .../filter/src/filter/authentication_filter.e | 17 +- examples/filter/src/filter_server.e | 65 +---- examples/filter/src/filter_server_execution.e | 82 ++++++ examples/filter/src/resource/user_handler.e | 10 +- examples/restbucksCRUD/src/restbucks_server.e | 30 +-- .../src/restbucks_server_execution.e | 57 +++++ examples/simple/application.e | 10 +- examples/simple/application_execution.e | 34 +++ examples/simple/simple.ecf | 6 +- examples/simple_file/service_file.ecf | 4 +- .../src/image_uploader_execution.e | 43 +--- .../openid/consumer/demo/application.e | 118 +-------- .../consumer/demo/application_execution.e | 131 ++++++++++ .../http_authorization/example/demo_basic.e | 210 +-------------- .../example/demo_basic_execution.e | 226 +++++++++++++++++ .../ewsgi/connectors/nino/src/nino_service.e | 17 -- .../{httpd => standalone}/dev/app_counter.e | 0 .../dev/app_wsf_execution.e | 0 .../dev/httpd_connector_dev.e | 13 +- .../{httpd => standalone}/license.lic | 0 .../none/httpd_connection_handler.e | 0 .../concurrency/none/httpd_request_handler.e | 0 .../none/httpd_request_handler_factory.e | 0 .../scoop/httpd_connection_handler.e | 0 .../concurrency/scoop/httpd_request_handler.e | 0 .../scoop/httpd_request_handler_factory.e | 0 .../concurrency/scoop/pool/concurrent_pool.e | 0 .../scoop/pool/concurrent_pool_factory.e | 0 .../scoop/pool/concurrent_pool_item.e | 0 .../thread/httpd_connection_handler.e | 0 .../thread/httpd_request_handler.e | 0 .../thread/httpd_request_handler_factory.e | 0 .../concurrency/thread/pool/pooled_thread.e | 0 .../concurrency/thread/pool/thread_pool.e | 0 .../configuration/httpd_configuration_i.e | 0 .../src/httpd/httpd-safe.ecf | 0 .../{httpd => standalone}/src/httpd/httpd.ecf | 0 .../src/httpd/httpd_connection_handler_i.e | 0 .../src/httpd/httpd_controller.e | 0 .../src/httpd/httpd_debug_facilities.e | 0 .../src/httpd/httpd_logger.e | 0 .../httpd/httpd_request_handler_factory_i.e | 0 .../src/httpd/httpd_request_handler_i.e | 106 +++++++- .../src/httpd/httpd_server_i.e | 72 ++++-- .../src/httpd/httpd_server_observer.e | 24 ++ .../src/httpd/network/httpd_stream_socket.e | 0 .../src/httpd/network/tcp_stream_socket.e | 0 .../src/httpd/no_ssl/httpd_configuration.e | 0 .../src/httpd/no_ssl/httpd_server.e | 0 .../src/httpd/ssl/httpd_configuration.e | 0 .../src/httpd/ssl/httpd_server.e | 0 .../src/httpd/ssl/httpd_stream_ssl_socket.e | 0 .../src/httpd/ssl/ssl_tcp_stream_socket.e | 0 .../wgi_httpd_request_handler.e | 24 +- .../wgi_httpd_request_handler_factory.e | 2 +- .../src/wgi_standalone_connector.e} | 89 +++++-- .../src/wgi_standalone_error_stream.e} | 6 +- .../src/wgi_standalone_input_stream.e} | 6 +- .../src/wgi_standalone_output_stream.e} | 6 +- .../src/wgi_standalone_response_stream.e} | 12 +- .../src/wgi_standalone_server_observer.e} | 39 ++- .../standalone-safe.ecf} | 22 +- .../connectors/standalone/standalone.ecf | 23 ++ .../examples/hello_world/src/hello_world.e | 11 +- .../hello_world/src/hello_world_execution.e | 36 +++ .../connector/wgi_execution_factory.e} | 12 +- .../request/wgi_request_cgi_variables.e | 2 +- .../wsf_openshift_service_launcher.e | 10 +- .../{httpd-safe.ecf => standalone-safe.ecf} | 8 +- library/server/wsf/connector/standalone.ecf | 22 ++ .../wsf_standalone_service_launcher.e} | 23 +- .../cgi/wsf_default_response_service.e | 24 -- .../wsf/default/cgi/wsf_default_service.e | 6 +- .../httpd/wsf_default_response_service.e | 24 -- .../libfcgi/wsf_default_response_service.e | 24 -- .../wsf/default/libfcgi/wsf_default_service.e | 6 +- .../libfcgi/wsf_default_service_launcher.e | 10 +- .../openshift/wsf_default_response_service.e | 24 -- .../default/openshift/wsf_default_service.e | 6 +- .../openshift/wsf_default_service_launcher.e | 10 +- .../{httpd-safe.ecf => standalone-safe.ecf} | 8 +- library/server/wsf/default/standalone.ecf | 17 ++ .../wsf_default_service.e | 0 .../wsf_default_service_launcher.e | 4 +- .../router/filter/wsf_filtered_execution.e | 92 +++++++ .../service/wsf_routed_skeleton_execution.e | 4 +- .../router/wsf_filtered_routed_execution.e | 68 +++++ .../server/wsf/router/wsf_routed_execution.e | 45 +++- ...onse_service.e => wsf_execution_factory.e} | 27 +- library/server/wsf/src/wsf_response.e | 2 +- .../server/wsf/tests/echo/src/echo_server.e | 51 +--- .../tests/echo/src/echo_server_execution.e | 59 +++++ library/server/wsf/tests/server/test.e | 36 +-- .../server/wsf/tests/server/test_execution.e | 51 ++++ .../wsf/tests/server/test_execution_i.e | 195 ++++++++++++++ .../server/wsf/tests/server/test_service.e | 178 +------------ .../server/wsf/tests/src/test_wsf_request.e | 11 +- .../tests/src/test_wsf_response_test_suite.e | 13 +- .../server/wsf/tests/src/wsf_service_null.e | 26 -- tests/all-stable-safe.ecf | 3 + .../rootdir/resources/${APP_NAME}.ecf | 34 +-- .../launcher/any/application_launcher_i.e | 44 ++-- .../resources/launcher/application_launcher.e | 4 +- .../launcher/default/application_launcher_i.e | 10 +- .../rootdir/resources/src/${APP_ROOT}.e | 24 +- .../resources/src/${APP_ROOT}_EXECUTION.e | 89 +++++++ tools/estudio_wizard/src/ewf_wizard.e | 37 ++- 124 files changed, 2399 insertions(+), 1789 deletions(-) create mode 100644 draft/library/server/wsf_js_widget/examples/custom-template/src/application_execution.e create mode 100644 draft/library/server/wsf_js_widget/examples/custom/src/application_execution.e create mode 100644 draft/library/server/wsf_js_widget/examples/demo/application_execution.e create mode 100644 examples/desktop_app/src/app_embedded_web_execution.e create mode 100644 examples/desktop_app/src/service/embedded_web_execution.e create mode 100644 examples/filter/src/filter_server_execution.e create mode 100644 examples/restbucksCRUD/src/restbucks_server_execution.e create mode 100644 examples/simple/application_execution.e create mode 100644 library/security/openid/consumer/demo/application_execution.e create mode 100644 library/server/authentication/http_authorization/example/demo_basic_execution.e rename library/server/ewsgi/connectors/{httpd => standalone}/dev/app_counter.e (100%) rename library/server/ewsgi/connectors/{httpd => standalone}/dev/app_wsf_execution.e (100%) rename library/server/ewsgi/connectors/{httpd => standalone}/dev/httpd_connector_dev.e (68%) rename library/server/ewsgi/connectors/{httpd => standalone}/license.lic (100%) rename library/server/ewsgi/connectors/{httpd => standalone}/src/httpd/concurrency/none/httpd_connection_handler.e (100%) rename library/server/ewsgi/connectors/{httpd => standalone}/src/httpd/concurrency/none/httpd_request_handler.e (100%) rename library/server/ewsgi/connectors/{httpd => standalone}/src/httpd/concurrency/none/httpd_request_handler_factory.e (100%) rename library/server/ewsgi/connectors/{httpd => standalone}/src/httpd/concurrency/scoop/httpd_connection_handler.e (100%) rename library/server/ewsgi/connectors/{httpd => standalone}/src/httpd/concurrency/scoop/httpd_request_handler.e (100%) rename library/server/ewsgi/connectors/{httpd => standalone}/src/httpd/concurrency/scoop/httpd_request_handler_factory.e (100%) rename library/server/ewsgi/connectors/{httpd => standalone}/src/httpd/concurrency/scoop/pool/concurrent_pool.e (100%) rename library/server/ewsgi/connectors/{httpd => standalone}/src/httpd/concurrency/scoop/pool/concurrent_pool_factory.e (100%) rename library/server/ewsgi/connectors/{httpd => standalone}/src/httpd/concurrency/scoop/pool/concurrent_pool_item.e (100%) rename library/server/ewsgi/connectors/{httpd => standalone}/src/httpd/concurrency/thread/httpd_connection_handler.e (100%) rename library/server/ewsgi/connectors/{httpd => standalone}/src/httpd/concurrency/thread/httpd_request_handler.e (100%) rename library/server/ewsgi/connectors/{httpd => standalone}/src/httpd/concurrency/thread/httpd_request_handler_factory.e (100%) rename library/server/ewsgi/connectors/{httpd => standalone}/src/httpd/concurrency/thread/pool/pooled_thread.e (100%) rename library/server/ewsgi/connectors/{httpd => standalone}/src/httpd/concurrency/thread/pool/thread_pool.e (100%) rename library/server/ewsgi/connectors/{httpd => standalone}/src/httpd/configuration/httpd_configuration_i.e (100%) rename library/server/ewsgi/connectors/{httpd => standalone}/src/httpd/httpd-safe.ecf (100%) rename library/server/ewsgi/connectors/{httpd => standalone}/src/httpd/httpd.ecf (100%) rename library/server/ewsgi/connectors/{httpd => standalone}/src/httpd/httpd_connection_handler_i.e (100%) rename library/server/ewsgi/connectors/{httpd => standalone}/src/httpd/httpd_controller.e (100%) rename library/server/ewsgi/connectors/{httpd => standalone}/src/httpd/httpd_debug_facilities.e (100%) rename library/server/ewsgi/connectors/{httpd => standalone}/src/httpd/httpd_logger.e (100%) rename library/server/ewsgi/connectors/{httpd => standalone}/src/httpd/httpd_request_handler_factory_i.e (100%) rename library/server/ewsgi/connectors/{httpd => standalone}/src/httpd/httpd_request_handler_i.e (71%) rename library/server/ewsgi/connectors/{httpd => standalone}/src/httpd/httpd_server_i.e (88%) create mode 100644 library/server/ewsgi/connectors/standalone/src/httpd/httpd_server_observer.e rename library/server/ewsgi/connectors/{httpd => standalone}/src/httpd/network/httpd_stream_socket.e (100%) rename library/server/ewsgi/connectors/{httpd => standalone}/src/httpd/network/tcp_stream_socket.e (100%) rename library/server/ewsgi/connectors/{httpd => standalone}/src/httpd/no_ssl/httpd_configuration.e (100%) rename library/server/ewsgi/connectors/{httpd => standalone}/src/httpd/no_ssl/httpd_server.e (100%) rename library/server/ewsgi/connectors/{httpd => standalone}/src/httpd/ssl/httpd_configuration.e (100%) rename library/server/ewsgi/connectors/{httpd => standalone}/src/httpd/ssl/httpd_server.e (100%) rename library/server/ewsgi/connectors/{httpd => standalone}/src/httpd/ssl/httpd_stream_ssl_socket.e (100%) rename library/server/ewsgi/connectors/{httpd => standalone}/src/httpd/ssl/ssl_tcp_stream_socket.e (100%) rename library/server/ewsgi/connectors/{httpd/src => standalone/src/implementation}/wgi_httpd_request_handler.e (92%) rename library/server/ewsgi/connectors/{httpd/src => standalone/src/implementation}/wgi_httpd_request_handler_factory.e (93%) rename library/server/ewsgi/connectors/{httpd/src/wgi_httpd_connector.e => standalone/src/wgi_standalone_connector.e} (71%) rename library/server/ewsgi/connectors/{httpd/src/wgi_httpd_error_stream.e => standalone/src/wgi_standalone_error_stream.e} (87%) rename library/server/ewsgi/connectors/{httpd/src/wgi_httpd_input_stream.e => standalone/src/wgi_standalone_input_stream.e} (92%) rename library/server/ewsgi/connectors/{httpd/src/wgi_httpd_output_stream.e => standalone/src/wgi_standalone_output_stream.e} (92%) rename library/server/ewsgi/connectors/{httpd/src/wgi_httpd_response_stream.e => standalone/src/wgi_standalone_response_stream.e} (72%) rename library/server/ewsgi/connectors/{httpd/dev/app_wsf_httpd_request_handler.e => standalone/src/wgi_standalone_server_observer.e} (53%) rename library/server/ewsgi/connectors/{httpd/httpd-safe.ecf => standalone/standalone-safe.ecf} (68%) create mode 100644 library/server/ewsgi/connectors/standalone/standalone.ecf create mode 100644 library/server/ewsgi/examples/hello_world/src/hello_world_execution.e rename library/server/{wsf/default/nino/wsf_default_response_service.e => ewsgi/specification/connector/wgi_execution_factory.e} (68%) rename library/server/wsf/connector/{httpd-safe.ecf => standalone-safe.ecf} (77%) create mode 100644 library/server/wsf/connector/standalone.ecf rename library/server/wsf/connector/{httpd/wsf_httpd_service_launcher.e => standalone/wsf_standalone_service_launcher.e} (85%) delete mode 100644 library/server/wsf/default/cgi/wsf_default_response_service.e delete mode 100644 library/server/wsf/default/httpd/wsf_default_response_service.e delete mode 100644 library/server/wsf/default/libfcgi/wsf_default_response_service.e delete mode 100644 library/server/wsf/default/openshift/wsf_default_response_service.e rename library/server/wsf/default/{httpd-safe.ecf => standalone-safe.ecf} (69%) create mode 100644 library/server/wsf/default/standalone.ecf rename library/server/wsf/default/{httpd => standalone}/wsf_default_service.e (100%) rename library/server/wsf/default/{httpd => standalone}/wsf_default_service_launcher.e (82%) create mode 100644 library/server/wsf/router/filter/wsf_filtered_execution.e create mode 100644 library/server/wsf/router/wsf_filtered_routed_execution.e rename library/server/wsf/src/{service/wsf_response_service.e => wsf_execution_factory.e} (50%) create mode 100644 library/server/wsf/tests/echo/src/echo_server_execution.e create mode 100644 library/server/wsf/tests/server/test_execution.e create mode 100644 library/server/wsf/tests/server/test_execution_i.e delete mode 100644 library/server/wsf/tests/src/wsf_service_null.e create mode 100644 tools/estudio_wizard/rootdir/resources/src/${APP_ROOT}_EXECUTION.e diff --git a/draft/library/server/wsf_js_widget/examples/custom-template/src/application.e b/draft/library/server/wsf_js_widget/examples/custom-template/src/application.e index b7c07219..8377165e 100644 --- a/draft/library/server/wsf_js_widget/examples/custom-template/src/application.e +++ b/draft/library/server/wsf_js_widget/examples/custom-template/src/application.e @@ -8,23 +8,11 @@ class inherit - WSF_ROUTED_SERVICE - rename - execute as execute_router - end - - WSF_FILTERED_SERVICE - - WSF_DEFAULT_SERVICE + WSF_DEFAULT_SERVICE [APPLICATION_EXECUTION] redefine initialize end - WSF_FILTER - rename - execute as execute_router - end - create make_and_launch @@ -33,75 +21,8 @@ feature {NONE} -- Initialization initialize -- Initialize current service. do - initialize_router - initialize_filter Precursor set_service_option ("port", 7070) end -feature -- Router and Filter - - create_filter - -- Create `filter' - local - f, l_filter: detachable WSF_FILTER - do - l_filter := Void - - -- Maintenance - create {WSF_MAINTENANCE_FILTER} f - f.set_next (l_filter) - l_filter := f - - -- Logging - create {WSF_LOGGING_FILTER} f - f.set_next (l_filter) - l_filter := f - filter := l_filter - end - - setup_filter - -- Setup `filter' - local - f: WSF_FILTER - do - from - f := filter - until - not attached f.next as l_next - loop - f := l_next - end - f.set_next (Current) - end - - setup_router - do - map_agent_uri ("/", agent execute_hello, Void) - -- NOTE: you could put all those files in a specific folder, and use WSF_FILE_SYSTEM_HANDLER with "/" - -- this way, it handles the caching and so on - router.handle_with_request_methods ("/assets", create {WSF_FILE_SYSTEM_HANDLER}.make_hidden ("assets"), router.methods_GET) - end - -feature -- Helper: mapping - - map_agent_uri (a_uri: READABLE_STRING_8; a_action: like {WSF_URI_AGENT_HANDLER}.action; rqst_methods: detachable WSF_REQUEST_METHODS) - do - router.map_with_request_methods (create {WSF_URI_MAPPING}.make (a_uri, create {WSF_URI_AGENT_HANDLER}.make (a_action)), rqst_methods) - end - - -feature -- Execution - - execute_hello (request: WSF_REQUEST; response: WSF_RESPONSE) - local - page: EMPTY_PAGE - do - -- To send a response we need to setup, the status code and - -- the response headers. - create page.make (request, response) - page.execute - end - - end diff --git a/draft/library/server/wsf_js_widget/examples/custom-template/src/application_execution.e b/draft/library/server/wsf_js_widget/examples/custom-template/src/application_execution.e new file mode 100644 index 00000000..d40b45ce --- /dev/null +++ b/draft/library/server/wsf_js_widget/examples/custom-template/src/application_execution.e @@ -0,0 +1,60 @@ +note + description: "simple application root class" + date: "$Date$" + revision: "$Revision$" + +class + APPLICATION_EXECUTION + +inherit + + WSF_FILTERED_ROUTED_EXECUTION + +create + make + +feature -- Router and Filter + + create_filter + -- Create `filter' + do + -- Maintenance + create {WSF_MAINTENANCE_FILTER} filter + end + + setup_filter + -- Setup `filter' + do + append_filters (<>) + end + + setup_router + do + map_agent_uri ("/", agent execute_hello, Void) + -- NOTE: you could put all those files in a specific folder, and use WSF_FILE_SYSTEM_HANDLER with "/" + -- this way, it handles the caching and so on + router.handle_with_request_methods ("/assets", create {WSF_FILE_SYSTEM_HANDLER}.make_hidden ("assets"), router.methods_GET) + end + +feature -- Helper: mapping + + map_agent_uri (a_uri: READABLE_STRING_8; a_action: like {WSF_URI_AGENT_HANDLER}.action; rqst_methods: detachable WSF_REQUEST_METHODS) + do + router.map_with_request_methods (create {WSF_URI_MAPPING}.make (a_uri, create {WSF_URI_AGENT_HANDLER}.make (a_action)), rqst_methods) + end + + +feature -- Execution + + execute_hello (req: WSF_REQUEST; res: WSF_RESPONSE) + local + page: EMPTY_PAGE + do + -- To send a response we need to setup, the status code and + -- the response headers. + create page.make (req, res) + page.execute + end + + +end diff --git a/draft/library/server/wsf_js_widget/examples/custom/src/application.e b/draft/library/server/wsf_js_widget/examples/custom/src/application.e index b7c07219..8377165e 100644 --- a/draft/library/server/wsf_js_widget/examples/custom/src/application.e +++ b/draft/library/server/wsf_js_widget/examples/custom/src/application.e @@ -8,23 +8,11 @@ class inherit - WSF_ROUTED_SERVICE - rename - execute as execute_router - end - - WSF_FILTERED_SERVICE - - WSF_DEFAULT_SERVICE + WSF_DEFAULT_SERVICE [APPLICATION_EXECUTION] redefine initialize end - WSF_FILTER - rename - execute as execute_router - end - create make_and_launch @@ -33,75 +21,8 @@ feature {NONE} -- Initialization initialize -- Initialize current service. do - initialize_router - initialize_filter Precursor set_service_option ("port", 7070) end -feature -- Router and Filter - - create_filter - -- Create `filter' - local - f, l_filter: detachable WSF_FILTER - do - l_filter := Void - - -- Maintenance - create {WSF_MAINTENANCE_FILTER} f - f.set_next (l_filter) - l_filter := f - - -- Logging - create {WSF_LOGGING_FILTER} f - f.set_next (l_filter) - l_filter := f - filter := l_filter - end - - setup_filter - -- Setup `filter' - local - f: WSF_FILTER - do - from - f := filter - until - not attached f.next as l_next - loop - f := l_next - end - f.set_next (Current) - end - - setup_router - do - map_agent_uri ("/", agent execute_hello, Void) - -- NOTE: you could put all those files in a specific folder, and use WSF_FILE_SYSTEM_HANDLER with "/" - -- this way, it handles the caching and so on - router.handle_with_request_methods ("/assets", create {WSF_FILE_SYSTEM_HANDLER}.make_hidden ("assets"), router.methods_GET) - end - -feature -- Helper: mapping - - map_agent_uri (a_uri: READABLE_STRING_8; a_action: like {WSF_URI_AGENT_HANDLER}.action; rqst_methods: detachable WSF_REQUEST_METHODS) - do - router.map_with_request_methods (create {WSF_URI_MAPPING}.make (a_uri, create {WSF_URI_AGENT_HANDLER}.make (a_action)), rqst_methods) - end - - -feature -- Execution - - execute_hello (request: WSF_REQUEST; response: WSF_RESPONSE) - local - page: EMPTY_PAGE - do - -- To send a response we need to setup, the status code and - -- the response headers. - create page.make (request, response) - page.execute - end - - end diff --git a/draft/library/server/wsf_js_widget/examples/custom/src/application_execution.e b/draft/library/server/wsf_js_widget/examples/custom/src/application_execution.e new file mode 100644 index 00000000..c7640ef6 --- /dev/null +++ b/draft/library/server/wsf_js_widget/examples/custom/src/application_execution.e @@ -0,0 +1,60 @@ +note + description: "simple application root class" + date: "$Date$" + revision: "$Revision$" + +class + APPLICATION_EXECUTION + +inherit + + WSF_FILTERED_ROUTED_EXECUTION + +create + make + +feature -- Router and Filter + + create_filter + -- Create `filter' + do + -- Maintenance + create {WSF_MAINTENANCE_FILTER} filter + end + + setup_filter + -- Setup `filter' + do + append_filters (<< create {WSF_LOGGING_FILTER} >>) + end + + setup_router + do + map_agent_uri ("/", agent execute_hello, Void) + -- NOTE: you could put all those files in a specific folder, and use WSF_FILE_SYSTEM_HANDLER with "/" + -- this way, it handles the caching and so on + router.handle_with_request_methods ("/assets", create {WSF_FILE_SYSTEM_HANDLER}.make_hidden ("assets"), router.methods_GET) + end + +feature -- Helper: mapping + + map_agent_uri (a_uri: READABLE_STRING_8; a_action: like {WSF_URI_AGENT_HANDLER}.action; rqst_methods: detachable WSF_REQUEST_METHODS) + do + router.map_with_request_methods (create {WSF_URI_MAPPING}.make (a_uri, create {WSF_URI_AGENT_HANDLER}.make (a_action)), rqst_methods) + end + + +feature -- Execution + + execute_hello (req: WSF_REQUEST; res: WSF_RESPONSE) + local + page: EMPTY_PAGE + do + -- To send a response we need to setup, the status code and + -- the response headers. + create page.make (req, res) + page.execute + end + + +end diff --git a/draft/library/server/wsf_js_widget/examples/demo/application.e b/draft/library/server/wsf_js_widget/examples/demo/application.e index 99986f57..9da734b8 100644 --- a/draft/library/server/wsf_js_widget/examples/demo/application.e +++ b/draft/library/server/wsf_js_widget/examples/demo/application.e @@ -8,168 +8,22 @@ class inherit - WSF_ROUTED_SERVICE - rename - execute as execute_router - end - - WSF_FILTERED_SERVICE - - WSF_DEFAULT_SERVICE + WSF_DEFAULT_SERVICE [APPLICATION_EXECUTION] redefine initialize end - WSF_FILTER - rename - execute as execute_router - end create make_and_launch feature {NONE} -- Initialization --- tt --- local --- lst: ARRAYED_LIST [READABLE_STRING_GENERAL] --- do --- create lst.make (3) --- lst.compare_objects --- lst.extend ({STRING_32} "abc") --- if lst.has ("abc") then --- print ("found%N") --- end --- end - initialize -- Initialize current service. do --- tt - initialize_router - initialize_filter Precursor set_service_option ("port", 9090) end -feature -- Router and Filter - - create_filter - -- Create `filter' - local - f, l_filter: detachable WSF_FILTER - do - l_filter := Void - - -- Maintenance - create {WSF_MAINTENANCE_FILTER} f - f.set_next (l_filter) - l_filter := f - - -- Logging - create {WSF_LOGGING_FILTER} f - f.set_next (l_filter) - l_filter := f - filter := l_filter - end - - setup_filter - -- Setup `filter' - local - f: WSF_FILTER - do - from - f := filter - until - not attached f.next as l_next - loop - f := l_next - end - f.set_next (Current) - end - - setup_router - do - map_agent_uri ("/", agent execute_hello, Void) - map_agent_uri ("/grid", agent grid_demo, Void) - map_agent_uri ("/repeater", agent repeater_demo, Void) - map_agent_uri ("/slider", agent slider_demo, Void) - map_agent_uri ("/upload", agent upload_demo, Void) - map_agent_uri ("/codeview", agent codeview, Void) - - -- NOTE: you could put all those files in a specific folder, and use WSF_FILE_SYSTEM_HANDLER with "/" - -- this way, it handles the caching and so on - router.handle_with_request_methods ("/assets", create {WSF_FILE_SYSTEM_HANDLER}.make_hidden ("assets"), router.methods_GET) - end - -feature -- Helper: mapping - - map_agent_uri (a_uri: READABLE_STRING_8; a_action: like {WSF_URI_AGENT_HANDLER}.action; rqst_methods: detachable WSF_REQUEST_METHODS) - do - router.map_with_request_methods (create {WSF_URI_MAPPING}.make (a_uri, create {WSF_URI_AGENT_HANDLER}.make (a_action)), rqst_methods) - end - -feature -- Execution - - execute_hello (request: WSF_REQUEST; response: WSF_RESPONSE) - local - page: SAMPLE_PAGE - do - -- To send a response we need to setup, the status code and - -- the response headers. - create page.make (request, response) - page.execute - end - - grid_demo (request: WSF_REQUEST; response: WSF_RESPONSE) - local - page: GRID_PAGE - do - -- To send a response we need to setup, the status code and - -- the response headers. - create page.make (request, response) - page.execute - end - - repeater_demo (request: WSF_REQUEST; response: WSF_RESPONSE) - local - page: REPEATER_PAGE - do - -- To send a response we need to setup, the status code and - -- the response headers. - create page.make (request, response) - page.execute - end - - slider_demo (request: WSF_REQUEST; response: WSF_RESPONSE) - local - page: SLIDER_PAGE - do - -- To send a response we need to setup, the status code and - -- the response headers. - create page.make (request, response) - page.execute - end - - upload_demo (request: WSF_REQUEST; response: WSF_RESPONSE) - local - page: UPLOAD_PAGE - do - -- To send a response we need to setup, the status code and - -- the response headers. - create page.make (request, response) - page.execute - end - - codeview (request: WSF_REQUEST; response: WSF_RESPONSE) - local - page: CODEVIEW_PAGE - do - -- To send a response we need to setup, the status code and - -- the response headers. - create page.make (request, response) - page.execute - end - - end diff --git a/draft/library/server/wsf_js_widget/examples/demo/application_execution.e b/draft/library/server/wsf_js_widget/examples/demo/application_execution.e new file mode 100644 index 00000000..b0582128 --- /dev/null +++ b/draft/library/server/wsf_js_widget/examples/demo/application_execution.e @@ -0,0 +1,114 @@ +note + description: "Summary description for {APPLICATION_EXECUTION}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + APPLICATION_EXECUTION + +inherit + WSF_FILTERED_ROUTED_EXECUTION + +create + make + +feature -- Router and Filter + + create_filter + -- Create `filter' + do + -- Maintenance + create {WSF_MAINTENANCE_FILTER} filter + end + + setup_filter + -- Setup `filter' + do + append_filters (<>) + end + + setup_router + do + map_agent_uri ("/", agent execute_hello, Void) + map_agent_uri ("/grid", agent grid_demo, Void) + map_agent_uri ("/repeater", agent repeater_demo, Void) + map_agent_uri ("/slider", agent slider_demo, Void) + map_agent_uri ("/upload", agent upload_demo, Void) + map_agent_uri ("/codeview", agent codeview, Void) + + -- NOTE: you could put all those files in a specific folder, and use WSF_FILE_SYSTEM_HANDLER with "/" + -- this way, it handles the caching and so on + router.handle_with_request_methods ("/assets", create {WSF_FILE_SYSTEM_HANDLER}.make_hidden ("assets"), router.methods_GET) + end + +feature -- Helper: mapping + + map_agent_uri (a_uri: READABLE_STRING_8; a_action: like {WSF_URI_AGENT_HANDLER}.action; rqst_methods: detachable WSF_REQUEST_METHODS) + do + router.map_with_request_methods (create {WSF_URI_MAPPING}.make (a_uri, create {WSF_URI_AGENT_HANDLER}.make (a_action)), rqst_methods) + end + +feature -- Execution + + execute_hello (req: WSF_REQUEST; res: WSF_RESPONSE) + local + page: SAMPLE_PAGE + do + -- To send a response we need to setup, the status code and + -- the response headers. + create page.make (req, res) + page.execute + end + + grid_demo (req: WSF_REQUEST; res: WSF_RESPONSE) + local + page: GRID_PAGE + do + -- To send a response we need to setup, the status code and + -- the response headers. + create page.make (req, res) + page.execute + end + + repeater_demo (req: WSF_REQUEST; res: WSF_RESPONSE) + local + page: REPEATER_PAGE + do + -- To send a response we need to setup, the status code and + -- the response headers. + create page.make (req, res) + page.execute + end + + slider_demo (req: WSF_REQUEST; res: WSF_RESPONSE) + local + page: SLIDER_PAGE + do + -- To send a response we need to setup, the status code and + -- the response headers. + create page.make (req, res) + page.execute + end + + upload_demo (req: WSF_REQUEST; res: WSF_RESPONSE) + local + page: UPLOAD_PAGE + do + -- To send a response we need to setup, the status code and + -- the response headers. + create page.make (req, res) + page.execute + end + + codeview (req: WSF_REQUEST; res: WSF_RESPONSE) + local + page: CODEVIEW_PAGE + do + -- To send a response we need to setup, the status code and + -- the response headers. + create page.make (req, res) + page.execute + end + +end diff --git a/examples/debug/debug.ecf b/examples/debug/debug.ecf index 26bf2100..642cd4cc 100644 --- a/examples/debug/debug.ecf +++ b/examples/debug/debug.ecf @@ -20,15 +20,15 @@ - + - + - + diff --git a/examples/debug/launcher/any/application_launcher_i.e b/examples/debug/launcher/any/application_launcher_i.e index 22f94cab..9e062274 100644 --- a/examples/debug/launcher/any/application_launcher_i.e +++ b/examples/debug/launcher/any/application_launcher_i.e @@ -22,8 +22,8 @@ feature -- Execution nature: like launcher_nature do nature := launcher_nature - if nature = Void or else nature = nature_httpd then - launch_httpd (opts) + if nature = Void or else nature = nature_standalone then + launch_standalone (opts) elseif nature = nature_nino then launch_nino (opts) elseif nature = nature_cgi then @@ -52,8 +52,8 @@ feature {NONE} -- Access ext := l_entry.extension end if ext /= Void then - if ext.same_string (nature_httpd) then - Result := nature_httpd + if ext.same_string (nature_standalone) then + Result := nature_standalone end if ext.same_string (nature_nino) then Result := nature_nino @@ -65,16 +65,16 @@ feature {NONE} -- Access Result := nature_libfcgi end end - Result := nature_httpd + Result := nature_standalone end feature {NONE} -- nino - nature_httpd: STRING = "httpd" + nature_standalone: STRING = "standalone" - launch_httpd (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS) + launch_standalone (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS) local - launcher: WSF_HTTPD_SERVICE_LAUNCHER [G] + launcher: WSF_STANDALONE_SERVICE_LAUNCHER [G] do create launcher.make_and_launch (opts) end diff --git a/examples/desktop_app/desktop_app.ecf b/examples/desktop_app/desktop_app.ecf index 78fd6e17..81a0aa50 100644 --- a/examples/desktop_app/desktop_app.ecf +++ b/examples/desktop_app/desktop_app.ecf @@ -7,17 +7,16 @@ - - + - - - + + + /EIFGENs$ /CVS$ diff --git a/examples/desktop_app/src/app_embedded_web_execution.e b/examples/desktop_app/src/app_embedded_web_execution.e new file mode 100644 index 00000000..815e35a6 --- /dev/null +++ b/examples/desktop_app/src/app_embedded_web_execution.e @@ -0,0 +1,239 @@ +note + description: "Summary description for {APP_EMBEDDED_WEB_EXECUTION}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + APP_EMBEDDED_WEB_EXECUTION + +inherit + EMBEDDED_WEB_EXECUTION + redefine + initialize + end + +create + make + +feature {NONE} -- Initialization + + initialize + do + Precursor + create request_exit_operation_actions + local_connection_restriction_enabled := True + end + +feature -- Execution + + request_exit_operation_actions: ACTION_SEQUENCE [TUPLE] + + execute + -- Execute the request + -- See `request.input' for input stream + -- `request.meta_variables' for the CGI meta variable + -- and `response' for output buffer + local + router: WSF_ROUTER + sess: detachable WSF_ROUTER_SESSION + m: WSF_HTML_PAGE_RESPONSE + b: STRING + fs: WSF_FILE_SYSTEM_HANDLER + req: like request + do + req := request + + create router.make (3) + router.handle ("/test/{var}", create {WSF_URI_TEMPLATE_AGENT_HANDLER}.make (agent handle_test)) + router.handle ("/env", create {WSF_URI_AGENT_HANDLER}.make (agent handle_env)) + router.handle ("/exit", create {WSF_URI_TEMPLATE_AGENT_HANDLER}.make (agent handle_exit)) + create fs.make_with_path ((create {EXECUTION_ENVIRONMENT}).current_working_path.extended ("files")) + router.handle ("/files", fs) + create sess + router.dispatch (req, response, sess) + if not sess.dispatched then + create m.make + create b.make_from_string ("

Hello Eiffel desktop user

") + b.append ("
  • test
  • ") + b.append ("
  • env
  • ") + b.append ("
  • files
  • ") + b.append ("
  • exit
  • ") + m.set_body (b) + response.send (m) + end + end + + handle_test (req: WSF_REQUEST; res: WSF_RESPONSE) + local + m: WSF_HTML_PAGE_RESPONSE + b: STRING + l_name: READABLE_STRING_32 + do + if attached {WSF_STRING} req.item ("var") as p_name then + l_name := p_name.value + else + l_name := {STRING_32} "Embedded web service and web_browser in vision2 application" + end + create m.make + create b.make_from_string ("

    This is a test about "+ m.html_encoded_string (l_name) +"

    ") + b.append ("
  • back to home
  • ") + if l_name.is_case_insensitive_equal_general ("start") then + b.append ("
  • test javascript+ajax
  • ") + elseif l_name.is_case_insensitive_equal_general ("js") then + b.append ("[ +

    Let AJAX change this text

    + +
    + ]") + m.add_javascript_content ("[ + function loadXMLDoc() + { + var xmlhttp; + if (window.XMLHttpRequest) + {// code for IE7+, Firefox, Chrome, Opera, Safari + xmlhttp=new XMLHttpRequest(); + } + else + {// code for IE6, IE5 + xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); + } + xmlhttp.onreadystatechange=function() + { + if (xmlhttp.readyState==4 && xmlhttp.status==200) + { + document.getElementById("myDiv").innerHTML=xmlhttp.responseText; + } + } + xmlhttp.open("GET","/test/ajax.txt",true); + xmlhttp.send(); + } + ]") + elseif l_name.is_case_insensitive_equal_general ("ajax.txt") then + b := "This is AJAX response ... from " + req.absolute_script_url ("") + end + m.set_body (b) + res.send (m) + end + + handle_env (req: WSF_REQUEST; res: WSF_RESPONSE) + local + s: STRING_8 + p: WSF_PAGE_RESPONSE + v: STRING_8 + do + create s.make (2048) + s.append ("**DEBUG**%N") + req.set_raw_input_data_recorded (True) + + append_iterable_to ("Meta variables:", req.meta_variables, s) + s.append_character ('%N') + + append_iterable_to ("Path parameters", req.path_parameters, s) + s.append_character ('%N') + + append_iterable_to ("Query parameters", req.query_parameters, s) + s.append_character ('%N') + + append_iterable_to ("Form parameters", req.form_parameters, s) + s.append_character ('%N') + + if attached req.content_type as l_type then + s.append ("Content: type=" + l_type.debug_output) + s.append (" length=") + s.append_natural_64 (req.content_length_value) + s.append_character ('%N') + create v.make (req.content_length_value.to_integer_32) + req.read_input_data_into (v) + across + v.split ('%N') as v_cursor + loop + s.append (" |") + s.append (v_cursor.item) + s.append_character ('%N') + end + end + + create p.make_with_body (s) + p.header.put_content_type_text_plain + res.send (p) + end + + handle_exit (req: WSF_REQUEST; res: WSF_RESPONSE) + local + m: WSF_HTML_PAGE_RESPONSE + b: STRING + do + create m.make + create b.make_from_string ("

    Embedded server is about to shutdown

    ") + b.append ("
  • back to home
  • ") + b.append ("
  • Click to confirm exit operation
  • ") + m.set_body (b) + res.send (m) + if attached {separate WGI_STANDALONE_CONNECTOR [WGI_EXECUTION]} req.wgi_connector as conn then + shutdown_server (conn) + end + request_exit_operation_actions.call (Void) + end + + shutdown_server (conn: separate WGI_STANDALONE_CONNECTOR [WGI_EXECUTION]) + do + conn.shutdown_server + end + +feature {NONE} -- Implementation + + append_iterable_to (a_title: READABLE_STRING_8; it: detachable ITERABLE [WSF_VALUE]; s: STRING_8) + local + n: INTEGER + t: READABLE_STRING_8 + v: READABLE_STRING_8 + do + s.append (a_title) + s.append_character (':') + if it /= Void then + across it as c loop + n := n + 1 + end + if n = 0 then + s.append (" empty") + s.append_character ('%N') + else + s.append_character ('%N') + across + it as c + loop + s.append (" - ") + s.append (c.item.url_encoded_name) + t := c.item.generating_type + if t.same_string ("WSF_STRING") then + else + s.append_character (' ') + s.append_character ('{') + s.append (t) + s.append_character ('}') + end + s.append_character ('=') + v := c.item.string_representation.as_string_8 + if v.has ('%N') then + s.append_character ('%N') + across + v.split ('%N') as v_cursor + loop + s.append (" |") + s.append (v_cursor.item) + s.append_character ('%N') + end + else + s.append (v) + s.append_character ('%N') + end + end + end + else + s.append (" none") + s.append_character ('%N') + end + end + +end diff --git a/examples/desktop_app/src/app_embedded_web_service.e b/examples/desktop_app/src/app_embedded_web_service.e index e9ebed88..ed11c24d 100644 --- a/examples/desktop_app/src/app_embedded_web_service.e +++ b/examples/desktop_app/src/app_embedded_web_service.e @@ -8,223 +8,11 @@ class APP_EMBEDDED_WEB_SERVICE inherit - EMBEDDED_WEB_SERVICE - redefine - make - end + EMBEDDED_WEB_SERVICE [APP_EMBEDDED_WEB_EXECUTION] create make feature {NONE} -- Initialization - make - do - Precursor - create request_exit_operation_actions - local_connection_restriction_enabled := True - end - -feature -- Execution - - request_exit_operation_actions: ACTION_SEQUENCE [TUPLE] - - execute (req: WSF_REQUEST; res: WSF_RESPONSE) - -- Execute the request - -- See `req.input' for input stream - -- `req.meta_variables' for the CGI meta variable - -- and `res' for output buffer - local - router: WSF_ROUTER - sess: detachable WSF_ROUTER_SESSION - m: WSF_HTML_PAGE_RESPONSE - b: STRING - fs: WSF_FILE_SYSTEM_HANDLER - do - create router.make (3) - router.handle ("/test/{var}", create {WSF_URI_TEMPLATE_AGENT_HANDLER}.make (agent handle_test)) - router.handle ("/env", create {WSF_URI_AGENT_HANDLER}.make (agent handle_env)) - router.handle ("/exit", create {WSF_URI_TEMPLATE_AGENT_HANDLER}.make (agent handle_exit)) - create fs.make_with_path ((create {EXECUTION_ENVIRONMENT}).current_working_path.extended ("files")) - router.handle ("/files", fs) - create sess - router.dispatch (req, res, sess) - if not sess.dispatched then - create m.make - create b.make_from_string ("

    Hello Eiffel desktop user

    ") - b.append ("
  • test
  • ") - b.append ("
  • env
  • ") - b.append ("
  • files
  • ") - b.append ("
  • exit
  • ") - m.set_body (b) - res.send (m) - end - end - - handle_test (req: WSF_REQUEST; res: WSF_RESPONSE) - local - m: WSF_HTML_PAGE_RESPONSE - b: STRING - l_name: READABLE_STRING_32 - do - if attached {WSF_STRING} req.item ("var") as p_name then - l_name := p_name.value - else - l_name := {STRING_32} "Embedded web service and web_browser in vision2 application" - end - create m.make - create b.make_from_string ("

    This is a test about "+ m.html_encoded_string (l_name) +"

    ") - b.append ("
  • back to home
  • ") - if l_name.is_case_insensitive_equal_general ("start") then - b.append ("
  • test javascript+ajax
  • ") - elseif l_name.is_case_insensitive_equal_general ("js") then - b.append ("[ -

    Let AJAX change this text

    - -
    - ]") - m.add_javascript_content ("[ - function loadXMLDoc() - { - var xmlhttp; - if (window.XMLHttpRequest) - {// code for IE7+, Firefox, Chrome, Opera, Safari - xmlhttp=new XMLHttpRequest(); - } - else - {// code for IE6, IE5 - xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); - } - xmlhttp.onreadystatechange=function() - { - if (xmlhttp.readyState==4 && xmlhttp.status==200) - { - document.getElementById("myDiv").innerHTML=xmlhttp.responseText; - } - } - xmlhttp.open("GET","/test/ajax.txt",true); - xmlhttp.send(); - } - ]") - elseif l_name.is_case_insensitive_equal_general ("ajax.txt") then - b := "This is AJAX response ... from " + req.absolute_script_url ("") - end - m.set_body (b) - res.send (m) - end - - handle_env (req: WSF_REQUEST; res: WSF_RESPONSE) - local - s: STRING_8 - p: WSF_PAGE_RESPONSE - v: STRING_8 - do - create s.make (2048) - s.append ("**DEBUG**%N") - req.set_raw_input_data_recorded (True) - - append_iterable_to ("Meta variables:", req.meta_variables, s) - s.append_character ('%N') - - append_iterable_to ("Path parameters", req.path_parameters, s) - s.append_character ('%N') - - append_iterable_to ("Query parameters", req.query_parameters, s) - s.append_character ('%N') - - append_iterable_to ("Form parameters", req.form_parameters, s) - s.append_character ('%N') - - if attached req.content_type as l_type then - s.append ("Content: type=" + l_type.debug_output) - s.append (" length=") - s.append_natural_64 (req.content_length_value) - s.append_character ('%N') - create v.make (req.content_length_value.to_integer_32) - req.read_input_data_into (v) - across - v.split ('%N') as v_cursor - loop - s.append (" |") - s.append (v_cursor.item) - s.append_character ('%N') - end - end - - create p.make_with_body (s) - p.header.put_content_type_text_plain - res.send (p) - end - - handle_exit (req: WSF_REQUEST; res: WSF_RESPONSE) - local - m: WSF_HTML_PAGE_RESPONSE - b: STRING - do - create m.make - create b.make_from_string ("

    Embedded server is about to shutdown

    ") - b.append ("
  • back to home
  • ") - m.set_body (b) - res.send (m) - if attached {WGI_NINO_CONNECTOR} req.wgi_connector as nino then - nino.server.shutdown_server - end - request_exit_operation_actions.call (Void) - end - -feature {NONE} -- Implementation - - append_iterable_to (a_title: READABLE_STRING_8; it: detachable ITERABLE [WSF_VALUE]; s: STRING_8) - local - n: INTEGER - t: READABLE_STRING_8 - v: READABLE_STRING_8 - do - s.append (a_title) - s.append_character (':') - if it /= Void then - across it as c loop - n := n + 1 - end - if n = 0 then - s.append (" empty") - s.append_character ('%N') - else - s.append_character ('%N') - across - it as c - loop - s.append (" - ") - s.append (c.item.url_encoded_name) - t := c.item.generating_type - if t.same_string ("WSF_STRING") then - else - s.append_character (' ') - s.append_character ('{') - s.append (t) - s.append_character ('}') - end - s.append_character ('=') - v := c.item.string_representation.as_string_8 - if v.has ('%N') then - s.append_character ('%N') - across - v.split ('%N') as v_cursor - loop - s.append (" |") - s.append (v_cursor.item) - s.append_character ('%N') - end - else - s.append (v) - s.append_character ('%N') - end - end - end - else - s.append (" none") - s.append_character ('%N') - end - end - end diff --git a/examples/desktop_app/src/desktop_app.e b/examples/desktop_app/src/desktop_app.e index 85aaf27c..a48779f0 100644 --- a/examples/desktop_app/src/desktop_app.e +++ b/examples/desktop_app/src/desktop_app.e @@ -24,18 +24,17 @@ feature {NONE} -- Initialization -- then launch the application. local l_win: like main_window - l_embeded_services: APP_EMBEDDED_WEB_SERVICE + l_embedded_service: APP_EMBEDDED_WEB_SERVICE do default_create create l_win.make main_window := l_win l_win.show - create l_embeded_services.make - l_embeded_services.set_port_number (0) -- Use first available port number + create l_embedded_service.make + l_embedded_service.set_port_number (0) -- Use first available port number - l_embeded_services.on_launched_actions.force (agent on_web_service_launched (l_win)) - l_embeded_services.request_exit_operation_actions.force (agent on_quit) - l_embeded_services.launch + l_embedded_service.on_launched_actions.force (agent on_web_service_launched (l_win, l_embedded_service)) + l_embedded_service.launch launch end @@ -46,11 +45,44 @@ feature {NONE} -- Initialization end end - on_web_service_launched (a_win: attached like main_window) + on_web_service_launched (a_win: attached like main_window; s: APP_EMBEDDED_WEB_SERVICE) do + add_idle_action_kamikaze (agent wait_for_termination (s, Void)) add_idle_action_kamikaze (agent a_win.open_link) end + wait_for_termination (s: APP_EMBEDDED_WEB_SERVICE; a_timeout: detachable EV_TIMEOUT) + local + t: detachable EV_TIMEOUT + do + t := a_timeout + if t /= Void then + t.set_interval (0) + end + if + attached s.observer as obs and then + observer_has_terminaded (obs) + then + if t /= Void then + t.destroy + end + on_quit + else + if t = Void then + create t + t.actions.extend (agent wait_for_termination (s, t)) + else + t.set_interval (1_000) + end + t.set_interval (1_000) + end + end + + observer_has_terminaded (obs: separate WGI_STANDALONE_SERVER_OBSERVER): BOOLEAN + do + Result := obs.terminated + end + feature {NONE} -- Implementation main_window: detachable MAIN_WINDOW diff --git a/examples/desktop_app/src/service/embedded_web_execution.e b/examples/desktop_app/src/service/embedded_web_execution.e new file mode 100644 index 00000000..9ece6bdc --- /dev/null +++ b/examples/desktop_app/src/service/embedded_web_execution.e @@ -0,0 +1,63 @@ +note + description: "Summary description for {EMBEDDED_WEB_EXECUTION}." + author: "" + date: "$Date$" + revision: "$Revision$" + +deferred class + EMBEDDED_WEB_EXECUTION + +inherit + WSF_EXECUTION + rename + execute as execute_embedded + end + + SHARED_EMBEDED_WEB_SERVICE_INFORMATION + +feature {NONE} -- Execution + + execute_embedded + -- Execute the request + -- See `request.input' for input stream + -- `request.meta_variables' for the CGI meta variable + -- and `response' for output buffer + local + filter: WSF_AGENT_FILTER + m: WSF_PAGE_RESPONSE + do + if local_connection_restriction_enabled then + if + attached request.remote_addr as l_remote_addr and then + l_remote_addr.is_case_insensitive_equal_general ("127.0.0.1") + then + execute + else + create m.make_with_body ("Only local connection is allowed") + m.set_status_code (403) -- Forbidden + response.send (m) + end + else + execute + end + end + + execute + deferred + end + +feature -- Status report + + local_connection_restriction_enabled: BOOLEAN + -- Accept only local connection? + --| based on 127.0.0.1 IP + --| TO IMPROVE + +feature -- Change + + set_local_connection_restriction_enabled (b: BOOLEAN) + do + local_connection_restriction_enabled := b + end + +end diff --git a/examples/desktop_app/src/service/embedded_web_service.e b/examples/desktop_app/src/service/embedded_web_service.e index 995f2393..7b3adc88 100644 --- a/examples/desktop_app/src/service/embedded_web_service.e +++ b/examples/desktop_app/src/service/embedded_web_service.e @@ -5,19 +5,10 @@ note revision: "$Revision$" deferred class - EMBEDDED_WEB_SERVICE + EMBEDDED_WEB_SERVICE [G -> EMBEDDED_WEB_EXECUTION create make end] inherit - THREAD - rename - make as make_thread, - execute as execute_thread - end - WSF_SERVICE - rename - execute as execute_embedded - end SHARED_EMBEDED_WEB_SERVICE_INFORMATION @@ -25,90 +16,35 @@ feature -- Initialization make do - make_thread create on_launched_actions end -feature {NONE} -- Execution +feature -- Execution - execute_embedded (req: WSF_REQUEST; res: WSF_RESPONSE) - -- Execute the request - -- See `req.input' for input stream - -- `req.meta_variables' for the CGI meta variable - -- and `res' for output buffer + launch local - filter: WSF_AGENT_FILTER - m: WSF_PAGE_RESPONSE - do - if local_connection_restriction_enabled then - if - attached req.remote_addr as l_remote_addr and then - l_remote_addr.is_case_insensitive_equal_general ("127.0.0.1") - then - execute (req, res) - else - create m.make_with_body ("Only local connection is allowed") - m.set_status_code (403) -- Forbidden - res.send (m) - end - else - execute (req, res) - end - end - - execute_thread - local - nino: WSF_NINO_SERVICE_LAUNCHER + launcher: WSF_STANDALONE_SERVICE_LAUNCHER [G] opts: WSF_SERVICE_LAUNCHER_OPTIONS do create opts.default_create opts.set_verbose (True) opts.set_option ("port", port_number) - create nino.make (Current, opts) - nino.on_launched_actions.force (agent on_launched) - nino.launch + create launcher.make (opts) + observer := launcher.connector.observer + launcher.on_launched_actions.force (agent on_launched) + launcher.launch end - execute (req: WSF_REQUEST; res: WSF_RESPONSE) - -- Execute the request - -- See `req.input' for input stream - -- `req.meta_variables' for the CGI meta variable - -- and `res' for output buffer - deferred - end + observer: detachable separate WGI_STANDALONE_SERVER_OBSERVER - on_launched (conn: WGI_CONNECTOR) + on_launched (conn: WGI_STANDALONE_CONNECTOR [G]) do - if attached {WGI_NINO_CONNECTOR} conn as nino then - set_port_number (nino.port) - end + set_port_number (conn.port) on_launched_actions.call (Void) end -feature -- Control - - wait - -- Wait for server to be terminated. - do - join - end - feature -- Access on_launched_actions: ACTION_SEQUENCE [TUPLE] -feature -- Status report - - local_connection_restriction_enabled: BOOLEAN - -- Accept only local connection? - --| based on 127.0.0.1 IP - --| TO IMPROVE - -feature -- Change - - set_local_connection_restriction_enabled (b: BOOLEAN) - do - local_connection_restriction_enabled := b - end - end diff --git a/examples/desktop_app/src/service/shared_embeded_web_service_information.e b/examples/desktop_app/src/service/shared_embeded_web_service_information.e index ba04e855..353f21d5 100644 --- a/examples/desktop_app/src/service/shared_embeded_web_service_information.e +++ b/examples/desktop_app/src/service/shared_embeded_web_service_information.e @@ -11,15 +11,25 @@ feature -- Access port_number: INTEGER do - Result := port_number_cell.item + Result := separate_port_number (port_number_cell) end set_port_number (a_port: like port_number) do - port_number_cell.replace (a_port) + separate_set_port_number (port_number_cell, a_port) end - port_number_cell: CELL [INTEGER] + separate_port_number (cl: like port_number_cell): like port_number + do + Result := cl.item + end + + separate_set_port_number (cl: like port_number_cell; a_port: like port_number) + do + cl.replace (a_port) + end + + port_number_cell: separate CELL [INTEGER] once ("process") create Result.put (0) end diff --git a/examples/filter/filter-safe.ecf b/examples/filter/filter-safe.ecf index 537594cf..6d85dcd0 100644 --- a/examples/filter/filter-safe.ecf +++ b/examples/filter/filter-safe.ecf @@ -1,30 +1,36 @@ - + /EIFGENs$ /\.git$ /\.svn$ - - - - - - - + + + + + + + + + + + + diff --git a/examples/filter/src/database/database_api.e b/examples/filter/src/database/database_api.e index 4c0024c0..669ef656 100644 --- a/examples/filter/src/database/database_api.e +++ b/examples/filter/src/database/database_api.e @@ -24,6 +24,24 @@ feature -- Initialization feature -- Access + user_by_id (a_id: INTEGER): detachable USER + do + Result := users.item (a_id) + end + + user_by_name (a_name: READABLE_STRING_GENERAL): detachable USER + do + across + users as c + until + Result /= Void + loop + if attached c.item as u and then a_name.same_string (u.name) then + Result := u + end + end + end + user (a_id: INTEGER; a_name: detachable READABLE_STRING_GENERAL): detachable USER -- User with id `a_id' or name `a_name'. require @@ -32,18 +50,9 @@ feature -- Access n: like {USER}.name do if a_id > 0 then - Result := users.item (a_id) + Result := user_by_id (a_id) elseif a_name /= Void then - n := a_name.as_string_8 - across - users as c - until - Result /= Void - loop - if attached c.item as u and then u.name.same_string (n) then - Result := u - end - end + Result := user_by_name (a_name) end ensure Result /= Void implies ((a_id > 0 and then Result.id = a_id) xor (a_name /= Void and then Result.name.same_string_general (a_name))) @@ -52,6 +61,6 @@ feature -- Access users: HASH_TABLE [USER, INTEGER] ;note - copyright: "2011-2012, Olivier Ligot, Jocelyn Fiat and others" + copyright: "2011-2015, Olivier Ligot, Jocelyn Fiat and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" end diff --git a/examples/filter/src/filter/authentication_filter.e b/examples/filter/src/filter/authentication_filter.e index c3bf8ae3..072c8aec 100644 --- a/examples/filter/src/filter/authentication_filter.e +++ b/examples/filter/src/filter/authentication_filter.e @@ -48,18 +48,31 @@ feature {NONE} -- Implementation -- Handle forbidden. local h: HTTP_HEADER + s: STRING do create h.make h.put_content_type_text_plain h.put_content_length (a_description.count) h.put_current_date - h.put_header_key_value ({HTTP_HEADER_NAMES}.header_www_authenticate, "Basic realm=%"User%"") + s := "Basic realm=%"For this demo, use any of: " + across + db_access.users as ic + loop + s.append_character ('(') + s.append (ic.item.name) + s.append_character (':') + s.append (ic.item.password) + s.append_character (')') + s.append_character (' ') + end + s.append_character ('"') + h.put_header_key_value ({HTTP_HEADER_NAMES}.header_www_authenticate, s) res.set_status_code ({HTTP_STATUS_CODE}.unauthorized) res.put_header_text (h.string) res.put_string (a_description) end note - copyright: "2011-2014, Olivier Ligot, Jocelyn Fiat and others" + copyright: "2011-2015, Olivier Ligot, Jocelyn Fiat and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" end diff --git a/examples/filter/src/filter_server.e b/examples/filter/src/filter_server.e index dfc9f8fe..2ad4442a 100644 --- a/examples/filter/src/filter_server.e +++ b/examples/filter/src/filter_server.e @@ -8,18 +8,7 @@ class FILTER_SERVER inherit - ANY - - WSF_DEFAULT_SERVICE - - WSF_ROUTED_SERVICE - undefine - execute - end - - WSF_FILTERED_SERVICE - - SHARED_EJSON + WSF_DEFAULT_SERVICE [FILTER_SERVER_EXECUTION] create make @@ -31,9 +20,6 @@ feature {NONE} -- Initialization l_message: STRING l_factory: INET_ADDRESS_FACTORY do - initialize_router - initialize_filter - initialize_json set_service_option ("port", port) create l_message.make_empty l_message.append_string ("Launching filter server at ") @@ -46,60 +32,13 @@ feature {NONE} -- Initialization make_and_launch end - create_filter - -- Create `filter' - do - create {WSF_CORS_FILTER} filter - end - - setup_filter - -- Setup `filter' - local - l_routing_filter: WSF_ROUTING_FILTER - l_logging_filter: WSF_LOGGING_FILTER - do - create l_routing_filter.make (router) - l_routing_filter.set_execute_default_action (agent execute_default) - filter.set_next (l_routing_filter) - - create l_logging_filter - l_routing_filter.set_next (l_logging_filter) - end - - setup_router - -- Setup `router' - local - l_options_filter: WSF_CORS_OPTIONS_FILTER - l_authentication_filter: AUTHENTICATION_FILTER - l_user_filter: USER_HANDLER - l_methods: WSF_REQUEST_METHODS - do - create l_options_filter.make (router) - create l_authentication_filter - create l_user_filter - - l_options_filter.set_next (l_authentication_filter) - l_authentication_filter.set_next (l_user_filter) - - create l_methods - l_methods.enable_options - l_methods.enable_get - router.handle_with_request_methods ("/user/{userid}", create {WSF_URI_TEMPLATE_AGENT_HANDLER}.make (agent l_options_filter.execute), l_methods) - end - - initialize_json - -- Initialize `json'. - do - json.add_converter (create {JSON_USER_CONVERTER}.make) - end - feature {NONE} -- Implementation port: INTEGER = 9090 -- Port number note - copyright: "2011-2014, Olivier Ligot, Jocelyn Fiat and others" + copyright: "2011-2015, Olivier Ligot, Jocelyn Fiat and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/examples/filter/src/filter_server_execution.e b/examples/filter/src/filter_server_execution.e new file mode 100644 index 00000000..21727ede --- /dev/null +++ b/examples/filter/src/filter_server_execution.e @@ -0,0 +1,82 @@ +note + description : "Filter example." + author : "Olivier Ligot" + date : "$Date$" + revision : "$Revision$" + +class + FILTER_SERVER_EXECUTION + +inherit + WSF_FILTERED_ROUTED_EXECUTION + redefine + initialize + end + + SHARED_EJSON + +create + make + +feature {NONE} -- Initialization + + initialize + do + Precursor + initialize_json + end + + create_filter + -- Create `filter' + do + create {WSF_CORS_FILTER} filter + end + + setup_filter + -- Setup `filter' + local + l_logging_filter: WSF_LOGGING_FILTER + do + create l_logging_filter + filter.set_next (l_logging_filter) + end + + setup_router + -- Setup `router' + local + l_options_filter: WSF_CORS_OPTIONS_FILTER + l_authentication_filter: AUTHENTICATION_FILTER + l_user_filter: USER_HANDLER + l_methods: WSF_REQUEST_METHODS + do + create l_options_filter.make (router) + create l_authentication_filter + create l_user_filter + + l_options_filter.set_next (l_authentication_filter) + l_authentication_filter.set_next (l_user_filter) + + create l_methods + l_methods.enable_options + l_methods.enable_get + router.handle_with_request_methods ("/user/{userid}", create {WSF_URI_TEMPLATE_AGENT_HANDLER}.make (agent l_options_filter.execute), l_methods) + end + + initialize_json + -- Initialize `json'. + once + -- See SHARED_EJSON, and the once function per thread `json'. + json.add_converter (create {JSON_USER_CONVERTER}.make) + end + +note + copyright: "2011-2015, Olivier Ligot, Jocelyn Fiat 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 + ]" +end diff --git a/examples/filter/src/resource/user_handler.e b/examples/filter/src/resource/user_handler.e index 722ccd03..efcb6698 100644 --- a/examples/filter/src/resource/user_handler.e +++ b/examples/filter/src/resource/user_handler.e @@ -41,7 +41,7 @@ feature -- Basic operations local id : STRING do - if attached req.orig_path_info as orig_path then + if attached req.path_info as orig_path then id := get_user_id_from_path (orig_path) if attached retrieve_user (id) as l_user then if l_user ~ req.execution_variable ("user") then @@ -86,12 +86,14 @@ feature {NONE} -- Implementation retrieve_user (id: STRING) : detachable USER -- Retrieve the user by id if it exist, in other case, Void do - if id.is_integer and then Db_access.users.has (id.to_integer) then - Result := db_access.users.item (id.to_integer) + if id.is_integer then + Result := db_access.user_by_id (id.to_integer) + else + Result := db_access.user_by_name (id) end end note - copyright: "2011-2013, Olivier Ligot, Jocelyn Fiat and others" + copyright: "2011-2015, Olivier Ligot, Jocelyn Fiat and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" end diff --git a/examples/restbucksCRUD/src/restbucks_server.e b/examples/restbucksCRUD/src/restbucks_server.e index 588b2057..68b2e4c4 100644 --- a/examples/restbucksCRUD/src/restbucks_server.e +++ b/examples/restbucksCRUD/src/restbucks_server.e @@ -6,19 +6,7 @@ note class RESTBUCKS_SERVER inherit - - WSF_ROUTED_SKELETON_SERVICE - undefine - requires_proxy - end - - WSF_URI_TEMPLATE_HELPER_FOR_ROUTED_SERVICE - - WSF_HANDLER_HELPER - - WSF_DEFAULT_SERVICE - - WSF_NO_PROXY_POLICY + WSF_DEFAULT_SERVICE [RESTBUCKS_SERVER_EXECUTION] create make @@ -27,26 +15,12 @@ feature {NONE} -- Initialization make do - initialize_router set_service_option ("port", 9090) make_and_launch end - setup_router - local - order_handler: ORDER_HANDLER - doc: WSF_ROUTER_SELF_DOCUMENTATION_HANDLER - do - create order_handler.make_with_router (router) - router.handle_with_request_methods ("/order", order_handler, router.methods_POST) - router.handle_with_request_methods ("/order/{orderid}", order_handler, router.methods_GET + router.methods_DELETE + router.methods_PUT) - create doc.make_hidden (router) - router.handle_with_request_methods ("/api/doc", doc, router.methods_GET) - end - - note - copyright: "2011-2013, Javier Velilla and others" + copyright: "2011-2015, Javier Velilla and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/examples/restbucksCRUD/src/restbucks_server_execution.e b/examples/restbucksCRUD/src/restbucks_server_execution.e new file mode 100644 index 00000000..1637d1c7 --- /dev/null +++ b/examples/restbucksCRUD/src/restbucks_server_execution.e @@ -0,0 +1,57 @@ +note + description : "REST Buck server" + date : "$Date$" + revision : "$Revision$" + +class RESTBUCKS_SERVER_EXECUTION + +inherit + + WSF_ROUTED_SKELETON_EXECUTION + undefine + requires_proxy + redefine + initialize + end + + WSF_URI_TEMPLATE_HELPER_FOR_ROUTED_EXECUTION + + WSF_HANDLER_HELPER + + WSF_NO_PROXY_POLICY + +create + make + +feature {NONE} -- Initialization + + initialize + do + Precursor + initialize_router + end + + setup_router + local + order_handler: ORDER_HANDLER + doc: WSF_ROUTER_SELF_DOCUMENTATION_HANDLER + do + create order_handler.make_with_router (router) + router.handle_with_request_methods ("/order", order_handler, router.methods_POST) + router.handle_with_request_methods ("/order/{orderid}", order_handler, router.methods_GET + router.methods_DELETE + router.methods_PUT) + create doc.make_hidden (router) + router.handle_with_request_methods ("/api/doc", doc, router.methods_GET) + end + + +note + copyright: "2011-2015, Javier Velilla 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 + ]" +end diff --git a/examples/simple/application.e b/examples/simple/application.e index 159f0cf4..d1de21d9 100644 --- a/examples/simple/application.e +++ b/examples/simple/application.e @@ -7,7 +7,7 @@ class APPLICATION inherit - WSF_DEFAULT_SERVICE + WSF_DEFAULT_SERVICE [APPLICATION_EXECUTION] redefine initialize end @@ -23,14 +23,6 @@ feature {NONE} -- Initialization set_service_option ("port", 9090) end -feature -- Basic operations - execute (req: WSF_REQUEST; res: WSF_RESPONSE) - do - -- To send a response we need to setup, the status code and - -- the response headers. - res.put_header ({HTTP_STATUS_CODE}.ok, <<["Content-Type", "text/plain"], ["Content-Length", "11"]>>) - res.put_string ("Hello World") - end end diff --git a/examples/simple/application_execution.e b/examples/simple/application_execution.e new file mode 100644 index 00000000..decbde71 --- /dev/null +++ b/examples/simple/application_execution.e @@ -0,0 +1,34 @@ +note + description : "simple application execution" + date : "$Date$" + revision : "$Revision$" + +class + APPLICATION_EXECUTION + +inherit + WSF_EXECUTION + +create + make + +feature -- Basic operations + + execute + local + s: STRING + do + -- To send a response we need to setup, the status code and + -- the response headers. + s := "Hello World!" + 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 attached request.http_connection as l_connection and then l_connection.is_case_insensitive_equal_general ("keep-alive") then + response.header.put_header_key_value ("Connection", "keep-alive") + end + response.put_string (s) + end + +end diff --git a/examples/simple/simple.ecf b/examples/simple/simple.ecf index 4bf050c9..1f7ea4c9 100644 --- a/examples/simple/simple.ecf +++ b/examples/simple/simple.ecf @@ -13,12 +13,12 @@ - + - + @@ -45,6 +45,6 @@ - + diff --git a/examples/simple_file/service_file.ecf b/examples/simple_file/service_file.ecf index 76534911..2a023343 100644 --- a/examples/simple_file/service_file.ecf +++ b/examples/simple_file/service_file.ecf @@ -6,8 +6,8 @@ - - + + diff --git a/examples/upload_image/src/image_uploader_execution.e b/examples/upload_image/src/image_uploader_execution.e index 84f51c87..68f1d22b 100644 --- a/examples/upload_image/src/image_uploader_execution.e +++ b/examples/upload_image/src/image_uploader_execution.e @@ -8,20 +8,19 @@ class IMAGE_UPLOADER_EXECUTION inherit - WSF_EXECUTION - redefine - initialize - end - WSF_ROUTED_SKELETON_EXECUTION undefine requires_proxy + redefine + initialize end WSF_NO_PROXY_POLICY WSF_URI_TEMPLATE_HELPER_FOR_ROUTED_EXECUTION + SHARED_EXECUTION_ENVIRONMENT + create make @@ -41,7 +40,7 @@ feature {NONE} -- Initialization map_uri_template_agent_with_request_methods ("/upload/{name}{?nb}", agent execute_upload_put, router.methods_put) map_uri_template_agent ("/upload{?nb}", agent execute_upload) - create www.make (document_root) + create www.make_with_path (document_root) www.set_directory_index (<<"index.html">>) www.set_not_found_handler (agent execute_not_found) router.handle_with_request_methods ("", www, router.methods_GET) @@ -49,31 +48,16 @@ feature {NONE} -- Initialization feature -- Configuration - document_root: READABLE_STRING_8 + document_root: PATH -- Document root to look for files or directories - local - e: EXECUTION_ENVIRONMENT - dn: DIRECTORY_NAME once - create e - create dn.make_from_string (e.current_working_directory) - dn.extend ("htdocs") - Result := dn.string - if Result [Result.count] = Operating_environment.directory_separator then - Result := Result.substring (1, Result.count - 1) - end - ensure - not Result.ends_with (Operating_environment.directory_separator.out) + Result := execution_environment.current_working_path.extended ("htdocs") end - files_root: READABLE_STRING_8 + files_root: PATH -- Uploaded files will be stored in `files_root' folder - local - dn: DIRECTORY_NAME once - create dn.make_from_string (document_root) - dn.extend ("files") - Result := dn.string + Result := document_root.extended ("files") end feature -- Execution @@ -109,8 +93,7 @@ feature -- Execution n := 1 end if attached {WSF_STRING} req.query_parameter ("demo") as p_demo then - create fn.make_from_string (document_root) - fn := fn.extended (p_demo.value) + fn := document_root.extended (p_demo.value) l_body.append ("File:
    %N") end @@ -134,9 +117,8 @@ feature -- Execution n := n + 1 l_body.append ("
  • ") l_body.append ("
    " + c.item.name + "=" + html_encode (c.item.filename) + " size=" + c.item.size.out + " type=" + c.item.content_type + "
    ") - create fn.make_from_string (files_root) l_safe_filename := c.item.safe_filename - fn := fn.extended (l_safe_filename) + fn := files_root.extended (l_safe_filename) if c.item.move_to (fn.name) then if c.item.content_type.starts_with ("image") then l_body.append ("%N") @@ -182,8 +164,7 @@ feature -- Execution if attached new_temporary_output_file ("tmp-uploaded-file_" + n.out) as f then req.read_input_data_into_file (f) f.close - create fn.make_from_string (files_root) - fn := fn.extended (l_safe_filename) + fn := files_root.extended (l_safe_filename) f.rename_file (fn.name) l_body.append ("
  • ") l_body.append ("
    Input data : size=" + f.count.out + " (" + req.content_length_value.out + ")
    ") diff --git a/library/security/openid/consumer/demo/application.e b/library/security/openid/consumer/demo/application.e index b74ef494..819fa640 100644 --- a/library/security/openid/consumer/demo/application.e +++ b/library/security/openid/consumer/demo/application.e @@ -8,17 +8,8 @@ class inherit - WSF_ROUTED_SKELETON_SERVICE - undefine - requires_proxy - end - - WSF_URI_TEMPLATE_HELPER_FOR_ROUTED_SERVICE - WSF_SERVICE - WSF_NO_PROXY_POLICY - SHARED_EXECUTION_ENVIRONMENT export {NONE} all @@ -31,15 +22,13 @@ feature {NONE} -- Initialization make_and_launch local - launcher: WSF_NINO_SERVICE_LAUNCHER + launcher: WSF_NINO_SERVICE_LAUNCHER [APPLICATION_EXECUTION] opts: WSF_SERVICE_LAUNCHER_OPTIONS do - initialize_router - create opts.make opts.set_verbose (True) opts.set_option ("port", 0) - create launcher.make (Current, opts) + create launcher.make (opts) launcher.on_launched_actions.extend (agent on_launched) launcher.launch end @@ -49,7 +38,7 @@ feature {NONE} -- Initialization e: EXECUTION_ENVIRONMENT cmd: STRING_32 do - if attached {WGI_NINO_CONNECTOR} conn as nino then + if attached {WGI_NINO_CONNECTOR [APPLICATION_EXECUTION]} conn as nino then e := execution_environment create cmd.make (32) if attached e.item ("COMSPEC") as l_comspec then @@ -64,105 +53,4 @@ feature {NONE} -- Initialization end end - setup_router - do - map_uri_template_agent ("/", agent handle_root) - map_uri_template_agent ("/openid", agent handle_openid) - end - - handle_root (req: WSF_REQUEST; res: WSF_RESPONSE) - local - m: WSF_HTML_PAGE_RESPONSE - s: STRING - do - create m.make - m.set_title ("EWF::OpenID demo") - create s.make_empty - s.append ("
    %N") - s.append ("OpenID identifier ") - s.append ("") - s.append ("
    %N") - s.append ("
    %N") - s.append ("OpenID identifier ") - s.append ("") - s.append ("
    %N") - m.set_body (s) - res.send (m) - end - - handle_openid (req: WSF_REQUEST; res: WSF_RESPONSE) - local - m: WSF_HTML_PAGE_RESPONSE - redir: WSF_HTML_DELAYED_REDIRECTION_RESPONSE - s: STRING - o: OPENID_CONSUMER - v: OPENID_CONSUMER_VALIDATION - do - if attached req.string_item ("openid.mode") as l_openid_mode then - create m.make - m.set_title ("EWF::OpenID demo") - create s.make_empty - - if l_openid_mode.same_string ("id_res") then - o := new_openid_consumer (req) - create v.make_from_items (o, req.items_as_string_items) - v.validate - if v.is_valid then - s.append ("
    User authenticated
    ") - s.append ("
      Request items") - across - req.items as c - loop - s.append ("
    • " + c.item.url_encoded_name + "=" + c.item.string_representation + "
    • ") - end - s.append ("
    ") - s.append ("
      Attributes") - across - v.attributes as c - loop - s.append ("
    • " + c.key + "=" + c.item + "
    • ") - end - s.append ("
    ") - else - s.append ("
    User authentication failed!!!
    ") - end - else - s.append ("
    Unexpected OpenID.mode=" + l_openid_mode + "
    ") - end - m.set_body (s) - res.send (m) - elseif attached req.string_item ("openid_identifier") as l_id then - create s.make_empty - - o := new_openid_consumer (req) - s.append ("Testing " + l_id + "
    %N") - s.append ("Return-to" + o.return_url + "
    ") - if attached o.auth_url (l_id) as l_auth_url then - s.append ("Click to sign with " + l_id + "
    ") - create redir.make (l_auth_url, 1) - s.append ("Automatically follow link in " + redir.delay.out + " second(s)
    ") - redir.set_title ("EWF::OpenID demo") - redir.set_body (s) - res.send (redir) - else - create m.make - m.set_title ("EWF::OpenID demo") - m.set_body (s) - res.send (m) - end - else - res.redirect_now ("/") - end - end - - new_openid_consumer (req: WSF_REQUEST): OPENID_CONSUMER - do - create Result.make (req.absolute_script_url ("/openid")) - - Result.ask_email (True) - Result.ask_all_info (False) --- Result.ask_nickname (False) --- Result.ask_fullname (False) --- Result.ask_country (True) - end end diff --git a/library/security/openid/consumer/demo/application_execution.e b/library/security/openid/consumer/demo/application_execution.e new file mode 100644 index 00000000..bfac0f31 --- /dev/null +++ b/library/security/openid/consumer/demo/application_execution.e @@ -0,0 +1,131 @@ +note + description : "OPENID demo application root class" + date : "$Date$" + revision : "$Revision$" + +class + APPLICATION_EXECUTION + +inherit + + WSF_ROUTED_SKELETON_EXECUTION + undefine + requires_proxy + end + + WSF_URI_TEMPLATE_HELPER_FOR_ROUTED_EXECUTION + + WSF_NO_PROXY_POLICY + + SHARED_EXECUTION_ENVIRONMENT + export + {NONE} all + end + +create + make + +feature {NONE} -- Initialization + + setup_router + do + map_uri_template_agent ("/", agent handle_root) + map_uri_template_agent ("/openid", agent handle_openid) + end + + handle_root (req: WSF_REQUEST; res: WSF_RESPONSE) + local + m: WSF_HTML_PAGE_RESPONSE + s: STRING + do + create m.make + m.set_title ("EWF::OpenID demo") + create s.make_empty + s.append ("
    %N") + s.append ("OpenID identifier ") + s.append ("") + s.append ("
    %N") + s.append ("
    %N") + s.append ("OpenID identifier ") + s.append ("") + s.append ("
    %N") + m.set_body (s) + res.send (m) + end + + handle_openid (req: WSF_REQUEST; res: WSF_RESPONSE) + local + m: WSF_HTML_PAGE_RESPONSE + redir: WSF_HTML_DELAYED_REDIRECTION_RESPONSE + s: STRING + o: OPENID_CONSUMER + v: OPENID_CONSUMER_VALIDATION + do + if attached req.string_item ("openid.mode") as l_openid_mode then + create m.make + m.set_title ("EWF::OpenID demo") + create s.make_empty + + if l_openid_mode.same_string ("id_res") then + o := new_openid_consumer (req) + create v.make_from_items (o, req.items_as_string_items) + v.validate + if v.is_valid then + s.append ("
    User authenticated
    ") + s.append ("
      Request items") + across + req.items as c + loop + s.append ("
    • " + c.item.url_encoded_name + "=" + c.item.string_representation + "
    • ") + end + s.append ("
    ") + s.append ("
      Attributes") + across + v.attributes as c + loop + s.append ("
    • " + c.key + "=" + c.item + "
    • ") + end + s.append ("
    ") + else + s.append ("
    User authentication failed!!!
    ") + end + else + s.append ("
    Unexpected OpenID.mode=" + l_openid_mode + "
    ") + end + m.set_body (s) + res.send (m) + elseif attached req.string_item ("openid_identifier") as l_id then + create s.make_empty + + o := new_openid_consumer (req) + s.append ("Testing " + l_id + "
    %N") + s.append ("Return-to" + o.return_url + "
    ") + if attached o.auth_url (l_id) as l_auth_url then + s.append ("Click to sign with " + l_id + "
    ") + create redir.make (l_auth_url, 1) + s.append ("Automatically follow link in " + redir.delay.out + " second(s)
    ") + redir.set_title ("EWF::OpenID demo") + redir.set_body (s) + res.send (redir) + else + create m.make + m.set_title ("EWF::OpenID demo") + m.set_body (s) + res.send (m) + end + else + res.redirect_now ("/") + end + end + + new_openid_consumer (req: WSF_REQUEST): OPENID_CONSUMER + do + create Result.make (req.absolute_script_url ("/openid")) + + Result.ask_email (True) + Result.ask_all_info (False) +-- Result.ask_nickname (False) +-- Result.ask_fullname (False) +-- Result.ask_country (True) + end +end diff --git a/library/server/authentication/http_authorization/example/demo_basic.e b/library/server/authentication/http_authorization/example/demo_basic.e index fddbc3ee..f65a77bc 100644 --- a/library/server/authentication/http_authorization/example/demo_basic.e +++ b/library/server/authentication/http_authorization/example/demo_basic.e @@ -7,13 +7,11 @@ class DEMO_BASIC inherit - WSF_DEFAULT_SERVICE + WSF_DEFAULT_SERVICE [DEMO_BASIC_EXECUTION] redefine initialize end - SHARED_HTML_ENCODER - create make_and_launch @@ -26,210 +24,4 @@ feature {NONE} -- Initialization set_service_option ("verbose", True) end -feature -- Credentials - - is_known_login (a_login: READABLE_STRING_GENERAL): BOOLEAN - -- Is `a_login' a known username? - do - Result := valid_credentials.has (a_login) - end - - is_valid_credential (a_login: READABLE_STRING_GENERAL; a_password: detachable READABLE_STRING_GENERAL): BOOLEAN - -- Is `a_login:a_password' a valid credential? - do - if - a_password /= Void and - attached valid_credentials.item (a_login) as l_passwd - then - Result := a_password.is_case_insensitive_equal (l_passwd) - end - ensure - Result implies is_known_login (a_login) - end - - demo_credential: STRING_32 - -- First valid known credential display for demo in dialog. - do - valid_credentials.start - create Result.make_from_string_general (valid_credentials.key_for_iteration) - Result.append_character (':') - Result.append (valid_credentials.item_for_iteration) - end - - valid_credentials: STRING_TABLE [READABLE_STRING_32] - -- Password indexed by login. - once - create Result.make_caseless (3) - Result.force ("world", "eiffel") - Result.force ("bar", "foo") - Result.force ("password", "user") - ensure - not Result.is_empty - end - -feature -- Basic operations - - execute (req: WSF_REQUEST; res: WSF_RESPONSE) - -- - local - auth: HTTP_AUTHORIZATION - l_authenticated_username: detachable READABLE_STRING_32 - l_invalid_credential: BOOLEAN - do - if attached req.http_authorization as l_http_auth then - create auth.make (l_http_auth) - if attached auth.login as l_login and then is_valid_credential (l_login, auth.password) then - l_authenticated_username := auth.login - else - l_invalid_credential := True - end - end - if l_invalid_credential then - handle_unauthorized ("ERROR: Invalid credential", req, res) - else - if l_authenticated_username /= Void then - handle_authenticated (l_authenticated_username, req, res) - elseif req.path_info.same_string_general ("/login") then - handle_unauthorized ("Please provide credential ...", req, res) - elseif req.path_info.starts_with_general ("/protected/") then - -- any "/protected/*" url - handle_unauthorized ("Protected area, please sign in before", req, res) - else - handle_anonymous (req, res) - end - end - end - - handle_authenticated (a_username: READABLE_STRING_32; req: WSF_REQUEST; res: WSF_RESPONSE) - -- User `a_username' is authenticated, execute request `req' with response `res'. - require - valid_username: not a_username.is_empty - known_username: is_known_login (a_username) - local - s: STRING - page: WSF_HTML_PAGE_RESPONSE - do - create s.make_empty - - append_html_header (req, s) - - s.append ("

    The authenticated user is ") - s.append (html_encoder.general_encoded_string (a_username)) - s.append (" ...

    ") - - append_html_menu (a_username, req, s) - append_html_logout (a_username, req, s) - append_html_footer (req, s) - - create page.make - page.set_body (s) - res.send (page) - end - - handle_anonymous (req: WSF_REQUEST; res: WSF_RESPONSE) - -- No user is authenticated, execute request `req' with response `res'. - local - s: STRING - page: WSF_HTML_PAGE_RESPONSE - do - create s.make_empty - append_html_header (req, s) - - s.append ("Anonymous visitor ...
    ") - - append_html_login (req, s) - append_html_menu (Void, req, s) - append_html_footer (req, s) - - create page.make - page.set_body (s) - res.send (page) - end - - handle_unauthorized (a_description: STRING; req: WSF_REQUEST; res: WSF_RESPONSE) - -- Restricted page, authenticated user is required. - -- Send `a_description' as part of the response. - local - h: HTTP_HEADER - s: STRING - page: WSF_HTML_PAGE_RESPONSE - do - create s.make_from_string (a_description) - - append_html_login (req, s) - append_html_menu (Void, req, s) - append_html_footer (req, s) - - create page.make - page.set_status_code ({HTTP_STATUS_CODE}.unauthorized) - page.header.put_header_key_value ({HTTP_HEADER_NAMES}.header_www_authenticate, - "Basic realm=%"Please enter a valid username and password (demo [" + html_encoder.encoded_string (demo_credential) + "])%"" - --| warning: for this example: a valid credential is provided in the message, of course that for real application. - ) - page.set_body (s) - res.send (page) - end - -feature -- Helper - - append_html_header (req: WSF_REQUEST; s: STRING) - -- Append header paragraph to `s'. - do - s.append ("

    The current page is " + html_encoder.encoded_string (req.path_info) + "

    ") - end - - append_html_menu (a_username: detachable READABLE_STRING_32; req: WSF_REQUEST; s: STRING) - -- Append menu to `s'. - -- when an user is authenticated, `a_username' is attached. - do - if a_username /= Void then - s.append ("
  • Your account (displayed only is user is authenticated!)
  • ") - end - s.append ("
  • home
  • ") - s.append ("
  • public area
  • ") - s.append ("
  • protected area
  • ") - end - - append_html_login (req: WSF_REQUEST; s: STRING) - -- Append login link to `s'. - do - s.append ("
  • sign in
  • ") - end - - append_html_logout (a_username: detachable READABLE_STRING_32; req: WSF_REQUEST; s: STRING) - -- Append logout link to `s'. - local - l_logout_url: STRING - do - l_logout_url := req.absolute_script_url ("/login") - l_logout_url.replace_substring_all ("://", "://_@") -- Hack to clear http authorization, i.e connect with bad username "_". - s.append ("
  • logout
  • ") - end - - append_html_footer (req: WSF_REQUEST; s: STRING) - -- Append html footer to `s'. - local - hauth: HTTP_AUTHORIZATION - do - s.append ("
    ") - if attached req.http_authorization as l_http_authorization then - s.append ("Has Authorization: header: ") - create hauth.make (req.http_authorization) - if attached hauth.login as l_login then - s.append (" login=" + html_encoder.encoded_string (l_login)+ "") - end - if attached hauth.password as l_password then - s.append (" password=" + html_encoder.encoded_string (l_password)+ "") - end - s.append ("
    ") - end - if attached req.raw_header_data as l_header then - -- Append the raw header data for information - s.append ("Raw header data:") - s.append ("
    ")
    -				s.append (l_header)
    -				s.append ("
    ") - end - end - end diff --git a/library/server/authentication/http_authorization/example/demo_basic_execution.e b/library/server/authentication/http_authorization/example/demo_basic_execution.e new file mode 100644 index 00000000..47926411 --- /dev/null +++ b/library/server/authentication/http_authorization/example/demo_basic_execution.e @@ -0,0 +1,226 @@ +note + description : "simple application root class" + date : "$Date$" + revision : "$Revision$" + +class + DEMO_BASIC_EXECUTION + +inherit + WSF_EXECUTION + + SHARED_HTML_ENCODER + +create + make + +feature -- Credentials + + is_known_login (a_login: READABLE_STRING_GENERAL): BOOLEAN + -- Is `a_login' a known username? + do + Result := valid_credentials.has (a_login) + end + + is_valid_credential (a_login: READABLE_STRING_GENERAL; a_password: detachable READABLE_STRING_GENERAL): BOOLEAN + -- Is `a_login:a_password' a valid credential? + do + if + a_password /= Void and + attached valid_credentials.item (a_login) as l_passwd + then + Result := a_password.is_case_insensitive_equal (l_passwd) + end + ensure + Result implies is_known_login (a_login) + end + + demo_credential: STRING_32 + -- First valid known credential display for demo in dialog. + do + valid_credentials.start + create Result.make_from_string_general (valid_credentials.key_for_iteration) + Result.append_character (':') + Result.append (valid_credentials.item_for_iteration) + end + + valid_credentials: STRING_TABLE [READABLE_STRING_32] + -- Password indexed by login. + once + create Result.make_caseless (3) + Result.force ("world", "eiffel") + Result.force ("bar", "foo") + Result.force ("password", "user") + ensure + not Result.is_empty + end + +feature -- Basic operations + + execute + -- + local + auth: HTTP_AUTHORIZATION + l_authenticated_username: detachable READABLE_STRING_32 + l_invalid_credential: BOOLEAN + req: WSF_REQUEST + res: WSF_RESPONSE + do + req := request + res := response + if attached req.http_authorization as l_http_auth then + create auth.make (l_http_auth) + if attached auth.login as l_login and then is_valid_credential (l_login, auth.password) then + l_authenticated_username := auth.login + else + l_invalid_credential := True + end + end + if l_invalid_credential then + handle_unauthorized ("ERROR: Invalid credential", req, res) + else + if l_authenticated_username /= Void then + handle_authenticated (l_authenticated_username, req, res) + elseif req.path_info.same_string_general ("/login") then + handle_unauthorized ("Please provide credential ...", req, res) + elseif req.path_info.starts_with_general ("/protected/") then + -- any "/protected/*" url + handle_unauthorized ("Protected area, please sign in before", req, res) + else + handle_anonymous (req, res) + end + end + end + + handle_authenticated (a_username: READABLE_STRING_32; req: WSF_REQUEST; res: WSF_RESPONSE) + -- User `a_username' is authenticated, execute request `req' with response `res'. + require + valid_username: not a_username.is_empty + known_username: is_known_login (a_username) + local + s: STRING + page: WSF_HTML_PAGE_RESPONSE + do + create s.make_empty + + append_html_header (req, s) + + s.append ("

    The authenticated user is ") + s.append (html_encoder.general_encoded_string (a_username)) + s.append (" ...

    ") + + append_html_menu (a_username, req, s) + append_html_logout (a_username, req, s) + append_html_footer (req, s) + + create page.make + page.set_body (s) + res.send (page) + end + + handle_anonymous (req: WSF_REQUEST; res: WSF_RESPONSE) + -- No user is authenticated, execute request `req' with response `res'. + local + s: STRING + page: WSF_HTML_PAGE_RESPONSE + do + create s.make_empty + append_html_header (req, s) + + s.append ("Anonymous visitor ...
    ") + + append_html_login (req, s) + append_html_menu (Void, req, s) + append_html_footer (req, s) + + create page.make + page.set_body (s) + res.send (page) + end + + handle_unauthorized (a_description: STRING; req: WSF_REQUEST; res: WSF_RESPONSE) + -- Restricted page, authenticated user is required. + -- Send `a_description' as part of the response. + local + s: STRING + page: WSF_HTML_PAGE_RESPONSE + do + create s.make_from_string (a_description) + + append_html_login (req, s) + append_html_menu (Void, req, s) + append_html_footer (req, s) + + create page.make + page.set_status_code ({HTTP_STATUS_CODE}.unauthorized) + page.header.put_header_key_value ({HTTP_HEADER_NAMES}.header_www_authenticate, + "Basic realm=%"Please enter a valid username and password (demo [" + html_encoder.encoded_string (demo_credential) + "])%"" + --| warning: for this example: a valid credential is provided in the message, of course that for real application. + ) + page.set_body (s) + res.send (page) + end + +feature -- Helper + + append_html_header (req: WSF_REQUEST; s: STRING) + -- Append header paragraph to `s'. + do + s.append ("

    The current page is " + html_encoder.encoded_string (req.path_info) + "

    ") + end + + append_html_menu (a_username: detachable READABLE_STRING_32; req: WSF_REQUEST; s: STRING) + -- Append menu to `s'. + -- when an user is authenticated, `a_username' is attached. + do + if a_username /= Void then + s.append ("
  • Your account (displayed only is user is authenticated!)
  • ") + end + s.append ("
  • home
  • ") + s.append ("
  • public area
  • ") + s.append ("
  • protected area
  • ") + end + + append_html_login (req: WSF_REQUEST; s: STRING) + -- Append login link to `s'. + do + s.append ("
  • sign in
  • ") + end + + append_html_logout (a_username: detachable READABLE_STRING_32; req: WSF_REQUEST; s: STRING) + -- Append logout link to `s'. + local + l_logout_url: STRING + do + l_logout_url := req.absolute_script_url ("/login") + l_logout_url.replace_substring_all ("://", "://_@") -- Hack to clear http authorization, i.e connect with bad username "_". + s.append ("
  • logout
  • ") + end + + append_html_footer (req: WSF_REQUEST; s: STRING) + -- Append html footer to `s'. + local + hauth: HTTP_AUTHORIZATION + do + s.append ("
    ") + if attached req.http_authorization as l_http_authorization then + s.append ("Has Authorization: header: ") + create hauth.make (req.http_authorization) + if attached hauth.login as l_login then + s.append (" login=" + html_encoder.encoded_string (l_login)+ "") + end + if attached hauth.password as l_password then + s.append (" password=" + html_encoder.encoded_string (l_password)+ "") + end + s.append ("
    ") + end + if attached req.raw_header_data as l_header then + -- Append the raw header data for information + s.append ("Raw header data:") + s.append ("
    ")
    +				s.append (l_header)
    +				s.append ("
    ") + end + end + +end diff --git a/library/server/ewsgi/connectors/nino/src/nino_service.e b/library/server/ewsgi/connectors/nino/src/nino_service.e index 8f596a28..4dcaabeb 100644 --- a/library/server/ewsgi/connectors/nino/src/nino_service.e +++ b/library/server/ewsgi/connectors/nino/src/nino_service.e @@ -26,23 +26,6 @@ feature {NONE} -- Implementation create connector.make_with_base (a_base_url) end --- make_with_callback (a_callback: PROCEDURE [ANY, TUPLE [req: WGI_REQUEST; res: WGI_RESPONSE]]) --- -- Initialize `Current'. --- do --- make_custom_with_callback (a_callback, Void) --- end - --- make_custom_with_callback (a_callback: PROCEDURE [ANY, TUPLE [req: WGI_REQUEST; res: WGI_RESPONSE]]; a_base_url: detachable STRING) --- -- Initialize `Current'. --- require --- base_url_starts_with_slash: (a_base_url /= Void and then not a_base_url.is_empty) implies a_base_url.starts_with ("/") --- local --- app: WGI_AGENT_SERVICE --- do --- create app.make (a_callback) --- make_custom (app, a_base_url) --- end - feature -- Access connector: WGI_NINO_CONNECTOR [G] diff --git a/library/server/ewsgi/connectors/httpd/dev/app_counter.e b/library/server/ewsgi/connectors/standalone/dev/app_counter.e similarity index 100% rename from library/server/ewsgi/connectors/httpd/dev/app_counter.e rename to library/server/ewsgi/connectors/standalone/dev/app_counter.e diff --git a/library/server/ewsgi/connectors/httpd/dev/app_wsf_execution.e b/library/server/ewsgi/connectors/standalone/dev/app_wsf_execution.e similarity index 100% rename from library/server/ewsgi/connectors/httpd/dev/app_wsf_execution.e rename to library/server/ewsgi/connectors/standalone/dev/app_wsf_execution.e diff --git a/library/server/ewsgi/connectors/httpd/dev/httpd_connector_dev.e b/library/server/ewsgi/connectors/standalone/dev/httpd_connector_dev.e similarity index 68% rename from library/server/ewsgi/connectors/httpd/dev/httpd_connector_dev.e rename to library/server/ewsgi/connectors/standalone/dev/httpd_connector_dev.e index 9353f5c3..d299ec48 100644 --- a/library/server/ewsgi/connectors/httpd/dev/httpd_connector_dev.e +++ b/library/server/ewsgi/connectors/standalone/dev/httpd_connector_dev.e @@ -17,16 +17,27 @@ feature {NONE} -- Initialization make -- Initialize `Current'. local - conn: WGI_HTTPD_CONNECTOR [APP_WSF_EXECUTION] + conn: WGI_STANDALONE_CONNECTOR [APP_WSF_EXECUTION] do print ("Starting httpd server ...%N") create conn.make + conn.on_launched_actions.extend (agent on_launched) conn.set_port_number (9090) conn.set_max_concurrent_connections (100) conn.launch end + on_launched (conn: WGI_STANDALONE_CONNECTOR [WGI_EXECUTION]) + do + print ("Server listening on port " + conn.port.out + "%N") + end + + on_stopped (conn: WGI_STANDALONE_CONNECTOR [WGI_EXECUTION]) + do + print ("Server terminated%N") + end + note copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" diff --git a/library/server/ewsgi/connectors/httpd/license.lic b/library/server/ewsgi/connectors/standalone/license.lic similarity index 100% rename from library/server/ewsgi/connectors/httpd/license.lic rename to library/server/ewsgi/connectors/standalone/license.lic diff --git a/library/server/ewsgi/connectors/httpd/src/httpd/concurrency/none/httpd_connection_handler.e b/library/server/ewsgi/connectors/standalone/src/httpd/concurrency/none/httpd_connection_handler.e similarity index 100% rename from library/server/ewsgi/connectors/httpd/src/httpd/concurrency/none/httpd_connection_handler.e rename to library/server/ewsgi/connectors/standalone/src/httpd/concurrency/none/httpd_connection_handler.e diff --git a/library/server/ewsgi/connectors/httpd/src/httpd/concurrency/none/httpd_request_handler.e b/library/server/ewsgi/connectors/standalone/src/httpd/concurrency/none/httpd_request_handler.e similarity index 100% rename from library/server/ewsgi/connectors/httpd/src/httpd/concurrency/none/httpd_request_handler.e rename to library/server/ewsgi/connectors/standalone/src/httpd/concurrency/none/httpd_request_handler.e diff --git a/library/server/ewsgi/connectors/httpd/src/httpd/concurrency/none/httpd_request_handler_factory.e b/library/server/ewsgi/connectors/standalone/src/httpd/concurrency/none/httpd_request_handler_factory.e similarity index 100% rename from library/server/ewsgi/connectors/httpd/src/httpd/concurrency/none/httpd_request_handler_factory.e rename to library/server/ewsgi/connectors/standalone/src/httpd/concurrency/none/httpd_request_handler_factory.e diff --git a/library/server/ewsgi/connectors/httpd/src/httpd/concurrency/scoop/httpd_connection_handler.e b/library/server/ewsgi/connectors/standalone/src/httpd/concurrency/scoop/httpd_connection_handler.e similarity index 100% rename from library/server/ewsgi/connectors/httpd/src/httpd/concurrency/scoop/httpd_connection_handler.e rename to library/server/ewsgi/connectors/standalone/src/httpd/concurrency/scoop/httpd_connection_handler.e diff --git a/library/server/ewsgi/connectors/httpd/src/httpd/concurrency/scoop/httpd_request_handler.e b/library/server/ewsgi/connectors/standalone/src/httpd/concurrency/scoop/httpd_request_handler.e similarity index 100% rename from library/server/ewsgi/connectors/httpd/src/httpd/concurrency/scoop/httpd_request_handler.e rename to library/server/ewsgi/connectors/standalone/src/httpd/concurrency/scoop/httpd_request_handler.e diff --git a/library/server/ewsgi/connectors/httpd/src/httpd/concurrency/scoop/httpd_request_handler_factory.e b/library/server/ewsgi/connectors/standalone/src/httpd/concurrency/scoop/httpd_request_handler_factory.e similarity index 100% rename from library/server/ewsgi/connectors/httpd/src/httpd/concurrency/scoop/httpd_request_handler_factory.e rename to library/server/ewsgi/connectors/standalone/src/httpd/concurrency/scoop/httpd_request_handler_factory.e diff --git a/library/server/ewsgi/connectors/httpd/src/httpd/concurrency/scoop/pool/concurrent_pool.e b/library/server/ewsgi/connectors/standalone/src/httpd/concurrency/scoop/pool/concurrent_pool.e similarity index 100% rename from library/server/ewsgi/connectors/httpd/src/httpd/concurrency/scoop/pool/concurrent_pool.e rename to library/server/ewsgi/connectors/standalone/src/httpd/concurrency/scoop/pool/concurrent_pool.e diff --git a/library/server/ewsgi/connectors/httpd/src/httpd/concurrency/scoop/pool/concurrent_pool_factory.e b/library/server/ewsgi/connectors/standalone/src/httpd/concurrency/scoop/pool/concurrent_pool_factory.e similarity index 100% rename from library/server/ewsgi/connectors/httpd/src/httpd/concurrency/scoop/pool/concurrent_pool_factory.e rename to library/server/ewsgi/connectors/standalone/src/httpd/concurrency/scoop/pool/concurrent_pool_factory.e diff --git a/library/server/ewsgi/connectors/httpd/src/httpd/concurrency/scoop/pool/concurrent_pool_item.e b/library/server/ewsgi/connectors/standalone/src/httpd/concurrency/scoop/pool/concurrent_pool_item.e similarity index 100% rename from library/server/ewsgi/connectors/httpd/src/httpd/concurrency/scoop/pool/concurrent_pool_item.e rename to library/server/ewsgi/connectors/standalone/src/httpd/concurrency/scoop/pool/concurrent_pool_item.e diff --git a/library/server/ewsgi/connectors/httpd/src/httpd/concurrency/thread/httpd_connection_handler.e b/library/server/ewsgi/connectors/standalone/src/httpd/concurrency/thread/httpd_connection_handler.e similarity index 100% rename from library/server/ewsgi/connectors/httpd/src/httpd/concurrency/thread/httpd_connection_handler.e rename to library/server/ewsgi/connectors/standalone/src/httpd/concurrency/thread/httpd_connection_handler.e diff --git a/library/server/ewsgi/connectors/httpd/src/httpd/concurrency/thread/httpd_request_handler.e b/library/server/ewsgi/connectors/standalone/src/httpd/concurrency/thread/httpd_request_handler.e similarity index 100% rename from library/server/ewsgi/connectors/httpd/src/httpd/concurrency/thread/httpd_request_handler.e rename to library/server/ewsgi/connectors/standalone/src/httpd/concurrency/thread/httpd_request_handler.e diff --git a/library/server/ewsgi/connectors/httpd/src/httpd/concurrency/thread/httpd_request_handler_factory.e b/library/server/ewsgi/connectors/standalone/src/httpd/concurrency/thread/httpd_request_handler_factory.e similarity index 100% rename from library/server/ewsgi/connectors/httpd/src/httpd/concurrency/thread/httpd_request_handler_factory.e rename to library/server/ewsgi/connectors/standalone/src/httpd/concurrency/thread/httpd_request_handler_factory.e diff --git a/library/server/ewsgi/connectors/httpd/src/httpd/concurrency/thread/pool/pooled_thread.e b/library/server/ewsgi/connectors/standalone/src/httpd/concurrency/thread/pool/pooled_thread.e similarity index 100% rename from library/server/ewsgi/connectors/httpd/src/httpd/concurrency/thread/pool/pooled_thread.e rename to library/server/ewsgi/connectors/standalone/src/httpd/concurrency/thread/pool/pooled_thread.e diff --git a/library/server/ewsgi/connectors/httpd/src/httpd/concurrency/thread/pool/thread_pool.e b/library/server/ewsgi/connectors/standalone/src/httpd/concurrency/thread/pool/thread_pool.e similarity index 100% rename from library/server/ewsgi/connectors/httpd/src/httpd/concurrency/thread/pool/thread_pool.e rename to library/server/ewsgi/connectors/standalone/src/httpd/concurrency/thread/pool/thread_pool.e diff --git a/library/server/ewsgi/connectors/httpd/src/httpd/configuration/httpd_configuration_i.e b/library/server/ewsgi/connectors/standalone/src/httpd/configuration/httpd_configuration_i.e similarity index 100% rename from library/server/ewsgi/connectors/httpd/src/httpd/configuration/httpd_configuration_i.e rename to library/server/ewsgi/connectors/standalone/src/httpd/configuration/httpd_configuration_i.e diff --git a/library/server/ewsgi/connectors/httpd/src/httpd/httpd-safe.ecf b/library/server/ewsgi/connectors/standalone/src/httpd/httpd-safe.ecf similarity index 100% rename from library/server/ewsgi/connectors/httpd/src/httpd/httpd-safe.ecf rename to library/server/ewsgi/connectors/standalone/src/httpd/httpd-safe.ecf diff --git a/library/server/ewsgi/connectors/httpd/src/httpd/httpd.ecf b/library/server/ewsgi/connectors/standalone/src/httpd/httpd.ecf similarity index 100% rename from library/server/ewsgi/connectors/httpd/src/httpd/httpd.ecf rename to library/server/ewsgi/connectors/standalone/src/httpd/httpd.ecf diff --git a/library/server/ewsgi/connectors/httpd/src/httpd/httpd_connection_handler_i.e b/library/server/ewsgi/connectors/standalone/src/httpd/httpd_connection_handler_i.e similarity index 100% rename from library/server/ewsgi/connectors/httpd/src/httpd/httpd_connection_handler_i.e rename to library/server/ewsgi/connectors/standalone/src/httpd/httpd_connection_handler_i.e diff --git a/library/server/ewsgi/connectors/httpd/src/httpd/httpd_controller.e b/library/server/ewsgi/connectors/standalone/src/httpd/httpd_controller.e similarity index 100% rename from library/server/ewsgi/connectors/httpd/src/httpd/httpd_controller.e rename to library/server/ewsgi/connectors/standalone/src/httpd/httpd_controller.e diff --git a/library/server/ewsgi/connectors/httpd/src/httpd/httpd_debug_facilities.e b/library/server/ewsgi/connectors/standalone/src/httpd/httpd_debug_facilities.e similarity index 100% rename from library/server/ewsgi/connectors/httpd/src/httpd/httpd_debug_facilities.e rename to library/server/ewsgi/connectors/standalone/src/httpd/httpd_debug_facilities.e diff --git a/library/server/ewsgi/connectors/httpd/src/httpd/httpd_logger.e b/library/server/ewsgi/connectors/standalone/src/httpd/httpd_logger.e similarity index 100% rename from library/server/ewsgi/connectors/httpd/src/httpd/httpd_logger.e rename to library/server/ewsgi/connectors/standalone/src/httpd/httpd_logger.e diff --git a/library/server/ewsgi/connectors/httpd/src/httpd/httpd_request_handler_factory_i.e b/library/server/ewsgi/connectors/standalone/src/httpd/httpd_request_handler_factory_i.e similarity index 100% rename from library/server/ewsgi/connectors/httpd/src/httpd/httpd_request_handler_factory_i.e rename to library/server/ewsgi/connectors/standalone/src/httpd/httpd_request_handler_factory_i.e diff --git a/library/server/ewsgi/connectors/httpd/src/httpd/httpd_request_handler_i.e b/library/server/ewsgi/connectors/standalone/src/httpd/httpd_request_handler_i.e similarity index 71% rename from library/server/ewsgi/connectors/httpd/src/httpd/httpd_request_handler_i.e rename to library/server/ewsgi/connectors/standalone/src/httpd/httpd_request_handler_i.e index 8d85e5f0..b27bb173 100644 --- a/library/server/ewsgi/connectors/httpd/src/httpd/httpd_request_handler_i.e +++ b/library/server/ewsgi/connectors/standalone/src/httpd/httpd_request_handler_i.e @@ -19,14 +19,19 @@ feature {NONE} -- Initialization reset do - has_error := False - version := Void - remote_info := Void + reset_request + has_error := False if attached internal_client_socket as l_sock then l_sock.cleanup end internal_client_socket := Void + end + + reset_request + do + version := Void + remote_info := Void -- FIXME: optimize to just wipe_out if needed create method.make_empty @@ -34,6 +39,7 @@ feature {NONE} -- Initialization create request_header.make_empty create request_header_map.make (10) + keep_alive_enabled := False end feature -- Status report @@ -79,6 +85,24 @@ feature -- Access remote_info: detachable TUPLE [addr: STRING; hostname: STRING; port: INTEGER] -- Information related to remote client + keep_alive_enabled: BOOLEAN + -- Inside a persistent connection? + + is_http_version_1_0: BOOLEAN + do + Result := not attached version as v or else v.same_string ("HTTP/1.0") + end + + is_http_version_1_1: BOOLEAN + do + Result := not attached version as v or else v.same_string ("HTTP/1.1") + end + + is_http_version_2: BOOLEAN + do + Result := not attached version as v or else v.same_string ("HTTP/2.0") + end + feature -- Settings is_verbose: BOOLEAN @@ -93,6 +117,7 @@ feature -- Change set_is_verbose (b: BOOLEAN) do is_verbose := b + print ("set_is_verbose " + b.out + "%N") end feature -- Execution @@ -118,6 +143,33 @@ feature -- Execution end execute + require + is_connected: is_connected + local + l_socket: like client_socket + l_exit: BOOLEAN + n: INTEGER + do + l_socket := client_socket + check + socket_attached: l_socket /= Void + socket_valid: l_socket.is_open_read and then l_socket.is_open_write + end + from + -- Process persistent connection as long the socket is not closed. + n := 0 + until + l_exit + loop + n := n + 1 + -- FIXME: it seems to be called one more time, mostly to see this is done. + execute_request + l_exit := has_error or l_socket.is_closed or not l_socket.is_open_read or not keep_alive_enabled + reset_request + end + end + + execute_request require is_connected: is_connected local @@ -132,14 +184,15 @@ feature -- Execution end if l_socket.is_closed then debug ("dbglog") - dbglog (generator + ".execute {socket is Closed!}") + dbglog (generator + ".execute_request {socket is Closed!}") end else debug ("dbglog") - dbglog (generator + ".execute socket=" + l_socket.descriptor.out + " ENTER") + dbglog (generator + ".execute_request socket=" + l_socket.descriptor.out + " ENTER") end from until l_continue loop - if l_socket.ready_for_reading then + if l_socket.try_ready_for_reading then +-- ready_for_reading then l_continue := True create l_remote_info if attached l_socket.peer_address as l_addr then @@ -150,7 +203,11 @@ feature -- Execution end analyze_request_message (l_socket) else - log (generator + ".execute socket=" + l_socket.descriptor.out + "} WAITING") + has_error := True + l_continue := True + debug ("dbglog") + dbglog (generator + ".execute_request socket=" + l_socket.descriptor.out + "} WAITING") + end end end @@ -164,7 +221,7 @@ feature -- Execution process_request (l_socket) end debug ("dbglog") - dbglog (generator + ".execute {" + l_socket.descriptor.out + "} LEAVE") + dbglog (generator + ".execute_request {" + l_socket.descriptor.out + "} LEAVE") end end end @@ -243,6 +300,22 @@ feature -- Parsing line := next_line (a_socket) end end + if not {HTTPD_SERVER}.is_persistent_connection_supported then + keep_alive_enabled := False + elseif is_http_version_1_0 then + keep_alive_enabled := attached request_header_map.item ("Connection") as l_connection and then + l_connection.is_case_insensitive_equal_general ("keep-alive") + else + -- By default HTTP:1/1 support persistent connection. + if + attached request_header_map.item ("Connection") as l_connection and then + l_connection.is_case_insensitive_equal_general ("close") + then + keep_alive_enabled := False + else + keep_alive_enabled := True + end + end end end @@ -251,7 +324,7 @@ feature -- Parsing require valid_line: line /= Void and then not line.is_empty local - pos, next_pos: INTEGER + n, pos, next_pos: INTEGER do if is_verbose then log ("%N## Parse HTTP request line ##") @@ -261,7 +334,11 @@ feature -- Parsing method := line.substring (1, pos - 1) next_pos := line.index_of (' ', pos + 1) uri := line.substring (pos + 1, next_pos - 1) - version := line.substring (next_pos + 1, line.count) + n := line.count + if line[n] = '%R' then + n := n - 1 + end + version := line.substring (next_pos + 1, n) has_error := method.is_empty end @@ -269,11 +346,18 @@ feature -- Parsing -- Next line fetched from `a_socket' is available. require is_readable: a_socket.is_open_read + local + retried: BOOLEAN do - if a_socket.socket_ok then + if retried then + Result := Void + elseif a_socket.socket_ok then a_socket.read_line_thread_aware Result := a_socket.last_string end + rescue + retried := True + retry end feature -- Output diff --git a/library/server/ewsgi/connectors/httpd/src/httpd/httpd_server_i.e b/library/server/ewsgi/connectors/standalone/src/httpd/httpd_server_i.e similarity index 88% rename from library/server/ewsgi/connectors/httpd/src/httpd/httpd_server_i.e rename to library/server/ewsgi/connectors/standalone/src/httpd/httpd_server_i.e index 86205296..2c3d9c6c 100644 --- a/library/server/ewsgi/connectors/httpd/src/httpd/httpd_server_i.e +++ b/library/server/ewsgi/connectors/standalone/src/httpd/httpd_server_i.e @@ -58,6 +58,19 @@ feature -- Access factory: separate HTTPD_REQUEST_HANDLER_FACTORY + is_persistent_connection_supported: BOOLEAN = False + -- Is persistent connection supported? + --| For now, disabled during dev. + +feature -- Callbacks + + observer: detachable separate HTTPD_SERVER_OBSERVER + + set_observer (obs: like observer) + do + observer := obs + end + feature -- Access: listening port: INTEGER @@ -91,22 +104,10 @@ feature -- Execution end is_shutdown_requested := False listen + is_terminated := True on_terminated end - on_terminated - require - is_terminated - do - if is_terminated then - log ("%N%NTerminating Web Application Server (port="+ port.out +"):%N") - end - if attached output as o then - o.flush - o.close - end - end - shutdown_server do debug ("dbglog") @@ -251,8 +252,12 @@ feature -- Event require not_launched: not is_launched do +-- print ("port=" + a_port.out + "%N") is_launched := True port := a_port + if attached observer as obs then + observer_on_launched (obs, a_port) + end ensure is_launched: is_launched end @@ -262,10 +267,43 @@ feature -- Event require is_launched: is_launched do - is_launched := False - is_terminated := True - ensure - stopped: not is_launched + if attached observer as obs then + observer_on_stopped (obs) + end + end + + on_terminated + -- Server terminated + require + is_terminated + do + if is_terminated and is_verbose then + log ("%N%NTerminating Web Application Server (port="+ port.out +"):%N") + end + if attached output as o then + o.flush + o.close + end + if attached observer as obs then + observer_on_terminated (obs) + end + end + +feature {NONE} -- Separate event + + observer_on_launched (obs: attached like observer; a_port: INTEGER) + do + obs.on_launched (a_port) + end + + observer_on_stopped (obs: attached like observer) + do + obs.on_stopped + end + + observer_on_terminated (obs: attached like observer) + do + obs.on_terminated end feature -- Configuration change diff --git a/library/server/ewsgi/connectors/standalone/src/httpd/httpd_server_observer.e b/library/server/ewsgi/connectors/standalone/src/httpd/httpd_server_observer.e new file mode 100644 index 00000000..3c64c812 --- /dev/null +++ b/library/server/ewsgi/connectors/standalone/src/httpd/httpd_server_observer.e @@ -0,0 +1,24 @@ +note + description: "Summary description for {HTTPD_SERVER_OBSERVER}." + author: "" + date: "$Date$" + revision: "$Revision$" + +deferred class + HTTPD_SERVER_OBSERVER + +feature -- Event + + on_launched (a_port: INTEGER) + deferred + end + + on_stopped + deferred + end + + on_terminated + deferred + end + +end diff --git a/library/server/ewsgi/connectors/httpd/src/httpd/network/httpd_stream_socket.e b/library/server/ewsgi/connectors/standalone/src/httpd/network/httpd_stream_socket.e similarity index 100% rename from library/server/ewsgi/connectors/httpd/src/httpd/network/httpd_stream_socket.e rename to library/server/ewsgi/connectors/standalone/src/httpd/network/httpd_stream_socket.e diff --git a/library/server/ewsgi/connectors/httpd/src/httpd/network/tcp_stream_socket.e b/library/server/ewsgi/connectors/standalone/src/httpd/network/tcp_stream_socket.e similarity index 100% rename from library/server/ewsgi/connectors/httpd/src/httpd/network/tcp_stream_socket.e rename to library/server/ewsgi/connectors/standalone/src/httpd/network/tcp_stream_socket.e diff --git a/library/server/ewsgi/connectors/httpd/src/httpd/no_ssl/httpd_configuration.e b/library/server/ewsgi/connectors/standalone/src/httpd/no_ssl/httpd_configuration.e similarity index 100% rename from library/server/ewsgi/connectors/httpd/src/httpd/no_ssl/httpd_configuration.e rename to library/server/ewsgi/connectors/standalone/src/httpd/no_ssl/httpd_configuration.e diff --git a/library/server/ewsgi/connectors/httpd/src/httpd/no_ssl/httpd_server.e b/library/server/ewsgi/connectors/standalone/src/httpd/no_ssl/httpd_server.e similarity index 100% rename from library/server/ewsgi/connectors/httpd/src/httpd/no_ssl/httpd_server.e rename to library/server/ewsgi/connectors/standalone/src/httpd/no_ssl/httpd_server.e diff --git a/library/server/ewsgi/connectors/httpd/src/httpd/ssl/httpd_configuration.e b/library/server/ewsgi/connectors/standalone/src/httpd/ssl/httpd_configuration.e similarity index 100% rename from library/server/ewsgi/connectors/httpd/src/httpd/ssl/httpd_configuration.e rename to library/server/ewsgi/connectors/standalone/src/httpd/ssl/httpd_configuration.e diff --git a/library/server/ewsgi/connectors/httpd/src/httpd/ssl/httpd_server.e b/library/server/ewsgi/connectors/standalone/src/httpd/ssl/httpd_server.e similarity index 100% rename from library/server/ewsgi/connectors/httpd/src/httpd/ssl/httpd_server.e rename to library/server/ewsgi/connectors/standalone/src/httpd/ssl/httpd_server.e diff --git a/library/server/ewsgi/connectors/httpd/src/httpd/ssl/httpd_stream_ssl_socket.e b/library/server/ewsgi/connectors/standalone/src/httpd/ssl/httpd_stream_ssl_socket.e similarity index 100% rename from library/server/ewsgi/connectors/httpd/src/httpd/ssl/httpd_stream_ssl_socket.e rename to library/server/ewsgi/connectors/standalone/src/httpd/ssl/httpd_stream_ssl_socket.e diff --git a/library/server/ewsgi/connectors/httpd/src/httpd/ssl/ssl_tcp_stream_socket.e b/library/server/ewsgi/connectors/standalone/src/httpd/ssl/ssl_tcp_stream_socket.e similarity index 100% rename from library/server/ewsgi/connectors/httpd/src/httpd/ssl/ssl_tcp_stream_socket.e rename to library/server/ewsgi/connectors/standalone/src/httpd/ssl/ssl_tcp_stream_socket.e diff --git a/library/server/ewsgi/connectors/httpd/src/wgi_httpd_request_handler.e b/library/server/ewsgi/connectors/standalone/src/implementation/wgi_httpd_request_handler.e similarity index 92% rename from library/server/ewsgi/connectors/httpd/src/wgi_httpd_request_handler.e rename to library/server/ewsgi/connectors/standalone/src/implementation/wgi_httpd_request_handler.e index de6863ad..c709ec8d 100644 --- a/library/server/ewsgi/connectors/httpd/src/wgi_httpd_request_handler.e +++ b/library/server/ewsgi/connectors/standalone/src/implementation/wgi_httpd_request_handler.e @@ -26,9 +26,14 @@ feature {NONE} -- Initialization do make connector := conn +-- if conn /= Void then +-- set_is_verbose (is_connector_verbose (conn)) +-- end end - connector: detachable separate WGI_HTTPD_CONNECTOR [G] +feature -- Access + + connector: detachable separate WGI_STANDALONE_CONNECTOR [G] base: detachable IMMUTABLE_STRING_8 do @@ -39,11 +44,18 @@ feature {NONE} -- Initialization end end - connector_base (conn: separate WGI_HTTPD_CONNECTOR [G]): detachable separate READABLE_STRING_8 +feature -- SCOOP helpers + + connector_base (conn: separate WGI_STANDALONE_CONNECTOR [G]): detachable separate READABLE_STRING_8 do Result := conn.base end + is_connector_verbose (conn: separate WGI_STANDALONE_CONNECTOR [G]): BOOLEAN + do + Result := conn.is_verbose + end + feature -- Request processing process_request (a_socket: HTTPD_STREAM_SOCKET) @@ -53,14 +65,14 @@ feature -- Request processing l_output: WGI_OUTPUT_STREAM l_error: WGI_ERROR_STREAM req: WGI_REQUEST_FROM_TABLE - res: detachable WGI_HTTPD_RESPONSE_STREAM + res: detachable WGI_STANDALONE_RESPONSE_STREAM exec: detachable WGI_EXECUTION retried: BOOLEAN do if not retried then - create {WGI_HTTPD_INPUT_STREAM} l_input.make (a_socket) - create {WGI_HTTPD_OUTPUT_STREAM} l_output.make (a_socket) - create {WGI_HTTPD_ERROR_STREAM} l_error.make_stderr (a_socket.descriptor.out) + create {WGI_STANDALONE_INPUT_STREAM} l_input.make (a_socket) + create {WGI_STANDALONE_OUTPUT_STREAM} l_output.make (a_socket) + create {WGI_STANDALONE_ERROR_STREAM} l_error.make_stderr (a_socket.descriptor.out) create req.make (httpd_environment (a_socket), l_input, connector) create res.make (l_output, l_error) diff --git a/library/server/ewsgi/connectors/httpd/src/wgi_httpd_request_handler_factory.e b/library/server/ewsgi/connectors/standalone/src/implementation/wgi_httpd_request_handler_factory.e similarity index 93% rename from library/server/ewsgi/connectors/httpd/src/wgi_httpd_request_handler_factory.e rename to library/server/ewsgi/connectors/standalone/src/implementation/wgi_httpd_request_handler_factory.e index f69d0893..2570bc00 100644 --- a/library/server/ewsgi/connectors/httpd/src/wgi_httpd_request_handler_factory.e +++ b/library/server/ewsgi/connectors/standalone/src/implementation/wgi_httpd_request_handler_factory.e @@ -12,7 +12,7 @@ inherit feature -- Access - connector: detachable separate WGI_HTTPD_CONNECTOR [G] + connector: detachable separate WGI_STANDALONE_CONNECTOR [G] feature -- Element change diff --git a/library/server/ewsgi/connectors/httpd/src/wgi_httpd_connector.e b/library/server/ewsgi/connectors/standalone/src/wgi_standalone_connector.e similarity index 71% rename from library/server/ewsgi/connectors/httpd/src/wgi_httpd_connector.e rename to library/server/ewsgi/connectors/standalone/src/wgi_standalone_connector.e index 5f5f0b06..541b58a8 100644 --- a/library/server/ewsgi/connectors/httpd/src/wgi_httpd_connector.e +++ b/library/server/ewsgi/connectors/standalone/src/wgi_standalone_connector.e @@ -1,5 +1,5 @@ note - description: "Summary description for {WGI_HTTPD_CONNECTOR}." + description: "Summary description for {WGI_STANDALONE_CONNECTOR}." author: "" todo: "[ Check if server and configuration has to be 'separate' ? @@ -11,7 +11,7 @@ note revision: "$Revision$" class - WGI_HTTPD_CONNECTOR [G -> WGI_EXECUTION create make end] + WGI_STANDALONE_CONNECTOR [G -> WGI_EXECUTION create make end] inherit WGI_CONNECTOR @@ -28,14 +28,15 @@ feature {NONE} -- Initialization do -- Callbacks create on_launched_actions - create on_stopped_actions -- Server create fac create server.make (fac) + create observer configuration := server_configuration (server) - + controller := server_controller (server) set_factory_connector (Current, fac) + initialize_server (server) end make_with_base (a_base: like base) @@ -46,11 +47,23 @@ feature {NONE} -- Initialization set_base (a_base) end - set_factory_connector (conn: detachable separate WGI_HTTPD_CONNECTOR [G]; fac: separate WGI_HTTPD_REQUEST_HANDLER_FACTORY [G]) + initialize_server (a_server: like server) + do + a_server.set_observer (observer) + end + +feature {NONE} -- Separate helper + + set_factory_connector (conn: detachable separate WGI_STANDALONE_CONNECTOR [G]; fac: separate WGI_HTTPD_REQUEST_HANDLER_FACTORY [G]) do fac.set_connector (conn) end + server_configuration (a_server: like server): like configuration + do + Result := a_server.configuration + end + feature -- Access name: STRING_8 = "httpd" @@ -63,12 +76,11 @@ feature -- Access server: separate HTTPD_SERVER - configuration: separate HTTPD_CONFIGURATION + controller: separate HTTPD_CONTROLLER - server_configuration (a_server: like server): like configuration - do - Result := a_server.configuration - end + observer: separate WGI_STANDALONE_SERVER_OBSERVER + + configuration: separate HTTPD_CONFIGURATION feature -- Access @@ -82,17 +94,17 @@ feature -- Status report port: INTEGER -- Listening port. - --| 0: not launched + --| 0: not launched + + is_verbose: BOOLEAN + -- Is verbose? feature -- Callbacks - on_launched_actions: ACTION_SEQUENCE [TUPLE [WGI_CONNECTOR]] + on_launched_actions: ACTION_SEQUENCE [TUPLE [WGI_STANDALONE_CONNECTOR [WGI_EXECUTION]]] -- Actions triggered when launched - on_stopped_actions: ACTION_SEQUENCE [TUPLE [WGI_CONNECTOR]] - -- Actions triggered when stopped - -feature -- Element change +feature -- Event on_launched (a_port: INTEGER) -- Server launched @@ -102,14 +114,6 @@ feature -- Element change on_launched_actions.call ([Current]) end - on_stopped - -- Server stopped - do - on_stopped_actions.call ([Current]) - launched := False - port := 0 - end - feature -- Element change set_base (b: like base) @@ -154,6 +158,7 @@ feature {NONE} -- Implementation set_is_verbose_on_configuration (b: BOOLEAN; cfg: like configuration) do + is_verbose := b cfg.set_is_verbose (b) end @@ -164,6 +169,29 @@ feature -- Server launched := False port := 0 launch_server (server) + on_server_started (observer) + end + + shutdown_server + do + if launched then + -- FIXME jfiat [2015/03/27] : prevent multiple calls (otherwise it hangs) + separate_shutdown_server_on_controller (controller) + end + end + + server_controller (a_server: like server): separate HTTPD_CONTROLLER + do + Result := a_server.controller + end + + on_server_started (obs: like observer) + require + obs.started + do + if obs.port > 0 then + on_launched (obs.port) + end end configure_server (a_configuration: like configuration) @@ -181,6 +209,19 @@ feature -- Server a_server.launch end +feature {NONE} -- Implementation + + separate_server_terminated (a_server: like server): BOOLEAN + do + Result := a_server.is_terminated + end + + separate_shutdown_server_on_controller (a_controller: separate HTTPD_CONTROLLER) + do + a_controller.shutdown + end + + note copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" diff --git a/library/server/ewsgi/connectors/httpd/src/wgi_httpd_error_stream.e b/library/server/ewsgi/connectors/standalone/src/wgi_standalone_error_stream.e similarity index 87% rename from library/server/ewsgi/connectors/httpd/src/wgi_httpd_error_stream.e rename to library/server/ewsgi/connectors/standalone/src/wgi_standalone_error_stream.e index 3cb84e31..8c48d2ab 100644 --- a/library/server/ewsgi/connectors/httpd/src/wgi_httpd_error_stream.e +++ b/library/server/ewsgi/connectors/standalone/src/wgi_standalone_error_stream.e @@ -1,12 +1,12 @@ note - description: "Summary description for WGI_HTTPD_ERROR_STREAM." + description: "Summary description for WGI_STANDALONE_ERROR_STREAM." legal: "See notice at end of class." status: "See notice at end of class." date: "$Date$" revision: "$Revision$" class - WGI_HTTPD_ERROR_STREAM + WGI_STANDALONE_ERROR_STREAM inherit WGI_ERROR_STREAM @@ -58,7 +58,7 @@ feature -- Error end note - copyright: "2011-2011, Eiffel Software and others" + copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/server/ewsgi/connectors/httpd/src/wgi_httpd_input_stream.e b/library/server/ewsgi/connectors/standalone/src/wgi_standalone_input_stream.e similarity index 92% rename from library/server/ewsgi/connectors/httpd/src/wgi_httpd_input_stream.e rename to library/server/ewsgi/connectors/standalone/src/wgi_standalone_input_stream.e index ce34a558..fbfa2b0b 100644 --- a/library/server/ewsgi/connectors/httpd/src/wgi_httpd_input_stream.e +++ b/library/server/ewsgi/connectors/standalone/src/wgi_standalone_input_stream.e @@ -1,12 +1,12 @@ note - description: "Summary description for {WGI_HTTPD_INPUT_STREAM}." + description: "Summary description for {WGI_STANDALONE_INPUT_STREAM}." legal: "See notice at end of class." status: "See notice at end of class." date: "$Date$" revision: "$Revision$" class - WGI_HTTPD_INPUT_STREAM + WGI_STANDALONE_INPUT_STREAM inherit WGI_INPUT_STREAM @@ -22,7 +22,7 @@ feature {NONE} -- Initialization set_source (a_source) end -feature {WGI_HTTPD_CONNECTOR, WGI_SERVICE} -- Nino +feature {WGI_STANDALONE_CONNECTOR, WGI_SERVICE} -- Nino set_source (i: like source) do diff --git a/library/server/ewsgi/connectors/httpd/src/wgi_httpd_output_stream.e b/library/server/ewsgi/connectors/standalone/src/wgi_standalone_output_stream.e similarity index 92% rename from library/server/ewsgi/connectors/httpd/src/wgi_httpd_output_stream.e rename to library/server/ewsgi/connectors/standalone/src/wgi_standalone_output_stream.e index c581bc79..b5ca291e 100644 --- a/library/server/ewsgi/connectors/httpd/src/wgi_httpd_output_stream.e +++ b/library/server/ewsgi/connectors/standalone/src/wgi_standalone_output_stream.e @@ -1,12 +1,12 @@ note - description: "Summary description for {WGI_HTTPD_OUTPUT_STREAM}." + description: "Summary description for {WGI_STANDALONE_OUTPUT_STREAM}." legal: "See notice at end of class." status: "See notice at end of class." date: "$Date$" revision: "$Revision$" class - WGI_HTTPD_OUTPUT_STREAM + WGI_STANDALONE_OUTPUT_STREAM inherit WGI_OUTPUT_STREAM @@ -26,7 +26,7 @@ feature {NONE} -- Initialization set_target (a_target) end -feature {WGI_HTTPD_CONNECTOR, WGI_SERVICE} -- Nino +feature {WGI_STANDALONE_CONNECTOR, WGI_SERVICE} -- Nino set_target (o: like target) do diff --git a/library/server/ewsgi/connectors/httpd/src/wgi_httpd_response_stream.e b/library/server/ewsgi/connectors/standalone/src/wgi_standalone_response_stream.e similarity index 72% rename from library/server/ewsgi/connectors/httpd/src/wgi_httpd_response_stream.e rename to library/server/ewsgi/connectors/standalone/src/wgi_standalone_response_stream.e index acc8a3cd..9c9ab699 100644 --- a/library/server/ewsgi/connectors/httpd/src/wgi_httpd_response_stream.e +++ b/library/server/ewsgi/connectors/standalone/src/wgi_standalone_response_stream.e @@ -7,7 +7,7 @@ note revision: "$Revision$" class - WGI_HTTPD_RESPONSE_STREAM + WGI_STANDALONE_RESPONSE_STREAM inherit WGI_RESPONSE_STREAM @@ -27,9 +27,11 @@ feature -- Header output operation o := output o.put_string (a_text) - -- Nino does not support persistent connection for now - o.put_string ("Connection: close") - o.put_crlf + if not {HTTPD_SERVER}.is_persistent_connection_supported then + -- standalone does not support persistent connection for now + o.put_string ("Connection: close") + o.put_crlf + end -- end of headers o.put_crlf @@ -38,7 +40,7 @@ feature -- Header output operation end ;note - copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" + copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/server/ewsgi/connectors/httpd/dev/app_wsf_httpd_request_handler.e b/library/server/ewsgi/connectors/standalone/src/wgi_standalone_server_observer.e similarity index 53% rename from library/server/ewsgi/connectors/httpd/dev/app_wsf_httpd_request_handler.e rename to library/server/ewsgi/connectors/standalone/src/wgi_standalone_server_observer.e index e2c3c00f..b36d0fb7 100644 --- a/library/server/ewsgi/connectors/httpd/dev/app_wsf_httpd_request_handler.e +++ b/library/server/ewsgi/connectors/standalone/src/wgi_standalone_server_observer.e @@ -1,28 +1,45 @@ note - description: "Summary description for {APP_WSF_HTTPD_REQUEST_HANDLER}." + description: "Summary description for {WGI_STANDALONE_SERVER_OBSERVER}." author: "" date: "$Date$" revision: "$Revision$" class - APP_WSF_HTTPD_REQUEST_HANDLER + WGI_STANDALONE_SERVER_OBSERVER inherit - WSF_HTTPD_REQUEST_HANDLER + HTTPD_SERVER_OBSERVER -create - make +feature -- Access -feature -- Execute + started: BOOLEAN - do_more (req: WGI_REQUEST; res: WGI_RESPONSE) - local - exec: WSF_EXECUTION + stopped: BOOLEAN + + terminated: BOOLEAN + + port: INTEGER + +feature -- Event + + on_launched (a_port: INTEGER) do - create {APP_WSF_EXECUTION} exec.make (req, res) - exec.execute + started := True + port := a_port end + on_stopped + do + stopped := True + end + + on_terminated + do + port := 0 + terminated := True + end + + note copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" diff --git a/library/server/ewsgi/connectors/httpd/httpd-safe.ecf b/library/server/ewsgi/connectors/standalone/standalone-safe.ecf similarity index 68% rename from library/server/ewsgi/connectors/httpd/httpd-safe.ecf rename to library/server/ewsgi/connectors/standalone/standalone-safe.ecf index 0213ebef..acf1c95f 100644 --- a/library/server/ewsgi/connectors/httpd/httpd-safe.ecf +++ b/library/server/ewsgi/connectors/standalone/standalone-safe.ecf @@ -1,13 +1,13 @@ - - + + /EIFGENs$ /\.git$ /\.svn$ - @@ -16,16 +16,14 @@ - - - - /httpd$ - + + + - + - @@ -33,10 +31,10 @@ - + - + diff --git a/library/server/ewsgi/connectors/standalone/standalone.ecf b/library/server/ewsgi/connectors/standalone/standalone.ecf new file mode 100644 index 00000000..3349c7ec --- /dev/null +++ b/library/server/ewsgi/connectors/standalone/standalone.ecf @@ -0,0 +1,23 @@ + + + + + + /EIFGENs$ + /\.git$ + /\.svn$ + + + + + + + + + + + + diff --git a/library/server/ewsgi/examples/hello_world/src/hello_world.e b/library/server/ewsgi/examples/hello_world/src/hello_world.e index d66c934d..b48667eb 100644 --- a/library/server/ewsgi/examples/hello_world/src/hello_world.e +++ b/library/server/ewsgi/examples/hello_world/src/hello_world.e @@ -18,20 +18,13 @@ feature {NONE} -- Initialization make do print ("Example: start a Nino web server on port " + port_number.out + ", %Nand reply Hello World for any request such as http://localhost:8123/%N") - (create {NINO_SERVICE}.make_custom (Current, "")).listen (port_number) - end - - execute (req: WGI_REQUEST; res: WGI_RESPONSE) - do - res.set_status_code (200, Void) - res.put_header_text ("Content-Type: text/plain%R%N") - res.put_string ("Hello World!%N") + (create {NINO_SERVICE [HELLO_WORLD_EXECUTION]}.make_custom ("")).listen (port_number) end port_number: INTEGER = 8123 note - copyright: "2011-2012, Eiffel Software and others" + copyright: "2011-2015, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/server/ewsgi/examples/hello_world/src/hello_world_execution.e b/library/server/ewsgi/examples/hello_world/src/hello_world_execution.e new file mode 100644 index 00000000..5ecbc814 --- /dev/null +++ b/library/server/ewsgi/examples/hello_world/src/hello_world_execution.e @@ -0,0 +1,36 @@ +note + description: "Summary description for {HELLO_WORLD_EXECUTION}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + HELLO_WORLD_EXECUTION + +inherit + WGI_EXECUTION + +create + make + +feature {NONE} -- Initialization + + execute + do + response.set_status_code (200, Void) + response.put_header_text ("Content-Type: text/plain%R%N") + response.put_string ("Hello World!%N") + end + +note + copyright: "2011-2015, 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 + ]" +end + diff --git a/library/server/wsf/default/nino/wsf_default_response_service.e b/library/server/ewsgi/specification/connector/wgi_execution_factory.e similarity index 68% rename from library/server/wsf/default/nino/wsf_default_response_service.e rename to library/server/ewsgi/specification/connector/wgi_execution_factory.e index db3fddc6..d0df1af0 100644 --- a/library/server/wsf/default/nino/wsf_default_response_service.e +++ b/library/server/ewsgi/specification/connector/wgi_execution_factory.e @@ -1,15 +1,17 @@ note - description: "Summary description for {WSF_DEFAULT_RESPONSE_SERVICE}." + description: "Summary description for {WGI_EXECUTION_FACTORY}." + author: "" date: "$Date$" revision: "$Revision$" deferred class - WSF_DEFAULT_RESPONSE_SERVICE [G -> WSF_EXECUTION create make end] + WGI_EXECUTION_FACTORY -inherit - WSF_DEFAULT_SERVICE [G] +feature -- Factory - WSF_RESPONSE_SERVICE [G] + execution (req: WGI_REQUEST; res: WGI_RESPONSE): WGI_EXECUTION + deferred + end note copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" diff --git a/library/server/ewsgi/specification/request/wgi_request_cgi_variables.e b/library/server/ewsgi/specification/request/wgi_request_cgi_variables.e index a969dfad..cd588e35 100644 --- a/library/server/ewsgi/specification/request/wgi_request_cgi_variables.e +++ b/library/server/ewsgi/specification/request/wgi_request_cgi_variables.e @@ -22,13 +22,13 @@ feature {NONE} -- Initialization local utf: UTF_CONVERTER do - auth_type := req.auth_type content_length := req.content_length if attached req.content_type as ct then content_type := ct.string else content_type := Void end + auth_type := req.auth_type gateway_interface := req.gateway_interface path_info := req.path_info path_translated := req.path_translated diff --git a/library/server/wsf/connector/openshift/wsf_openshift_service_launcher.e b/library/server/wsf/connector/openshift/wsf_openshift_service_launcher.e index 5e262ae9..4fe7c19b 100644 --- a/library/server/wsf/connector/openshift/wsf_openshift_service_launcher.e +++ b/library/server/wsf/connector/openshift/wsf_openshift_service_launcher.e @@ -16,10 +16,10 @@ note revision: "$Revision$" class - WSF_OPENSHIFT_SERVICE_LAUNCHER + WSF_OPENSHIFT_SERVICE_LAUNCHER [G -> WSF_EXECUTION create make end] inherit - WSF_NINO_SERVICE_LAUNCHER + WSF_NINO_SERVICE_LAUNCHER [G] redefine initialize end @@ -31,9 +31,7 @@ inherit create make, - make_and_launch, - make_callback, - make_callback_and_launch + make_and_launch feature {NONE} -- Initialization @@ -86,7 +84,7 @@ feature {NONE} -- Implementation ;note - copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" + copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/server/wsf/connector/httpd-safe.ecf b/library/server/wsf/connector/standalone-safe.ecf similarity index 77% rename from library/server/wsf/connector/httpd-safe.ecf rename to library/server/wsf/connector/standalone-safe.ecf index c5d577f6..7ad62d20 100644 --- a/library/server/wsf/connector/httpd-safe.ecf +++ b/library/server/wsf/connector/standalone-safe.ecf @@ -1,6 +1,6 @@ - - + + /EIFGENs$ @@ -10,13 +10,13 @@ - + - + diff --git a/library/server/wsf/connector/standalone.ecf b/library/server/wsf/connector/standalone.ecf new file mode 100644 index 00000000..63d5cd22 --- /dev/null +++ b/library/server/wsf/connector/standalone.ecf @@ -0,0 +1,22 @@ + + + + + + /EIFGENs$ + /\.git$ + /\.svn$ + + + + + + + + + + + + + diff --git a/library/server/wsf/connector/httpd/wsf_httpd_service_launcher.e b/library/server/wsf/connector/standalone/wsf_standalone_service_launcher.e similarity index 85% rename from library/server/wsf/connector/httpd/wsf_httpd_service_launcher.e rename to library/server/wsf/connector/standalone/wsf_standalone_service_launcher.e index 6738c80f..006a23ee 100644 --- a/library/server/wsf/connector/httpd/wsf_httpd_service_launcher.e +++ b/library/server/wsf/connector/standalone/wsf_standalone_service_launcher.e @@ -8,8 +8,8 @@ note The httpd default connector support options: port: numeric such as 8099 (or equivalent string as "8099") base: base_url (very specific to standalone server) - verbose: to display verbose output, useful for Nino - force_single_threaded: use only one thread, useful for Nino + verbose: to display verbose output, useful for standalone connector + force_single_threaded: use only one thread, useful for standalone connector check WSF_SERVICE_LAUNCHER for more documentation ]" @@ -17,7 +17,7 @@ note revision: "$Revision$" class - WSF_HTTPD_SERVICE_LAUNCHER [G -> WSF_EXECUTION create make end] + WSF_STANDALONE_SERVICE_LAUNCHER [G -> WSF_EXECUTION create make end] inherit WSF_SERVICE_LAUNCHER [G] @@ -71,7 +71,6 @@ feature {NONE} -- Initialization create conn.make connector := conn conn.on_launched_actions.extend (agent on_launched) - conn.on_stopped_actions.extend (agent on_stopped) conn.set_base (base_url) update_configuration (conn.configuration) @@ -88,7 +87,6 @@ feature -- Execution if attached server_name as l_server_name then cfg.set_http_server_name (l_server_name) end --- conn.set_port_number (port_number) cfg.http_server_port := port_number end @@ -102,7 +100,7 @@ feature -- Execution conn.set_base (base_url) debug ("nino") if verbose then - io.error.put_string ("Launching Nino web server on port " + port_number.out) + io.error.put_string ("Launching standalone web server on port " + port_number.out) if attached server_name as l_name then io.error.put_string ("%N http://" + l_name + ":" + port_number.out + "/" + base_url + "%N") else @@ -116,24 +114,19 @@ feature -- Execution feature -- Callback - on_launched_actions: ACTION_SEQUENCE [TUPLE [WGI_CONNECTOR]] + on_launched_actions: ACTION_SEQUENCE [TUPLE [WGI_STANDALONE_CONNECTOR [G]]] -- Actions triggered when launched - on_stopped_actions: ACTION_SEQUENCE [TUPLE [WGI_CONNECTOR]] + on_stopped_actions: ACTION_SEQUENCE [TUPLE [WGI_STANDALONE_CONNECTOR [G]]] -- Actions triggered when stopped feature {NONE} -- Implementation - on_launched (conn: WGI_CONNECTOR) + on_launched (conn: WGI_STANDALONE_CONNECTOR [G]) do on_launched_actions.call ([conn]) end - on_stopped (conn: WGI_CONNECTOR) - do - on_stopped_actions.call ([conn]) - end - port_number: INTEGER server_name: detachable READABLE_STRING_8 @@ -146,7 +139,7 @@ feature {NONE} -- Implementation feature -- Status report - connector: WGI_HTTPD_CONNECTOR [G] + connector: WGI_STANDALONE_CONNECTOR [G] -- Default connector launchable: BOOLEAN diff --git a/library/server/wsf/default/cgi/wsf_default_response_service.e b/library/server/wsf/default/cgi/wsf_default_response_service.e deleted file mode 100644 index 0cefc7da..00000000 --- a/library/server/wsf/default/cgi/wsf_default_response_service.e +++ /dev/null @@ -1,24 +0,0 @@ -note - description: "Summary description for {WSF_DEFAULT_RESPONSE_SERVICE}." - date: "$Date$" - revision: "$Revision$" - -deferred class - WSF_DEFAULT_RESPONSE_SERVICE - -inherit - WSF_DEFAULT_SERVICE - - WSF_RESPONSE_SERVICE - -note - copyright: "2011-2012, 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 - ]" -end diff --git a/library/server/wsf/default/cgi/wsf_default_service.e b/library/server/wsf/default/cgi/wsf_default_service.e index dd76ca78..a19fb656 100644 --- a/library/server/wsf/default/cgi/wsf_default_service.e +++ b/library/server/wsf/default/cgi/wsf_default_service.e @@ -4,13 +4,13 @@ note revision: "$Revision$" deferred class - WSF_DEFAULT_SERVICE + WSF_DEFAULT_SERVICE [G -> WSF_EXECUTION create make end] inherit - WSF_DEFAULT_SERVICE_I [WSF_DEFAULT_SERVICE_LAUNCHER] + WSF_DEFAULT_SERVICE_I [WSF_DEFAULT_SERVICE_LAUNCHER [G]] note - copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" + copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/server/wsf/default/httpd/wsf_default_response_service.e b/library/server/wsf/default/httpd/wsf_default_response_service.e deleted file mode 100644 index 0cefc7da..00000000 --- a/library/server/wsf/default/httpd/wsf_default_response_service.e +++ /dev/null @@ -1,24 +0,0 @@ -note - description: "Summary description for {WSF_DEFAULT_RESPONSE_SERVICE}." - date: "$Date$" - revision: "$Revision$" - -deferred class - WSF_DEFAULT_RESPONSE_SERVICE - -inherit - WSF_DEFAULT_SERVICE - - WSF_RESPONSE_SERVICE - -note - copyright: "2011-2012, 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 - ]" -end diff --git a/library/server/wsf/default/libfcgi/wsf_default_response_service.e b/library/server/wsf/default/libfcgi/wsf_default_response_service.e deleted file mode 100644 index 0cefc7da..00000000 --- a/library/server/wsf/default/libfcgi/wsf_default_response_service.e +++ /dev/null @@ -1,24 +0,0 @@ -note - description: "Summary description for {WSF_DEFAULT_RESPONSE_SERVICE}." - date: "$Date$" - revision: "$Revision$" - -deferred class - WSF_DEFAULT_RESPONSE_SERVICE - -inherit - WSF_DEFAULT_SERVICE - - WSF_RESPONSE_SERVICE - -note - copyright: "2011-2012, 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 - ]" -end diff --git a/library/server/wsf/default/libfcgi/wsf_default_service.e b/library/server/wsf/default/libfcgi/wsf_default_service.e index dd76ca78..a19fb656 100644 --- a/library/server/wsf/default/libfcgi/wsf_default_service.e +++ b/library/server/wsf/default/libfcgi/wsf_default_service.e @@ -4,13 +4,13 @@ note revision: "$Revision$" deferred class - WSF_DEFAULT_SERVICE + WSF_DEFAULT_SERVICE [G -> WSF_EXECUTION create make end] inherit - WSF_DEFAULT_SERVICE_I [WSF_DEFAULT_SERVICE_LAUNCHER] + WSF_DEFAULT_SERVICE_I [WSF_DEFAULT_SERVICE_LAUNCHER [G]] note - copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" + copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/server/wsf/default/libfcgi/wsf_default_service_launcher.e b/library/server/wsf/default/libfcgi/wsf_default_service_launcher.e index 82189381..99f302ce 100644 --- a/library/server/wsf/default/libfcgi/wsf_default_service_launcher.e +++ b/library/server/wsf/default/libfcgi/wsf_default_service_launcher.e @@ -5,19 +5,17 @@ note revision: "$Revision$" class - WSF_DEFAULT_SERVICE_LAUNCHER + WSF_DEFAULT_SERVICE_LAUNCHER [G -> WSF_EXECUTION create make end] inherit - WSF_LIBFCGI_SERVICE_LAUNCHER + WSF_LIBFCGI_SERVICE_LAUNCHER [G] create make, - make_and_launch, - make_callback, - make_callback_and_launch + make_and_launch note - copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" + copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/server/wsf/default/openshift/wsf_default_response_service.e b/library/server/wsf/default/openshift/wsf_default_response_service.e deleted file mode 100644 index 0cefc7da..00000000 --- a/library/server/wsf/default/openshift/wsf_default_response_service.e +++ /dev/null @@ -1,24 +0,0 @@ -note - description: "Summary description for {WSF_DEFAULT_RESPONSE_SERVICE}." - date: "$Date$" - revision: "$Revision$" - -deferred class - WSF_DEFAULT_RESPONSE_SERVICE - -inherit - WSF_DEFAULT_SERVICE - - WSF_RESPONSE_SERVICE - -note - copyright: "2011-2012, 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 - ]" -end diff --git a/library/server/wsf/default/openshift/wsf_default_service.e b/library/server/wsf/default/openshift/wsf_default_service.e index dd76ca78..a19fb656 100644 --- a/library/server/wsf/default/openshift/wsf_default_service.e +++ b/library/server/wsf/default/openshift/wsf_default_service.e @@ -4,13 +4,13 @@ note revision: "$Revision$" deferred class - WSF_DEFAULT_SERVICE + WSF_DEFAULT_SERVICE [G -> WSF_EXECUTION create make end] inherit - WSF_DEFAULT_SERVICE_I [WSF_DEFAULT_SERVICE_LAUNCHER] + WSF_DEFAULT_SERVICE_I [WSF_DEFAULT_SERVICE_LAUNCHER [G]] note - copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" + copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/server/wsf/default/openshift/wsf_default_service_launcher.e b/library/server/wsf/default/openshift/wsf_default_service_launcher.e index a648940a..f0b14177 100644 --- a/library/server/wsf/default/openshift/wsf_default_service_launcher.e +++ b/library/server/wsf/default/openshift/wsf_default_service_launcher.e @@ -6,19 +6,17 @@ note revision: "$Revision$" class - WSF_DEFAULT_SERVICE_LAUNCHER + WSF_DEFAULT_SERVICE_LAUNCHER [G -> WSF_EXECUTION create make end] inherit - WSF_OPENSHIFT_SERVICE_LAUNCHER + WSF_OPENSHIFT_SERVICE_LAUNCHER [G] create make, - make_and_launch, - make_callback, - make_callback_and_launch + make_and_launch note - copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" + copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/server/wsf/default/httpd-safe.ecf b/library/server/wsf/default/standalone-safe.ecf similarity index 69% rename from library/server/wsf/default/httpd-safe.ecf rename to library/server/wsf/default/standalone-safe.ecf index c60d7c8e..9716756e 100644 --- a/library/server/wsf/default/httpd-safe.ecf +++ b/library/server/wsf/default/standalone-safe.ecf @@ -1,6 +1,6 @@ - - + + /EIFGENs$ @@ -11,7 +11,7 @@ - - + + diff --git a/library/server/wsf/default/standalone.ecf b/library/server/wsf/default/standalone.ecf new file mode 100644 index 00000000..918b7a99 --- /dev/null +++ b/library/server/wsf/default/standalone.ecf @@ -0,0 +1,17 @@ + + + + + + /EIFGENs$ + /\.git$ + /\.svn$ + + + + + + + + diff --git a/library/server/wsf/default/httpd/wsf_default_service.e b/library/server/wsf/default/standalone/wsf_default_service.e similarity index 100% rename from library/server/wsf/default/httpd/wsf_default_service.e rename to library/server/wsf/default/standalone/wsf_default_service.e diff --git a/library/server/wsf/default/httpd/wsf_default_service_launcher.e b/library/server/wsf/default/standalone/wsf_default_service_launcher.e similarity index 82% rename from library/server/wsf/default/httpd/wsf_default_service_launcher.e rename to library/server/wsf/default/standalone/wsf_default_service_launcher.e index 3a91dafd..65c07c38 100644 --- a/library/server/wsf/default/httpd/wsf_default_service_launcher.e +++ b/library/server/wsf/default/standalone/wsf_default_service_launcher.e @@ -1,6 +1,6 @@ note description: "[ - Default launcher for WSF_SERVICE based on {WSF_HTTPD_SERVICE_LAUNCHER} + Default launcher for WSF_SERVICE based on {WSF_STANDALONE_SERVICE_LAUNCHER} ]" date: "$Date$" revision: "$Revision$" @@ -9,7 +9,7 @@ class WSF_DEFAULT_SERVICE_LAUNCHER [G -> WSF_EXECUTION create make end] inherit - WSF_HTTPD_SERVICE_LAUNCHER [G] + WSF_STANDALONE_SERVICE_LAUNCHER [G] create make, diff --git a/library/server/wsf/router/filter/wsf_filtered_execution.e b/library/server/wsf/router/filter/wsf_filtered_execution.e new file mode 100644 index 00000000..eb2bd534 --- /dev/null +++ b/library/server/wsf/router/filter/wsf_filtered_execution.e @@ -0,0 +1,92 @@ +note + description: "Summary description for {WSF_FILTERED_EXECUTION}." + author: "" + date: "$Date$" + revision: "$Revision$" + +deferred class + WSF_FILTERED_EXECUTION + +inherit + WSF_EXECUTION + redefine + initialize + end + +feature {NONE} -- Initialization + + initialize + do + Precursor + initialize_filter + end + + initialize_filter + -- Initialize `filter' + do + create_filter + setup_filter + end + + create_filter + -- Create `filter' + deferred + ensure + filter_created: filter /= Void + end + + setup_filter + -- Setup `filter' + require + filter_created: filter /= Void + deferred + end + + append_filters (a_filters: ITERABLE [WSF_FILTER]) + -- Append collection `a_filters' of filters to the end of the `filter' chain. + local + f: like filter + l_next_filter: detachable like filter + do + from + f := filter + l_next_filter := f.next + until + l_next_filter = Void + loop + f := l_next_filter + l_next_filter := f.next + end + check f_attached_without_next: f /= Void and then f.next = Void end + across + a_filters as ic + loop + l_next_filter := ic.item + f.set_next (l_next_filter) + f := l_next_filter + end + end + +feature -- Access + + filter: WSF_FILTER + -- Filter + +feature -- Execution + + execute + do + filter.execute (request, response) + end + +;note + copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, 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 + ]" +end diff --git a/library/server/wsf/router/policy/service/wsf_routed_skeleton_execution.e b/library/server/wsf/router/policy/service/wsf_routed_skeleton_execution.e index 7daacd25..8a0a4792 100644 --- a/library/server/wsf/router/policy/service/wsf_routed_skeleton_execution.e +++ b/library/server/wsf/router/policy/service/wsf_routed_skeleton_execution.e @@ -48,7 +48,7 @@ feature -- Execution create l_sess router.dispatch (req, res, l_sess) if not l_sess.dispatched then - execute_default + execute_default (req, res) end end end @@ -279,7 +279,7 @@ invariant unavailability_duration_xor_unavailable_until: unavailability_duration > 0 implies unavailable_until = Void ;note - copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others" + copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/server/wsf/router/wsf_filtered_routed_execution.e b/library/server/wsf/router/wsf_filtered_routed_execution.e new file mode 100644 index 00000000..68129add --- /dev/null +++ b/library/server/wsf/router/wsf_filtered_routed_execution.e @@ -0,0 +1,68 @@ +note + description: "[ + Execution which is first filtered, and then pass to the router + ]" + date: "$Date$" + revision: "$Revision$" + +deferred class + WSF_FILTERED_ROUTED_EXECUTION + +inherit + WSF_FILTERED_EXECUTION + redefine + initialize + end + + WSF_ROUTED_EXECUTION + undefine + execute + redefine + initialize + end + + WSF_FILTER + rename + execute as filter_execute + end + +feature {NONE} -- Initialize + + initialize + local + f: like filter + do + Precursor {WSF_ROUTED_EXECUTION} + Precursor {WSF_FILTERED_EXECUTION} + -- Current is a WSF_FILTER as well in order to call the router + -- let's add Current at the end of the filter chain. + from + f := filter + until + not attached f.next as l_next + loop + f := l_next + end + f.set_next (Current) + end + +feature -- Execute Filter + + filter_execute (req: WSF_REQUEST; res: WSF_RESPONSE) + -- Execute the filter. + do + router_execute (req, res) + end + +note + copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, 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 + ]" + +end diff --git a/library/server/wsf/router/wsf_routed_execution.e b/library/server/wsf/router/wsf_routed_execution.e index 40581dcc..7b2d693a 100644 --- a/library/server/wsf/router/wsf_routed_execution.e +++ b/library/server/wsf/router/wsf_routed_execution.e @@ -7,6 +7,20 @@ note deferred class WSF_ROUTED_EXECUTION +inherit + WSF_EXECUTION + redefine + initialize + end + +feature {NONE} -- Initialize + + initialize + do + Precursor + initialize_router + end + feature -- Router initialize_router @@ -34,14 +48,6 @@ feature -- Router feature -- Access - request: WSF_REQUEST - deferred - end - - response: WSF_RESPONSE - deferred - end - router: WSF_ROUTER -- Router used to dispatch the request according to the WSF_REQUEST object -- and associated request methods @@ -51,19 +57,22 @@ feature -- Execution execute -- Dispatch the request -- and if handler is not found, execute the default procedure `execute_default'. + do + router_execute (request, response) + end + + router_execute (req: WSF_REQUEST; res: WSF_RESPONSE) local sess: WSF_ROUTER_SESSION do create sess - router.dispatch (request, response, sess) + router.dispatch (req, res, sess) if not sess.dispatched then - execute_default + execute_default (req, res) end - ensure - response_status_is_set: response.status_is_set end - execute_default + execute_default (req: WSF_REQUEST; res: WSF_RESPONSE) -- Dispatch requests without a matching handler. local msg: WSF_DEFAULT_ROUTER_RESPONSE @@ -73,4 +82,14 @@ feature -- Execution response.send (msg) end +note + copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, 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 + ]" end diff --git a/library/server/wsf/src/service/wsf_response_service.e b/library/server/wsf/src/wsf_execution_factory.e similarity index 50% rename from library/server/wsf/src/service/wsf_response_service.e rename to library/server/wsf/src/wsf_execution_factory.e index 5b375e19..04be7117 100644 --- a/library/server/wsf/src/service/wsf_response_service.e +++ b/library/server/wsf/src/wsf_execution_factory.e @@ -1,31 +1,22 @@ note - description: "[ - Inherit from this class to implement the main entry of your web service - You just need to implement `execute', get data from the request `req' - and return a response message - ]" + description: "Summary description for {WSF_EXECUTION_FACTORY}." + author: "" date: "$Date$" revision: "$Revision$" deferred class - WSF_RESPONSE_SERVICE [G -> WSF_EXECUTION create make end] + WSF_EXECUTION_FACTORY inherit - WSF_SERVICE - -feature -- Response - - response (req: WSF_REQUEST): WSF_RESPONSE_MESSAGE - deferred - ensure - Result_attached: Result /= Void + WGI_EXECUTION_FACTORY + redefine + execution end -feature -- Execution +feature -- Factory - execute (req: WSF_REQUEST; res: WSF_RESPONSE) - do - res.send (response (req)) + execution (req: WGI_REQUEST; res: WGI_RESPONSE): WSF_EXECUTION + deferred end note diff --git a/library/server/wsf/src/wsf_response.e b/library/server/wsf/src/wsf_response.e index d7964568..32922fa1 100644 --- a/library/server/wsf/src/wsf_response.e +++ b/library/server/wsf/src/wsf_response.e @@ -19,7 +19,7 @@ note class WSF_RESPONSE -create {WSF_TO_WGI_SERVICE, WSF_EXECUTION, WGI_EXPORTER} +create {WSF_EXECUTION, WGI_EXPORTER} make_from_wgi create {WSF_RESPONSE} diff --git a/library/server/wsf/tests/echo/src/echo_server.e b/library/server/wsf/tests/echo/src/echo_server.e index 0ff1a36b..efc71879 100644 --- a/library/server/wsf/tests/echo/src/echo_server.e +++ b/library/server/wsf/tests/echo/src/echo_server.e @@ -8,7 +8,7 @@ class ECHO_SERVER inherit - WSF_DEFAULT_SERVICE + WSF_DEFAULT_SERVICE [ECHO_SERVER_EXECUTION] create make @@ -23,53 +23,4 @@ feature {NONE} -- Initialization make_and_launch end -feature -- Execution - - execute (req: WSF_REQUEST; res: WSF_RESPONSE) - local - page: WSF_PAGE_RESPONSE - l_body: STRING_8 - do - create l_body.make (1024) - create page.make_with_body (l_body) - page.header.put_content_type_text_plain - - l_body.append ("REQUEST_METHOD=" + req.request_method + "%N") - l_body.append ("REQUEST_URI=" + req.request_uri + "%N") - l_body.append ("PATH_INFO=" + req.path_info + "%N") - l_body.append ("QUERY_STRING=" + req.query_string + "%N") - - l_body.append ("Query parameters:%N") - across - req.query_parameters as q - loop - l_body.append ("%T"+ q.item.name + "=" + q.item.string_representation +"%N") - end - - l_body.append ("Form parameters:%N") - across - req.form_parameters as q - loop - l_body.append ("%T"+ q.item.name + "=" + q.item.string_representation +"%N") - end - - l_body.append ("Meta variables:%N") - across - req.meta_variables as q - loop - l_body.append ("%T"+ q.item.name + "=" + q.item.string_representation +"%N") - end - - res.send (page) - end - -feature -- Access - -feature -- Change - -feature {NONE} -- Implementation - -invariant --- invariant_clause: True - end diff --git a/library/server/wsf/tests/echo/src/echo_server_execution.e b/library/server/wsf/tests/echo/src/echo_server_execution.e new file mode 100644 index 00000000..e4b73f46 --- /dev/null +++ b/library/server/wsf/tests/echo/src/echo_server_execution.e @@ -0,0 +1,59 @@ +note + description : "Objects that ..." + author : "$Author$" + date : "$Date$" + revision : "$Revision$" + +class + ECHO_SERVER_EXECUTION + +inherit + WSF_EXECUTION + +create + make + +feature -- Execution + + execute + local + req: WSF_REQUEST; res: WSF_RESPONSE + page: WSF_PAGE_RESPONSE + l_body: STRING_8 + do + req := request + res := response + create l_body.make (1024) + create page.make_with_body (l_body) + page.header.put_content_type_text_plain + + l_body.append ("REQUEST_METHOD=" + req.request_method + "%N") + l_body.append ("REQUEST_URI=" + req.request_uri + "%N") + l_body.append ("PATH_INFO=" + req.path_info + "%N") + l_body.append ("QUERY_STRING=" + req.query_string + "%N") + + l_body.append ("Query parameters:%N") + across + req.query_parameters as q + loop + l_body.append ("%T"+ q.item.name + "=" + q.item.string_representation +"%N") + end + + l_body.append ("Form parameters:%N") + across + req.form_parameters as q + loop + l_body.append ("%T"+ q.item.name + "=" + q.item.string_representation +"%N") + end + + l_body.append ("Meta variables:%N") + across + req.meta_variables as q + loop + l_body.append ("%T"+ q.item.name + "=" + q.item.string_representation +"%N") + end + + res.send (page) + end + +end diff --git a/library/server/wsf/tests/server/test.e b/library/server/wsf/tests/server/test.e index 5cd52363..f672cb23 100644 --- a/library/server/wsf/tests/server/test.e +++ b/library/server/wsf/tests/server/test.e @@ -2,9 +2,9 @@ class TEST inherit - WSF_DEFAULT_SERVICE + WSF_DEFAULT_SERVICE [TEST_EXECUTION] - TEST_SERVICE + TEST_SERVICE [TEST_EXECUTION] create make @@ -22,38 +22,6 @@ feature {NONE} -- Initialization make_and_launch end -feature -- Helper - server_log_path: STRING - local - fn: FILE_NAME - once - create fn.make_from_string ("server_test.log") - Result := fn.string - end - - server_log (m: STRING_8) - local - f: RAW_FILE - do - create f.make (server_log_path) - f.open_append - f.put_string (m) - f.put_character ('%N') - f.close - end - - base_url: detachable STRING - - test_url (a_query_url: READABLE_STRING_8): READABLE_STRING_8 - local - b: like base_url - do - b := base_url - if b = Void then - b := "" - end - Result := "/" + b + a_query_url - end end diff --git a/library/server/wsf/tests/server/test_execution.e b/library/server/wsf/tests/server/test_execution.e new file mode 100644 index 00000000..be73d987 --- /dev/null +++ b/library/server/wsf/tests/server/test_execution.e @@ -0,0 +1,51 @@ +note + description: "Summary description for {}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + TEST_EXECUTION + +inherit + TEST_EXECUTION_I + +create + make + +feature -- Helper + + server_log_path: STRING + local + fn: FILE_NAME + once + create fn.make_from_string ("server_test.log") + Result := fn.string + end + + server_log (m: STRING_8) + local + f: RAW_FILE + do + create f.make (server_log_path) + f.open_append + f.put_string (m) + f.put_character ('%N') + f.close + end + + base_url: detachable STRING + + test_url (a_query_url: READABLE_STRING_8): READABLE_STRING_8 + local + b: like base_url + do + b := base_url + if b = Void then + b := "" + end + Result := "/" + b + a_query_url + end + +end + diff --git a/library/server/wsf/tests/server/test_execution_i.e b/library/server/wsf/tests/server/test_execution_i.e new file mode 100644 index 00000000..56537b06 --- /dev/null +++ b/library/server/wsf/tests/server/test_execution_i.e @@ -0,0 +1,195 @@ +note + description: "Summary description for {}." + author: "" + date: "$Date$" + revision: "$Revision$" + +deferred class + TEST_EXECUTION_I + +inherit + WSF_EXECUTION + +feature -- Execution + + execute + local + req: WSF_REQUEST + res: WSF_RESPONSE + q: detachable STRING_32 + n: NATURAL_64 + page: WSF_PAGE_RESPONSE + log_res: WSF_LOGGER_RESPONSE_WRAPPER + do + req := request + res := response + debug + server_log (req.request_uri) + if attached req.content_type as l_content_type then + server_log ("content_type:" + l_content_type.string) + end + end + if attached req.http_expect as l_expect and then l_expect.same_string ("100-continue") then + (create {EXECUTION_ENVIRONMENT}).sleep (900_000_000) -- 900 milliseconds + end + + create page.make + if attached req.request_uri as l_uri then + if l_uri.starts_with (test_url ("get/01")) then + page.set_status_code (200) + page.header.put_content_type_text_plain + page.put_string ("get-01") + create q.make_empty + + across + req.query_parameters as qcur + loop + if not q.is_empty then + q.append_character ('&') + end + q.append (qcur.item.name.as_string_32 + "=" + qcur.item.string_representation) + end + if not q.is_empty then + page.put_string ("(" + q + ")") + end + elseif l_uri.starts_with (test_url ("post/01")) then + page.put_header (200, <<["Content-Type", "text/plain"]>>) + page.put_string ("post-01") + create q.make_empty + + across + req.query_parameters as qcur + loop + if not q.is_empty then + q.append_character ('&') + end + q.append (qcur.item.name.as_string_32 + "=" + qcur.item.string_representation) + end + + if not q.is_empty then + page.put_string ("(" + q + ")") + end + + create q.make_empty +-- req.set_raw_input_data_recorded (True) + + across + req.form_parameters as fcur + loop + debug + server_log ("%Tform: " + fcur.item.name) + end + if not q.is_empty then + q.append_character ('&') + end + q.append (fcur.item.name.as_string_32 + "=" + fcur.item.string_representation) + end + +-- if attached req.raw_input_data as d then +-- server_log ("Raw data=" + d) +-- end + + if not q.is_empty then + page.put_string (" : " + q ) + end + elseif l_uri.starts_with (test_url ("post/file/01")) then + page.put_header (200, <<["Content-Type", "text/plain"]>>) + page.put_string ("post-file-01") + n := req.content_length_value + if n > 0 then + req.input.read_string (n.to_integer_32) + q := req.input.last_string + page.put_string ("%N" + q) + end + else + page.put_header (200, <<["Content-Type", "text/plain"]>>) + page.put_string ("Hello") + end + else + page.put_header (200, <<["Content-Type", "text/plain"]>>) + page.put_string ("Bye") + end + + if + attached new_file (req, "output.log") as l_out and + attached new_file (req, "error.log") as l_err + then + create log_res.make_from_response (res, l_out, l_err) + log_res.send (page) + + l_out.close + l_err.close + else + check False end + res.send (page) + end + end + + new_file (req: WSF_REQUEST; a_suffix: STRING): detachable FILE + local + dp, p, fp: FILE_NAME + d: DIRECTORY + i: INTEGER + f: detachable FILE + retried: INTEGER + do + if retried = 0 then + create dp.make_from_string ("logs") + create d.make (dp.string) + if not d.exists then + d.recursive_create_dir + end + if attached req.request_time_stamp as t then + create p.make_from_string (t.out) + else + create p.make_from_string ("") + end + + from + i := 0 + create fp.make_from_string (dp.string) + if p.is_empty then + fp.set_file_name (p.string + a_suffix) + else + fp.set_file_name (p.string + "-" + a_suffix) + end + create {PLAIN_TEXT_FILE} f.make (fp.string) + until + not f.exists + loop + i := i + 1 + create fp.make_from_string (dp.string) + if p.is_empty then + fp.set_file_name (p.string + i.out + "-" + a_suffix) + else + fp.set_file_name (p.string + "_" + i.out + "-" + a_suffix) + end + + f.make (fp.string) + end + f.open_write + elseif retried < 5 then + + -- Eventually another request created the file at the same time .. + f := new_file (req, a_suffix) + else + f := Void + end + Result := f + rescue + retried := retried + 1 + retry + end + +feature -- Helper + + server_log (s: STRING) + deferred + end + + test_url (a_query_url: READABLE_STRING_8): READABLE_STRING_8 + deferred + end + +end + diff --git a/library/server/wsf/tests/server/test_service.e b/library/server/wsf/tests/server/test_service.e index 716e0b51..f2ea7e1e 100644 --- a/library/server/wsf/tests/server/test_service.e +++ b/library/server/wsf/tests/server/test_service.e @@ -5,187 +5,11 @@ note revision: "$Revision$" deferred class - TEST_SERVICE + TEST_SERVICE [G -> TEST_EXECUTION_I create make end] inherit WSF_SERVICE -feature -- Execution - - execute (req: WSF_REQUEST; res: WSF_RESPONSE) - local - q: detachable STRING_32 - n: NATURAL_64 - page: WSF_PAGE_RESPONSE - log_res: WSF_LOGGER_RESPONSE_WRAPPER - do - debug - server_log (req.request_uri) - if attached req.content_type as l_content_type then - server_log ("content_type:" + l_content_type.string) - end - end - if attached req.http_expect as l_expect and then l_expect.same_string ("100-continue") then - (create {EXECUTION_ENVIRONMENT}).sleep (900_000_000) -- 900 milliseconds - end - - create page.make - if attached req.request_uri as l_uri then - if l_uri.starts_with (test_url ("get/01")) then - page.set_status_code (200) - page.header.put_content_type_text_plain - page.put_string ("get-01") - create q.make_empty - - across - req.query_parameters as qcur - loop - if not q.is_empty then - q.append_character ('&') - end - q.append (qcur.item.name.as_string_32 + "=" + qcur.item.string_representation) - end - if not q.is_empty then - page.put_string ("(" + q + ")") - end - elseif l_uri.starts_with (test_url ("post/01")) then - page.put_header (200, <<["Content-Type", "text/plain"]>>) - page.put_string ("post-01") - create q.make_empty - - across - req.query_parameters as qcur - loop - if not q.is_empty then - q.append_character ('&') - end - q.append (qcur.item.name.as_string_32 + "=" + qcur.item.string_representation) - end - - if not q.is_empty then - page.put_string ("(" + q + ")") - end - - create q.make_empty --- req.set_raw_input_data_recorded (True) - - across - req.form_parameters as fcur - loop - debug - server_log ("%Tform: " + fcur.item.name) - end - if not q.is_empty then - q.append_character ('&') - end - q.append (fcur.item.name.as_string_32 + "=" + fcur.item.string_representation) - end - --- if attached req.raw_input_data as d then --- server_log ("Raw data=" + d) --- end - - if not q.is_empty then - page.put_string (" : " + q ) - end - elseif l_uri.starts_with (test_url ("post/file/01")) then - page.put_header (200, <<["Content-Type", "text/plain"]>>) - page.put_string ("post-file-01") - n := req.content_length_value - if n > 0 then - req.input.read_string (n.to_integer_32) - q := req.input.last_string - page.put_string ("%N" + q) - end - else - page.put_header (200, <<["Content-Type", "text/plain"]>>) - page.put_string ("Hello") - end - else - page.put_header (200, <<["Content-Type", "text/plain"]>>) - page.put_string ("Bye") - end - - if - attached new_file (req, "output.log") as l_out and - attached new_file (req, "error.log") as l_err - then - create log_res.make_from_response (res, l_out, l_err) - log_res.send (page) - - l_out.close - l_err.close - else - check False end - res.send (page) - end - end - - new_file (req: WSF_REQUEST; a_suffix: STRING): detachable FILE - local - dp, p, fp: FILE_NAME - d: DIRECTORY - i: INTEGER - f: detachable FILE - retried: INTEGER - do - if retried = 0 then - create dp.make_from_string ("logs") - create d.make (dp.string) - if not d.exists then - d.recursive_create_dir - end - if attached req.request_time_stamp as t then - create p.make_from_string (t.out) - else - create p.make_from_string ("") - end - - from - i := 0 - create fp.make_from_string (dp.string) - if p.is_empty then - fp.set_file_name (p.string + a_suffix) - else - fp.set_file_name (p.string + "-" + a_suffix) - end - create {PLAIN_TEXT_FILE} f.make (fp.string) - until - not f.exists - loop - i := i + 1 - create fp.make_from_string (dp.string) - if p.is_empty then - fp.set_file_name (p.string + i.out + "-" + a_suffix) - else - fp.set_file_name (p.string + "_" + i.out + "-" + a_suffix) - end - - f.make (fp.string) - end - f.open_write - elseif retried < 5 then - - -- Eventually another request created the file at the same time .. - f := new_file (req, a_suffix) - else - f := Void - end - Result := f - rescue - retried := retried + 1 - retry - end - -feature -- Helper - - server_log (s: STRING) - deferred - end - - test_url (a_query_url: READABLE_STRING_8): READABLE_STRING_8 - deferred - end end diff --git a/library/server/wsf/tests/src/test_wsf_request.e b/library/server/wsf/tests/src/test_wsf_request.e index c011f03c..fadd050a 100644 --- a/library/server/wsf/tests/src/test_wsf_request.e +++ b/library/server/wsf/tests/src/test_wsf_request.e @@ -17,14 +17,9 @@ inherit on_clean end - TEST_SERVICE - undefine - default_create - end - feature {NONE} -- Events - web_app: detachable NINO_SERVICE + web_app: detachable NINO_SERVICE [TEST_EXECUTION] port_number: INTEGER base_url: detachable STRING @@ -32,7 +27,7 @@ feature {NONE} -- Events on_prepare -- local - app: NINO_SERVICE + app: NINO_SERVICE [TEST_EXECUTION] wt: WORKER_THREAD e: EXECUTION_ENVIRONMENT do @@ -43,7 +38,7 @@ feature {NONE} -- Events port_number := 0 base_url := "/test/" - create app.make_custom (to_wgi_service, base_url) + create app.make_custom (base_url) web_app := app create wt.make (agent app.listen (port_number)) diff --git a/library/server/wsf/tests/src/test_wsf_response_test_suite.e b/library/server/wsf/tests/src/test_wsf_response_test_suite.e index 2f6c0771..968ca0b2 100644 --- a/library/server/wsf/tests/src/test_wsf_response_test_suite.e +++ b/library/server/wsf/tests/src/test_wsf_response_test_suite.e @@ -7,15 +7,13 @@ class TEST_WSF_RESPONSE_TEST_SUITE inherit - WSF_TO_WGI_SERVICE - rename - default_create as df_wgi, - execute as execute_wgi - end EQA_TEST_SET redefine on_prepare - select + end + + WGI_EXPORTER + undefine default_create end @@ -23,7 +21,6 @@ feature {NONE} -- Events on_prepare do - make_from_service (create {WSF_SERVICE_NULL}) end feature -- Test Cases @@ -96,7 +93,7 @@ feature -- Test Cases end - test_add_multiple_cookie_with_similar_cookie_name_2 + test_add_multiple_cookie_with_similar_cookie_name_2 local w_res: WSF_RESPONSE l_cookie: WSF_COOKIE diff --git a/library/server/wsf/tests/src/wsf_service_null.e b/library/server/wsf/tests/src/wsf_service_null.e deleted file mode 100644 index 4f6cf001..00000000 --- a/library/server/wsf/tests/src/wsf_service_null.e +++ /dev/null @@ -1,26 +0,0 @@ -note - description: "[ - Mock implementation of the WGI_SERVICE interface. - - Used for testing the ewf core and also web applications - ]" - date: "$Date$" - revision: "$Revision$" - -class - WSF_SERVICE_NULL - -inherit - - WSF_SERVICE - - -feature -- Execute - execute (req: WSF_REQUEST; res: WSF_RESPONSE) - -- Execute the request - -- See `req.input' for input stream - -- `req.meta_variables' for the CGI meta variable - -- and `res' for output buffer - do - end -end diff --git a/tests/all-stable-safe.ecf b/tests/all-stable-safe.ecf index 80db1dc4..db1cc477 100644 --- a/tests/all-stable-safe.ecf +++ b/tests/all-stable-safe.ecf @@ -13,11 +13,13 @@ + + @@ -45,6 +47,7 @@ + diff --git a/tools/estudio_wizard/rootdir/resources/${APP_NAME}.ecf b/tools/estudio_wizard/rootdir/resources/${APP_NAME}.ecf index f30460a5..6562aee1 100644 --- a/tools/estudio_wizard/rootdir/resources/${APP_NAME}.ecf +++ b/tools/estudio_wizard/rootdir/resources/${APP_NAME}.ecf @@ -17,22 +17,28 @@ {if condition="$WIZ.connectors.use_cgi ~ $WIZ_YES"}{/if} {if condition="$WIZ.connectors.use_libfcgi ~ $WIZ_YES"}{/if} - {if condition="$WIZ.connectors.use_standalone ~ $WIZ_YES"}{/if} + {if condition="$WIZ.connectors.use_standalone ~ $WIZ_YES"}{/if} + {if condition="$WIZ.connectors.use_nino ~ $WIZ_YES"}{/if} - - /default$ - + {if condition="$WIZ.connectors.use_standalone ~ $WIZ_YES"} + + + + + + + + {/if} +{if condition="$WIZ.connectors.use_nino ~ $WIZ_YES"} - - - /any$ - + + {/if} @@ -40,10 +46,8 @@ - - - /any$ - + + {/if} @@ -51,10 +55,8 @@ - - - /any$ - + + {/if} diff --git a/tools/estudio_wizard/rootdir/resources/launcher/any/application_launcher_i.e b/tools/estudio_wizard/rootdir/resources/launcher/any/application_launcher_i.e index 58f5e2ba..ff7a5956 100644 --- a/tools/estudio_wizard/rootdir/resources/launcher/any/application_launcher_i.e +++ b/tools/estudio_wizard/rootdir/resources/launcher/any/application_launcher_i.e @@ -10,33 +10,38 @@ note revision: "$Revision: 36 $" deferred class - APPLICATION_LAUNCHER_I + APPLICATION_LAUNCHER_I [G -> WSF_EXECUTION create make end] + +inherit + SHARED_EXECUTION_ENVIRONMENT feature -- Execution - launch (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS) - -- Launch Web Server Application using `a_service' and optionals `opts'. + launch (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS) + -- Launch Web Server Application using optionals `opts'. local - l_id: like launcher_id launcher: WSF_SERVICE_LAUNCHER do l_id := launcher_id - if l_id = Void then + if not attached launcher_id as l_id then {unless condition="$WIZ.connectors.use_standalone ~ $WIZ_YES"}{literal} io.error.put_string ("Application launcher not found!%N") (create {EXCEPTIONS}).die (-1){/literal}{/unless} {if condition="$WIZ.connectors.use_standalone ~ $WIZ_YES"}{literal} -- Choose a default -> standalone - create {WSF_NINO_SERVICE_LAUNCHER} launcher.make_and_launch (a_service, opts){/literal}{/if} -{if condition="$WIZ.connectors.use_libfcgi ~ $WIZ_YES"}{literal} - elseif is_libfcgi_launcher_id (l_id) then - create {WSF_LIBFCGI_SERVICE_LAUNCHER} launcher.make_and_launch (a_service, opts){/literal}{/if} -{if condition="$WIZ.connectors.use_cgi ~ $WIZ_YES"}{literal} - elseif is_cgi_launcher_id (l_id) then - create {WSF_CGI_SERVICE_LAUNCHER} launcher.make_and_launch (a_service, opts){/literal}{/if} + create {WSF_STANDALONE_SERVICE_LAUNCHER} launcher.make_and_launch (opts){/literal}{/if} {if condition="$WIZ.connectors.use_standalone ~ $WIZ_YES"}{literal} elseif is_nino_launcher_id (l_id) then - create {WSF_NINO_SERVICE_LAUNCHER} launcher.make_and_launch (a_service, opts){/literal}{/if} + create {WSF_STANDALONE_SERVICE_LAUNCHER} launcher.make_and_launch (opts){/literal}{/if} +{if condition="$WIZ.connectors.use_libfcgi ~ $WIZ_YES"}{literal} + elseif is_libfcgi_launcher_id (l_id) then + create {WSF_LIBFCGI_SERVICE_LAUNCHER} launcher.make_and_launch (opts){/literal}{/if} +{if condition="$WIZ.connectors.use_cgi ~ $WIZ_YES"}{literal} + elseif is_cgi_launcher_id (l_id) then + create {WSF_CGI_SERVICE_LAUNCHER} launcher.make_and_launch (opts){/literal}{/if} +{if condition="$WIZ.connectors.use_nino ~ $WIZ_YES"}{literal} + elseif is_nino_launcher_id (l_id) then + create {WSF_NINO_SERVICE_LAUNCHER} launcher.make_and_launch (opts){/literal}{/if} {literal} else io.error.put_string ("Application launcher not found!%N") @@ -48,11 +53,8 @@ feature -- Execution -- Launcher id based on the executable extension name if any. -- This can be redefine to customize for your application. --| ex: nino, cgi, libfcgi or Void. - local - sh_exec: SHARED_EXECUTION_ENVIRONMENT do - create sh_exec - if attached (create {PATH}.make_from_string (sh_exec.execution_environment.arguments.command_name)).extension as ext then + if attached (create {PATH}.make_from_string (execution_environment.arguments.command_name)).extension as ext then Result := ext end end @@ -60,10 +62,15 @@ feature -- Execution feature -- Status report {/literal} {if condition="$WIZ.connectors.use_standalone ~ $WIZ_YES"} + is_nino_launcher_id (a_id: READABLE_STRING_GENERAL): BOOLEAN + do + Result := a_id.is_case_insensitive ("standalone") + end{/if} + +{if condition="$WIZ.connectors.use_nino ~ $WIZ_YES"} is_nino_launcher_id (a_id: READABLE_STRING_GENERAL): BOOLEAN do Result := a_id.is_case_insensitive ("nino") - or a_id.is_case_insensitive ("standalone") end{/if} {if condition="$WIZ.connectors.use_cgi ~ $WIZ_YES"} @@ -79,6 +86,5 @@ feature -- Status report or a_id.is_case_insensitive ("fcgi") end{/if} - end diff --git a/tools/estudio_wizard/rootdir/resources/launcher/application_launcher.e b/tools/estudio_wizard/rootdir/resources/launcher/application_launcher.e index 7754546d..616dbd6f 100644 --- a/tools/estudio_wizard/rootdir/resources/launcher/application_launcher.e +++ b/tools/estudio_wizard/rootdir/resources/launcher/application_launcher.e @@ -8,10 +8,10 @@ note revision: "$Revision: 36 $" class - APPLICATION_LAUNCHER + APPLICATION_LAUNCHER [G -> WSF_EXECUTION create make end] inherit - APPLICATION_LAUNCHER_I + APPLICATION_LAUNCHER_I [G] feature -- Custom diff --git a/tools/estudio_wizard/rootdir/resources/launcher/default/application_launcher_i.e b/tools/estudio_wizard/rootdir/resources/launcher/default/application_launcher_i.e index 03bd497b..72fb1389 100644 --- a/tools/estudio_wizard/rootdir/resources/launcher/default/application_launcher_i.e +++ b/tools/estudio_wizard/rootdir/resources/launcher/default/application_launcher_i.e @@ -10,21 +10,21 @@ note revision: "$Revision: 36 $" deferred class - APPLICATION_LAUNCHER_I + APPLICATION_LAUNCHER_I [G -> WSF_EXECUTION create make end] feature -- Execution - launch (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS) + launch (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS) -- Launch Web Server Application using `a_service' and optionals `opts'. local - launcher: WSF_SERVICE_LAUNCHER + launcher: WSF_SERVICE_LAUNCHER [G] do {literal} - create {WSF_DEFAULT_SERVICE_LAUNCHER} launcher.make_and_launch (a_service, opts){/literal} + create {WSF_DEFAULT_SERVICE_LAUNCHER [G]} launcher.make_and_launch (opts){/literal} end launcher_id: detachable READABLE_STRING_GENERAL - do + once -- Not used for default connector selection. end diff --git a/tools/estudio_wizard/rootdir/resources/src/${APP_ROOT}.e b/tools/estudio_wizard/rootdir/resources/src/${APP_ROOT}.e index 75792d57..0dab746f 100644 --- a/tools/estudio_wizard/rootdir/resources/src/${APP_ROOT}.e +++ b/tools/estudio_wizard/rootdir/resources/src/${APP_ROOT}.e @@ -16,8 +16,8 @@ inherit end {if condition="$WIZ.routers.use_router ~ $WIZ_YES"} WSF_ROUTED_SERVICE{/if} - - APPLICATION_LAUNCHER + {if isset="$APP_ROOT"}APPLICATION_LAUNCHER [{$APP_ROOT/}_EXECUTION]{/if} + {unless isset="$APP_ROOT"}APPLICATION_LAUNCHER [APPLICATION_EXECUTION]{/if} {literal}create make_and_launch @@ -29,27 +29,7 @@ feature {NONE} -- Initialization do Precursor set_service_option ("port", {$WIZ.standalone_connector.port/}) -{unless condition="$WIZ.routers.use_router ~ $WIZ_YES"} end -feature -- Execution - - execute (req: WSF_REQUEST; res: WSF_RESPONSE) - do - end{/unless} -{if condition="$WIZ.routers.use_router ~ $WIZ_YES"}{literal} - initialize_router - end - - setup_router - -- Setup `router' - local - fhdl: WSF_FILE_SYSTEM_HANDLER - do - router.handle_with_request_methods ("/doc", create {WSF_ROUTER_SELF_DOCUMENTATION_HANDLER}.make (router), router.methods_GET) - create fhdl.make_hidden ("www") - fhdl.set_directory_index (<<"index.html">>) - router.handle_with_request_methods ("", fhdl, router.methods_GET) - end{/literal}{/if} end diff --git a/tools/estudio_wizard/rootdir/resources/src/${APP_ROOT}_EXECUTION.e b/tools/estudio_wizard/rootdir/resources/src/${APP_ROOT}_EXECUTION.e new file mode 100644 index 00000000..9baf8fe4 --- /dev/null +++ b/tools/estudio_wizard/rootdir/resources/src/${APP_ROOT}_EXECUTION.e @@ -0,0 +1,89 @@ +note + description: "[ + application execution + ]" + date: "$Date$" + revision: "$Revision$" + +class + {if isset="$APP_ROOT"}{$APP_ROOT/}_EXECUTION{/if} + {unless isset="$APP_ROOT"}APPLICATION_EXECUTION{/unless} + +inherit +{unless condition="$WIZ.routers.use_router ~ $WIZ_YES"} + {unless condition="$WIZ.routers.use_filter ~ $WIZ_YES"} + WSF_EXECUTION{/unless} + {if condition="$WIZ.routers.use_filter ~ $WIZ_YES"} + WSF_FILTERED_EXECUTION{/if} +{/unless} +{if condition="$WIZ.routers.use_router ~ $WIZ_YES"} + {unless condition="$WIZ.routers.use_filter ~ $WIZ_YES"} + WSF_ROUTED_EXECUTION{/unless} + {if condition="$WIZ.routers.use_filter ~ $WIZ_YES"} + WSF_FILTERED_ROUTED_EXECUTION{/if} +{/if} + +{literal}create + make + +feature {NONE} -- Initialization +{/literal} + +{unless condition="$WIZ.routers.use_router ~ $WIZ_YES"}{literal} +feature -- Execution + + execute + -- Use `request' to get data for the incoming http request + -- and `response' to send response back to the client + local + mesg: WSF_PAGE_RESPONSE + do + --| As example, you can use {WSF_PAGE_RESPONSE} + --| To send back easily a simple plaintext message. + create mesg.make_with_body ("Hello Eiffel Web") + response.send (mesg) + end{/unless} + +{if condition="$WIZ.routers.use_filter ~ $WIZ_YES"}{literal} +feature -- Filter + + create_filter + -- Create `filter' + do + --| Example using Maintenance filter. + create {WSF_MAINTENANCE_FILTER} filter + end + + setup_filter + -- Setup `filter' + do + append_filters (<< + create {WSF_CORS_FILTER}, + create {WSF_LOGGING_FILTER} + >>) + --| Chain more filters like {WSF_CUSTOM_HEADER_FILTER}, ... + --| and your owns filters. + end{/if} + +{if condition="$WIZ.routers.use_router ~ $WIZ_YES"}{literal} +feature -- Router + + setup_router + -- Setup `router' + local + fhdl: WSF_FILE_SYSTEM_HANDLER + do + --| As example: + --| /doc is dispatched to self documentated page + --| /* are dispatched to serve files/directories contained in "www" directory + + --| Self documentation + router.handle_with_request_methods ("/doc", create {WSF_ROUTER_SELF_DOCUMENTATION_HANDLER}.make (router), router.methods_GET) + + --| Files publisher + create fhdl.make_hidden ("www") + fhdl.set_directory_index (<<"index.html">>) + router.handle_with_request_methods ("", fhdl, router.methods_GET) + end{/literal}{/if} + +end diff --git a/tools/estudio_wizard/src/ewf_wizard.e b/tools/estudio_wizard/src/ewf_wizard.e index 670207b2..f98cea13 100644 --- a/tools/estudio_wizard/src/ewf_wizard.e +++ b/tools/estudio_wizard/src/ewf_wizard.e @@ -24,7 +24,7 @@ feature -- Factory create Result.make (Current) end -feature -- Pages +feature -- Pages first_page: WIZARD_PAGE once @@ -83,11 +83,13 @@ Web application runs on top of connectors Select connectors you want to support: ]") - Result.add_boolean_question ("Standalone", "use_standalone", "Using the Eiffel Web nino server") + Result.add_boolean_question ("Standalone", "use_standalone", "Using the standalone Eiffel Web server") + Result.add_boolean_question ("Nino", "use_nino", "Using the Eiffel Web nino server") Result.add_boolean_question ("CGI", "use_cgi", "Require a httpd server") Result.add_boolean_question ("libFCGI", "use_libfcgi", "Require a httpd server") Result.data.force ("yes", "use_standalone") + Result.data.force ("no", "use_nino") Result.data.force ("yes", "use_cgi") Result.data.force ("yes", "use_libfcgi") end @@ -95,7 +97,7 @@ Select connectors you want to support: standalone_connector_page: WIZARD_PAGE once Result := new_page ("standalone_connector") - Result.set_title ("Standalone (nino) connector") + Result.set_title ("Standalone (or nino) connector") Result.set_subtitle ("Set options .") Result.add_integer_question ("Port number", "port", "It happens port 80 is already taken, thus choose another one.") Result.add_boolean_question ("Verbose", "verbose", "Verbose output") @@ -117,6 +119,19 @@ Use the router component to easily map URL patterns to handlers: Result.data.force ("yes", "use_router") end + filters_page: WIZARD_PAGE + once + Result := new_page ("filters") + Result.set_title ("Use Filter (chain filter)") + Result.set_subtitle ("Use the filter component.") + Result.add_text ("[ +Use the filter component: + ]") + Result.add_boolean_question ("use the filter component", "use_filter", "Check generated code to see how to configure it.") + + Result.data.force ("yes", "use_filter") + end + final_page: WIZARD_PAGE local -- s,sv: STRING_32 @@ -160,6 +175,12 @@ Use the router component to easily map URL patterns to handlers: end sv.append ("standalone") end + if connectors_page.boolean_field_value ("use_nino") then + if not sv.is_empty then + sv.append (", ") + end + sv.append ("nino") + end if connectors_page.boolean_field_value ("use_cgi") then if not sv.is_empty then sv.append (", ") @@ -178,6 +199,9 @@ Use the router component to easily map URL patterns to handlers: if routers_page.boolean_field_value ("use_router") then l_settings.force (["Use Router", "yes"]) end + if routers_page.boolean_field_value ("use_filter") then + l_settings.force (["Use Filter", "yes"]) + end a_txt2.set_text (formatted_title_value_items (l_settings)) end(Result, txt1, txt2)) @@ -195,7 +219,10 @@ feature -- Events elseif a_current_page = project_page then Result := connectors_page elseif a_current_page = connectors_page then - if connectors_page.boolean_field_value ("use_standalone") then + if + connectors_page.boolean_field_value ("use_standalone") + or connectors_page.boolean_field_value ("use_nino") + then Result := standalone_connector_page else Result := routers_page @@ -203,6 +230,8 @@ feature -- Events elseif a_current_page = standalone_connector_page then Result := routers_page elseif a_current_page = routers_page then + Result := filters_page + elseif a_current_page = filters_page then Result := final_page end end