From c7366615cf32c325912ed5689626f664395bebcd Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Wed, 14 Dec 2011 14:44:06 +0100 Subject: [PATCH] Added DEFAULT_SERVICE_LAUNCHER.make_and_launch_with_options Added WSF_RESPONSE.redirect_now_with_content (...) Updated hello_routed_world .. mainly example use to test/develop... not really a nice example --- .../src/hello_routed_world.e | 23 ++++-- .../default/cgi/default_service_launcher.e | 5 ++ .../libfcgi/default_service_launcher.e | 5 ++ .../default/nino/default_service_launcher.e | 78 ++++++++++++++++--- library/server/wsf/src/wsf_response.e | 20 +++++ 5 files changed, 113 insertions(+), 18 deletions(-) diff --git a/examples/hello_routed_world/src/hello_routed_world.e b/examples/hello_routed_world/src/hello_routed_world.e index 0ccc91c5..3a33e1fd 100644 --- a/examples/hello_routed_world/src/hello_routed_world.e +++ b/examples/hello_routed_world/src/hello_routed_world.e @@ -22,7 +22,7 @@ feature {NONE} -- Initialization s: DEFAULT_SERVICE_LAUNCHER do initialize_router - create s.make_and_launch (agent execute) + create s.make_and_launch_with_options (agent execute, <<["port", 8099]>>) end create_router @@ -36,6 +36,7 @@ feature {NONE} -- Initialization hello: REQUEST_URI_TEMPLATE_ROUTING_HANDLER www: REQUEST_FILE_SYSTEM_HANDLER [REQUEST_URI_TEMPLATE_HANDLER_CONTEXT] do + router.map_agent ("/refresh", agent execute_refresh) router.map_agent ("/home", agent execute_home) create www.make (document_root) www.set_directory_index (<<"index.html">>) @@ -79,7 +80,16 @@ feature {NONE} -- Initialization feature -- Execution + execute_default (req: WSF_REQUEST; res: WSF_RESPONSE) + local + l_url: STRING + do + l_url := req.absolute_script_url ("/home") + res.redirect_now_with_content (l_url, "You are now being redirected to " + l_url, {HTTP_MIME_TYPES}.text_html) + end + + execute_refresh (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE) local h: HTTP_HEADER l_url: STRING @@ -87,20 +97,20 @@ feature -- Execution n: INTEGER i: INTEGER s: STRING_8 - df: WSF_FILE_RESPONSE do - create df.make_html ("index.html") - df.set_no_cache + l_url := req.absolute_script_url ("/home") + - l_url := req.script_url ("/home") n := 3 create h.make h.put_refresh (l_url, 5) + h.put_location (l_url) h.put_content_type_text_plain h.put_transfer_encoding_chunked -- h.put_content_length (0) - res.set_status_code ({HTTP_STATUS_CODE}.moved_permanently) +-- res.set_status_code ({HTTP_STATUS_CODE}.moved_permanently) + res.set_status_code ({HTTP_STATUS_CODE}.ok) res.write_header_text (h.string) from @@ -143,6 +153,7 @@ feature -- Execution l_body.append ("Hello World ?!%N") l_body.append ("

Please try the following links