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)
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
note
|
||||
description: "Summary description for {WSF_ANY}."
|
||||
author: ""
|
||||
description: "[
|
||||
{WSF_ANY} represents a parameter holding any object.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
@@ -15,11 +16,11 @@ create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_name: READABLE_STRING_8; a_value: like item)
|
||||
make (a_name: READABLE_STRING_8; a_value: like value)
|
||||
do
|
||||
name := url_decoded_string (a_name)
|
||||
url_encoded_name := a_name
|
||||
item := a_value
|
||||
value := a_value
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
@@ -28,7 +29,7 @@ feature -- Access
|
||||
|
||||
url_encoded_name: READABLE_STRING_8
|
||||
|
||||
item: detachable ANY
|
||||
value: detachable ANY
|
||||
|
||||
feature -- Element change
|
||||
|
||||
@@ -50,8 +51,8 @@ feature -- Query
|
||||
-- String representation of Current
|
||||
-- if possible
|
||||
do
|
||||
if attached item as i then
|
||||
Result := i.generating_type
|
||||
if attached value as v then
|
||||
Result := v.generating_type
|
||||
else
|
||||
Result := "Void"
|
||||
end
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
note
|
||||
description: "Summary description for {WSF_MULTIPLE_STRING}."
|
||||
author: ""
|
||||
description: "[
|
||||
{WSF_MULTIPLE_STRING} represents a sequence of name=value parameters
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
@@ -25,7 +26,7 @@ feature {NONE} -- Initialization
|
||||
make_with_value (a_value: WSF_VALUE)
|
||||
do
|
||||
name := a_value.name
|
||||
create {LINKED_LIST [WSF_STRING]} string_values.make
|
||||
create {LINKED_LIST [WSF_STRING]} values.make
|
||||
add_value (a_value)
|
||||
end
|
||||
|
||||
@@ -58,11 +59,25 @@ feature -- Access
|
||||
|
||||
name: READABLE_STRING_32
|
||||
|
||||
string_values: LIST [WSF_STRING]
|
||||
values: LIST [WSF_STRING]
|
||||
|
||||
first_string_value: WSF_STRING
|
||||
frozen string_values: like values
|
||||
obsolete
|
||||
"Use `values' [2012-May-31]"
|
||||
do
|
||||
Result := string_values.first
|
||||
Result := values
|
||||
end
|
||||
|
||||
first_value: WSF_STRING
|
||||
do
|
||||
Result := values.first
|
||||
end
|
||||
|
||||
frozen first_string_value: WSF_STRING
|
||||
obsolete
|
||||
"Use `first_value' [2012-May-31]"
|
||||
do
|
||||
Result := first_value
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
@@ -79,15 +94,15 @@ feature -- Status report
|
||||
is_string: BOOLEAN
|
||||
-- Is Current as a WSF_STRING representation?
|
||||
do
|
||||
Result := string_values.count = 1
|
||||
Result := values.count = 1
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
as_string: WSF_STRING
|
||||
do
|
||||
if string_values.count = 1 then
|
||||
Result := first_string_value
|
||||
if values.count = 1 then
|
||||
Result := first_value
|
||||
else
|
||||
Result := Precursor
|
||||
end
|
||||
@@ -97,19 +112,19 @@ feature -- Traversing
|
||||
|
||||
new_cursor: ITERATION_CURSOR [WSF_STRING]
|
||||
do
|
||||
Result := string_values.new_cursor
|
||||
Result := values.new_cursor
|
||||
end
|
||||
|
||||
feature -- Helper
|
||||
|
||||
string_representation: STRING_32
|
||||
do
|
||||
if string_values.count = 1 then
|
||||
create Result.make_from_string (first_string_value)
|
||||
if values.count = 1 then
|
||||
create Result.make_from_string (first_value)
|
||||
else
|
||||
create Result.make_from_string ("[")
|
||||
across
|
||||
string_values as c
|
||||
values as c
|
||||
loop
|
||||
if Result.count > 1 then
|
||||
Result.append_character (',')
|
||||
@@ -139,7 +154,7 @@ feature -- Element change
|
||||
|
||||
add_string_value (s: WSF_STRING)
|
||||
do
|
||||
string_values.extend (s)
|
||||
values.extend (s)
|
||||
end
|
||||
|
||||
feature -- Visitor
|
||||
@@ -150,7 +165,7 @@ feature -- Visitor
|
||||
end
|
||||
|
||||
invariant
|
||||
string_values_not_empty: string_values.count >= 1
|
||||
string_values_not_empty: values.count >= 1
|
||||
|
||||
note
|
||||
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
note
|
||||
description: "Summary description for {WSF_STRING}."
|
||||
author: ""
|
||||
description: "[
|
||||
{WSF_STRING} represents a String parameter
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
@@ -25,21 +26,70 @@ feature {NONE} -- Initialization
|
||||
make (a_name: READABLE_STRING_8; a_string: READABLE_STRING_8)
|
||||
do
|
||||
name := url_decoded_string (a_name)
|
||||
string := url_decoded_string (a_string)
|
||||
value := url_decoded_string (a_string)
|
||||
|
||||
url_encoded_name := a_name
|
||||
url_encoded_string := a_string
|
||||
url_encoded_value := a_string
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
name: READABLE_STRING_32
|
||||
-- <Precursor>
|
||||
--| Note that the value might be html encoded as well
|
||||
--| this is the application responsibility to html decode it
|
||||
|
||||
string: READABLE_STRING_32
|
||||
value: READABLE_STRING_32
|
||||
-- <Precursor>
|
||||
--| Note that the value might be html encoded as well
|
||||
--| this is the application responsibility to html decode it
|
||||
|
||||
url_encoded_name: READABLE_STRING_8
|
||||
-- URL encoded string of `name'.
|
||||
|
||||
url_encoded_string: READABLE_STRING_8
|
||||
url_encoded_value: READABLE_STRING_8
|
||||
-- URL encoded string of `value'.
|
||||
|
||||
frozen string: like value
|
||||
obsolete
|
||||
"Use value [2012-May-31]"
|
||||
do
|
||||
Result := value
|
||||
end
|
||||
|
||||
frozen url_encoded_string: like url_encoded_value
|
||||
obsolete
|
||||
"Use url_encoded_value [2012-May-31]"
|
||||
do
|
||||
Result := url_encoded_value
|
||||
end
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
integer_value: INTEGER
|
||||
-- Integer value of `value'.
|
||||
require
|
||||
value_is_integer: is_integer
|
||||
do
|
||||
Result := value.to_integer
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_string: BOOLEAN = True
|
||||
-- Is Current as a WSF_STRING representation?
|
||||
|
||||
is_empty: BOOLEAN
|
||||
-- Is empty?
|
||||
do
|
||||
Result := value.is_empty
|
||||
end
|
||||
|
||||
is_integer: BOOLEAN
|
||||
-- Is `value' an integer?
|
||||
do
|
||||
Result := value.is_integer
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
@@ -51,31 +101,20 @@ feature -- Element change
|
||||
a_name.same_string (url_encoded_name)
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_string: BOOLEAN = True
|
||||
-- Is Current as a WSF_STRING representation?
|
||||
|
||||
is_empty: BOOLEAN
|
||||
-- Is empty?
|
||||
do
|
||||
Result := string.is_empty
|
||||
end
|
||||
|
||||
feature -- Helper
|
||||
|
||||
same_string (a_other: READABLE_STRING_GENERAL): BOOLEAN
|
||||
-- Does `a_other' represent the same string as `Current'?
|
||||
do
|
||||
Result := string.same_string_general (a_other)
|
||||
Result := value.same_string_general (a_other)
|
||||
end
|
||||
|
||||
is_case_insensitive_equal (a_other: READABLE_STRING_8): BOOLEAN
|
||||
-- Does `a_other' represent the same case insensitive string as `Current'?
|
||||
local
|
||||
v: like string
|
||||
v: like value
|
||||
do
|
||||
v := string
|
||||
v := value
|
||||
if v = a_other then
|
||||
Result := True
|
||||
elseif v.is_valid_as_string_8 then
|
||||
@@ -87,26 +126,7 @@ feature -- Conversion
|
||||
|
||||
string_representation: STRING_32
|
||||
do
|
||||
create Result.make_from_string (string)
|
||||
end
|
||||
|
||||
html_encoded_name: READABLE_STRING_8
|
||||
-- HTML encoded string `name'
|
||||
do
|
||||
Result := (create {HTML_ENCODER}).encoded_string (name)
|
||||
end
|
||||
|
||||
html_encoded_string: READABLE_STRING_8
|
||||
-- HTML encoded string `string'
|
||||
do
|
||||
Result := (create {HTML_ENCODER}).encoded_string (string)
|
||||
end
|
||||
|
||||
feature {NONE} -- Conversion
|
||||
|
||||
html_decoded_string (s: READABLE_STRING_GENERAL): READABLE_STRING_32
|
||||
do
|
||||
Result := (create {HTML_ENCODER}).general_decoded_string (s)
|
||||
create Result.make_from_string (value)
|
||||
end
|
||||
|
||||
feature -- Visitor
|
||||
|
||||
@@ -47,7 +47,7 @@ feature -- Access
|
||||
end
|
||||
end
|
||||
|
||||
first_key: detachable READABLE_STRING_32
|
||||
first_name: detachable READABLE_STRING_32
|
||||
do
|
||||
across
|
||||
values as c
|
||||
@@ -70,6 +70,13 @@ feature -- Access
|
||||
Result := values.count
|
||||
end
|
||||
|
||||
frozen first_key: like first_name
|
||||
obsolete
|
||||
"Use first_name [2012-May-31]"
|
||||
do
|
||||
Result := first_name
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
change_name (a_name: like name)
|
||||
@@ -122,7 +129,7 @@ feature -- Helper
|
||||
string_representation: STRING_32
|
||||
do
|
||||
create Result.make_from_string ("{")
|
||||
if values.count = 1 and then attached first_key as fk then
|
||||
if values.count = 1 and then attached first_name as fk then
|
||||
Result.append (fk + ": ")
|
||||
if attached value (fk) as fv then
|
||||
Result.append (fv.string_representation)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
note
|
||||
description: "Summary description for {WSF_UPLOADED_FILE}."
|
||||
author: ""
|
||||
description: "[
|
||||
{WSF_UPLOADED_FILE} represents an uploaded file from form parameters.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
@@ -40,13 +41,11 @@ feature -- Element change
|
||||
a_name.same_string (url_encoded_name)
|
||||
end
|
||||
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_string: BOOLEAN = False
|
||||
-- Is Current as a WSF_STRING representation?
|
||||
|
||||
|
||||
feature -- Conversion
|
||||
|
||||
string_representation: STRING_32
|
||||
|
||||
@@ -16,6 +16,11 @@ feature -- Access
|
||||
deferred
|
||||
end
|
||||
|
||||
frozen key: like name
|
||||
do
|
||||
Result := name
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
|
||||
change_name (a_name: like name)
|
||||
@@ -78,7 +83,7 @@ feature -- Status report
|
||||
debug_output: STRING
|
||||
-- String that should be displayed in debugger to represent `Current'.
|
||||
do
|
||||
create Result.make_from_string (name.as_string_8 + "=" + string_representation.as_string_8)
|
||||
create Result.make_from_string (url_encoder.encoded_string (name) + "=" + url_encoder.encoded_string (string_representation))
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
@@ -104,7 +104,7 @@ feature -- Element change
|
||||
answer_head_request_method := b
|
||||
end
|
||||
|
||||
feature {WSF_SERVICE, WSF_RESPONSE} -- Basic operations
|
||||
feature {WSF_RESPONSE} -- Output
|
||||
|
||||
send_to (res: WSF_RESPONSE)
|
||||
do
|
||||
|
||||
@@ -150,7 +150,7 @@ feature -- Element change
|
||||
update_content_length
|
||||
end
|
||||
|
||||
feature {WSF_SERVICE, WSF_RESPONSE} -- Output
|
||||
feature {WSF_RESPONSE} -- Output
|
||||
|
||||
send_to (res: WSF_RESPONSE)
|
||||
local
|
||||
|
||||
@@ -110,7 +110,7 @@ feature -- Element change
|
||||
body := b
|
||||
end
|
||||
|
||||
feature {WSF_SERVICE, WSF_RESPONSE} -- Output
|
||||
feature {WSF_RESPONSE} -- Output
|
||||
|
||||
send_to (res: WSF_RESPONSE)
|
||||
local
|
||||
@@ -147,8 +147,20 @@ feature {WSF_SERVICE, WSF_RESPONSE} -- Output
|
||||
res.put_string (s)
|
||||
end
|
||||
|
||||
feature -- HTML facilities
|
||||
|
||||
html_encoded_string (s: READABLE_STRING_32): READABLE_STRING_8
|
||||
do
|
||||
Result := html_encoder.encoded_string (s)
|
||||
end
|
||||
|
||||
feature {NONE} -- HTML Generation
|
||||
|
||||
html_encoder: HTML_ENCODER
|
||||
once ("thread")
|
||||
create Result
|
||||
end
|
||||
|
||||
append_html_head_code (s: STRING_8)
|
||||
local
|
||||
t: like title
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
note
|
||||
description: "[
|
||||
Immediate redirection with HTML content
|
||||
Immediate redirection with HTML content
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
@@ -41,7 +41,7 @@ feature -- Element change
|
||||
url_location := a_url_location
|
||||
end
|
||||
|
||||
feature {WSF_SERVICE, WSF_RESPONSE} -- Output
|
||||
feature {WSF_RESPONSE} -- Output
|
||||
|
||||
send_to (res: WSF_RESPONSE)
|
||||
local
|
||||
|
||||
@@ -79,7 +79,7 @@ feature -- Element change
|
||||
l_body.append (a_string)
|
||||
end
|
||||
|
||||
feature {WSF_SERVICE, WSF_RESPONSE} -- Output
|
||||
feature {WSF_RESPONSE} -- Output
|
||||
|
||||
send_to (res: WSF_RESPONSE)
|
||||
local
|
||||
|
||||
@@ -70,7 +70,7 @@ feature -- Element change
|
||||
content_type := Void
|
||||
end
|
||||
|
||||
feature {WSF_SERVICE, WSF_RESPONSE} -- Output
|
||||
feature {WSF_RESPONSE} -- Output
|
||||
|
||||
send_to (res: WSF_RESPONSE)
|
||||
local
|
||||
|
||||
@@ -87,12 +87,12 @@ feature {NONE} -- Initialization
|
||||
end
|
||||
|
||||
--| PATH_INFO
|
||||
path_info := url_encoder.decoded_string (wgi_request.path_info)
|
||||
path_info := raw_url_encoder.decoded_string (wgi_request.path_info)
|
||||
|
||||
--| PATH_TRANSLATED
|
||||
s8 := wgi_request.path_translated
|
||||
if s8 /= Void then
|
||||
path_translated := url_encoder.decoded_string (s8)
|
||||
path_translated := raw_url_encoder.decoded_string (s8)
|
||||
end
|
||||
|
||||
--| Here one can set its own environment entries if needed
|
||||
@@ -253,7 +253,7 @@ feature -- Access: global variable
|
||||
string_item (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_32
|
||||
do
|
||||
if attached {WSF_STRING} item (a_name) as val then
|
||||
Result := val.string
|
||||
Result := val.value
|
||||
else
|
||||
check is_string_value: False end
|
||||
end
|
||||
@@ -303,7 +303,7 @@ feature -- Access: CGI Meta variables
|
||||
a_name_valid: a_name /= Void and then not a_name.is_empty
|
||||
do
|
||||
if attached meta_variable (a_name) as val then
|
||||
Result := val.string
|
||||
Result := val.value
|
||||
end
|
||||
end
|
||||
|
||||
@@ -317,7 +317,7 @@ feature -- Access: CGI Meta variables
|
||||
a_name_not_empty: a_name /= Void and then not a_name.is_empty
|
||||
do
|
||||
if attached meta_variable (a_name) as val then
|
||||
Result := val.string
|
||||
Result := val.value
|
||||
if use_default_when_empty and then Result.is_empty then
|
||||
Result := a_default
|
||||
end
|
||||
@@ -332,7 +332,7 @@ feature -- Access: CGI Meta variables
|
||||
do
|
||||
meta_variables_table.force (new_string_value (a_name, a_value), a_name)
|
||||
ensure
|
||||
param_set: attached {WSF_STRING} meta_variable (a_name) as val and then val.url_encoded_string.same_string (a_value)
|
||||
param_set: attached {WSF_STRING} meta_variable (a_name) as val and then val.url_encoded_value.same_string (a_value)
|
||||
end
|
||||
|
||||
unset_meta_variable (a_name: READABLE_STRING_GENERAL)
|
||||
@@ -825,9 +825,9 @@ feature -- Extra CGI environment variables
|
||||
do
|
||||
if
|
||||
attached {WSF_STRING} meta_variable ({WSF_META_NAMES}.request_time) as t and then
|
||||
t.string.is_integer_64
|
||||
t.value.is_integer_64
|
||||
then
|
||||
Result := date_time_utilities.unix_time_stamp_to_date_time (t.string.to_integer_64)
|
||||
Result := date_time_utilities.unix_time_stamp_to_date_time (t.value.to_integer_64)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -857,7 +857,7 @@ feature {NONE} -- Cookies
|
||||
l_cookies := internal_cookies_table
|
||||
if l_cookies = Void then
|
||||
if attached {WSF_STRING} meta_variable ({WSF_META_NAMES}.http_cookie) as val then
|
||||
s := val.string
|
||||
s := val.value
|
||||
create l_cookies.make_with_key_tester (5, string_equality_tester)
|
||||
l_cookies.compare_objects
|
||||
from
|
||||
@@ -1582,6 +1582,11 @@ feature {NONE} -- Implementation: utilities
|
||||
empty_string: READABLE_STRING_32
|
||||
-- Reusable empty string
|
||||
|
||||
raw_url_encoder: URL_ENCODER
|
||||
once
|
||||
create {URL_ENCODER} Result
|
||||
end
|
||||
|
||||
url_encoder: URL_ENCODER
|
||||
once
|
||||
create {UTF8_URL_ENCODER} Result
|
||||
|
||||
@@ -1,17 +1,24 @@
|
||||
note
|
||||
description: "Summary description for {WSF_RESPONSE_MESSAGE}."
|
||||
author: ""
|
||||
description: "[
|
||||
Object to represent a full message to be send to the client
|
||||
via {WSF_RESPONSE}.send (obj)
|
||||
|
||||
The only requirement is to implement correctly the `send_to (WSF_RESPONSE)'
|
||||
method.
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
deferred class
|
||||
WSF_RESPONSE_MESSAGE
|
||||
|
||||
feature {WSF_SERVICE, WSF_RESPONSE} -- Output
|
||||
feature {WSF_RESPONSE} -- Output
|
||||
|
||||
send_to (res: WSF_RESPONSE)
|
||||
-- Send Current message to `res'
|
||||
--| This should not be called by user's code directly
|
||||
--
|
||||
-- This feature should be called via `{WSF_RESPONSE}.send (obj)'
|
||||
-- where `obj' is the current object
|
||||
require
|
||||
header_not_committed: not res.header_committed
|
||||
status_not_committed: not res.status_committed
|
||||
|
||||
Reference in New Issue
Block a user