From 8a58d62a7ee1118bd6e508d4b664a362c07223c7 Mon Sep 17 00:00:00 2001
From: Jocelyn Fiat
Date: Mon, 11 Jun 2012 14:58:13 +0200
Subject: [PATCH] Adopted convention name and value or values for WSF_VALUE and
descendant (WSF_STRING ...) kept `key' as redirection, and also string as
obsolete redirection. Router: provide a way to pass the request methods
without using manifest string, thanks to WSF_ROUTER_METHODS so instead of
using manifest array or manifest strings, just create an instance of
WSF_ROUTER_METHODS for convenience, WSF_ROUTER provides a few `methods_...'
returning prebuilt WSF_ROUTER_METHODS objects Improved code related to
unicode handling in URL, and parameters (before the framework was doing too
much)
---
examples/tutorial/step_3/hello/hello.ecf | 2 +-
.../step_4/hello/src/hello_application.e | 36 +-
.../step_4/hello/src/user_message_handler.e | 31 +-
.../protocol/http/src/http_request_methods.e | 31 +-
.../wsf/router/uri/default/wsf_uri_router.e | 6 +-
.../server/wsf/router/uri/wsf_uri_router_i.e | 30 +-
.../default/wsf_uri_template_router.e | 4 +-
.../uri_template/wsf_uri_template_router_i.e | 16 +-
.../wsf/router/wsf_file_system_handler.e | 2 +-
library/server/wsf/router/wsf_handler.e | 2 +-
library/server/wsf/router/wsf_router.e | 141 ++++--
.../server/wsf/router/wsf_router_methods.e | 402 ++++++++++++++++++
.../server/wsf/router/wsf_routing_handler.e | 5 +-
.../server/wsf/src/request/value/wsf_any.e | 15 +-
.../src/request/value/wsf_multiple_string.e | 45 +-
.../server/wsf/src/request/value/wsf_string.e | 100 +++--
.../server/wsf/src/request/value/wsf_table.e | 11 +-
.../wsf/src/request/value/wsf_uploaded_file.e | 7 +-
library/server/wsf/src/request/wsf_value.e | 7 +-
.../wsf/src/response/wsf_download_response.e | 2 +-
.../wsf/src/response/wsf_file_response.e | 2 +-
.../wsf/src/response/wsf_html_page_response.e | 14 +-
.../response/wsf_html_redirection_response.e | 4 +-
.../wsf/src/response/wsf_page_response.e | 2 +-
.../src/response/wsf_redirection_response.e | 2 +-
library/server/wsf/src/wsf_request.e | 23 +-
library/server/wsf/src/wsf_response_message.e | 15 +-
library/text/encoder/src/html_encoder.e | 23 +-
library/text/encoder/src/utf8_url_encoder.e | 8 +-
29 files changed, 790 insertions(+), 198 deletions(-)
create mode 100644 library/server/wsf/router/wsf_router_methods.e
diff --git a/examples/tutorial/step_3/hello/hello.ecf b/examples/tutorial/step_3/hello/hello.ecf
index 1cfd0b49..b58272ca 100644
--- a/examples/tutorial/step_3/hello/hello.ecf
+++ b/examples/tutorial/step_3/hello/hello.ecf
@@ -12,7 +12,7 @@
-
+
diff --git a/examples/tutorial/step_4/hello/src/hello_application.e b/examples/tutorial/step_4/hello/src/hello_application.e
index fab7157c..68dd1cec 100644
--- a/examples/tutorial/step_4/hello/src/hello_application.e
+++ b/examples/tutorial/step_4/hello/src/hello_application.e
@@ -30,11 +30,10 @@ feature {NONE} -- Initialization
do
router.map_agent ("/hello", agent execute_hello)
+ router.map_with_request_methods ("/users/{user}/message/{mesgid}", create {USER_MESSAGE_HANDLER}, router.methods_GET_POST)
+ router.map_with_request_methods ("/users/{user}/message/", create {USER_MESSAGE_HANDLER}, router.methods_GET_POST)
- router.map_with_request_methods ("/users/{user}/message/{mesgid}", create {USER_MESSAGE_HANDLER}, <<"GET", "POST">>)
- router.map_with_request_methods ("/users/{user}/message/", create {USER_MESSAGE_HANDLER}, <<"GET", "POST">>)
-
- router.map_agent_response_with_request_methods ("/users/{user}/{?op}", agent response_user, <<"GET">>)
+ router.map_agent_response_with_request_methods ("/users/{user}/{?op}", agent response_user, router.methods_GET)
end
feature -- Execution
@@ -50,6 +49,7 @@ feature -- Execution
local
mesg: WSF_HTML_PAGE_RESPONSE
s: STRING_8
+ l_user_name: READABLE_STRING_32
do
--| It is now returning a WSF_HTML_PAGE_RESPONSE
--| Since it is easier for building html page
@@ -59,9 +59,12 @@ feature -- Execution
--| this could be a query, or a form parameter
if attached {WSF_STRING} req.item ("user") as u then
--| If yes, say hello world #name
- s := "Hello " + u.html_encoded_string + "!
"
- s.append ("Display a message
")
- s.append ("Click here to quit.
")
+
+ l_user_name := (create {HTML_ENCODER}).decoded_string (u.value)
+
+ s := "Hello " + mesg.html_encoded_string (l_user_name) + "!
"
+ s.append ("Display a message")
+ s.append ("Click here to quit.
")
mesg.set_body (s)
--| We should html encode this name
--| but to keep the example simple, we don't do that for now.
@@ -69,7 +72,7 @@ feature -- Execution
--| Otherwise, ask for name
s := (create {HTML_ENCODER}).encoded_string ({STRING_32} "Hello / ahoj / नमस्ते / Ciào / مرحبا / Hola / 你好 / Hallo / Selam / Bonjour ")
s.append ("[
-