Added WSF_CUSTOM_HEADER_FILTER which provide a convenient way to add a custom header from a filter.
Added to wsf_extension WSF_DEBUG_FILTER and WSF_DEBUG_HANDLER that could be convenient to test specific requests Restructured wsf_extension
This commit is contained in:
117
library/server/wsf/extension/filter/wsf_debug_filter.e
Normal file
117
library/server/wsf/extension/filter/wsf_debug_filter.e
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
note
|
||||||
|
description: "Summary description for {WSF_DEBUG_FILTER}."
|
||||||
|
date: "$Date: 2013-05-23 21:54:29 +0200 (jeu., 23 mai 2013) $"
|
||||||
|
revision: "$Revision: 92585 $"
|
||||||
|
|
||||||
|
class
|
||||||
|
WSF_DEBUG_FILTER
|
||||||
|
|
||||||
|
inherit
|
||||||
|
WSF_FILTER
|
||||||
|
|
||||||
|
create
|
||||||
|
default_create,
|
||||||
|
make
|
||||||
|
|
||||||
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
|
make (a_output: FILE)
|
||||||
|
do
|
||||||
|
output := a_output
|
||||||
|
end
|
||||||
|
|
||||||
|
output: detachable FILE
|
||||||
|
|
||||||
|
feature -- Basic operations
|
||||||
|
|
||||||
|
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||||
|
-- Execute the filter
|
||||||
|
local
|
||||||
|
s: STRING_8
|
||||||
|
do
|
||||||
|
create s.make (2048)
|
||||||
|
if attached req.content_type as l_type then
|
||||||
|
s.append ("[length=")
|
||||||
|
s.append_natural_64 (req.content_length_value)
|
||||||
|
s.append_character (']')
|
||||||
|
s.append_character (' ')
|
||||||
|
s.append (l_type.debug_output)
|
||||||
|
s.append_character ('%N')
|
||||||
|
end
|
||||||
|
|
||||||
|
append_iterable_to ("Path parameters", req.path_parameters, s)
|
||||||
|
append_iterable_to ("Query parameters", req.query_parameters, s)
|
||||||
|
append_iterable_to ("Form parameters", req.form_parameters, s)
|
||||||
|
|
||||||
|
if not s.is_empty then
|
||||||
|
s.prepend ("**DEBUG**%N")
|
||||||
|
if attached output as o then
|
||||||
|
o.put_string (s)
|
||||||
|
else
|
||||||
|
res.put_error (s)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
execute_next (req, res)
|
||||||
|
end
|
||||||
|
|
||||||
|
append_iterable_to (a_title: READABLE_STRING_8; it: detachable ITERABLE [WSF_VALUE]; s: STRING_8)
|
||||||
|
local
|
||||||
|
n: INTEGER
|
||||||
|
do
|
||||||
|
if it /= Void then
|
||||||
|
across it as c loop
|
||||||
|
n := n + 1
|
||||||
|
end
|
||||||
|
if n > 0 then
|
||||||
|
s.append (a_title)
|
||||||
|
s.append_character (':')
|
||||||
|
s.append_character ('%N')
|
||||||
|
across
|
||||||
|
it as c
|
||||||
|
loop
|
||||||
|
s.append (" - ")
|
||||||
|
s.append (c.item.url_encoded_name)
|
||||||
|
s.append_character (' ')
|
||||||
|
s.append_character ('{')
|
||||||
|
s.append (c.item.generating_type)
|
||||||
|
s.append_character ('}')
|
||||||
|
s.append_character ('=')
|
||||||
|
s.append (c.item.debug_output.as_string_8)
|
||||||
|
s.append_character ('%N')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
note
|
||||||
|
copyright: "Copyright (c) 1984-2013, Eiffel Software"
|
||||||
|
license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
|
||||||
|
licensing_options: "http://www.eiffel.com/licensing"
|
||||||
|
copying: "[
|
||||||
|
This file is part of Eiffel Software's Eiffel Development Environment.
|
||||||
|
|
||||||
|
Eiffel Software's Eiffel Development Environment is free
|
||||||
|
software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License as published
|
||||||
|
by the Free Software Foundation, version 2 of the License
|
||||||
|
(available at the URL listed under "license" above).
|
||||||
|
|
||||||
|
Eiffel Software's Eiffel Development Environment is
|
||||||
|
distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty
|
||||||
|
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public
|
||||||
|
License along with Eiffel Software's Eiffel Development
|
||||||
|
Environment; if not, write to the Free Software Foundation,
|
||||||
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
]"
|
||||||
|
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
|
||||||
174
library/server/wsf/extension/handler/wsf_debug_handler.e
Normal file
174
library/server/wsf/extension/handler/wsf_debug_handler.e
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
note
|
||||||
|
description: "Summary description for {WSF_DEBUG_HANDLER}."
|
||||||
|
author: ""
|
||||||
|
date: "$Date: 2013-06-28 16:14:02 +0200 (ven., 28 juin 2013) $"
|
||||||
|
revision: "$Revision: 92754 $"
|
||||||
|
|
||||||
|
class
|
||||||
|
WSF_DEBUG_HANDLER
|
||||||
|
|
||||||
|
inherit
|
||||||
|
WSF_STARTS_WITH_HANDLER
|
||||||
|
rename
|
||||||
|
execute as execute_starts_with
|
||||||
|
end
|
||||||
|
|
||||||
|
WSF_SELF_DOCUMENTED_HANDLER
|
||||||
|
|
||||||
|
SHARED_HTML_ENCODER
|
||||||
|
|
||||||
|
SHARED_WSF_PERCENT_ENCODER
|
||||||
|
rename
|
||||||
|
percent_encoder as url_encoder
|
||||||
|
export
|
||||||
|
{NONE} all
|
||||||
|
end
|
||||||
|
|
||||||
|
SHARED_EXECUTION_ENVIRONMENT
|
||||||
|
export
|
||||||
|
{NONE} all
|
||||||
|
end
|
||||||
|
|
||||||
|
create
|
||||||
|
make,
|
||||||
|
make_hidden
|
||||||
|
|
||||||
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
|
make
|
||||||
|
do
|
||||||
|
end
|
||||||
|
|
||||||
|
make_hidden
|
||||||
|
do
|
||||||
|
make
|
||||||
|
is_hidden := True
|
||||||
|
end
|
||||||
|
|
||||||
|
is_hidden: BOOLEAN
|
||||||
|
-- Current mapped handler should be hidden from self documentation
|
||||||
|
|
||||||
|
feature -- Documentation
|
||||||
|
|
||||||
|
mapping_documentation (m: WSF_ROUTER_MAPPING; a_request_methods: detachable WSF_REQUEST_METHODS): WSF_ROUTER_MAPPING_DOCUMENTATION
|
||||||
|
-- <Precursor>
|
||||||
|
do
|
||||||
|
create Result.make (m)
|
||||||
|
Result.set_is_hidden (is_hidden)
|
||||||
|
Result.add_description ("Debug handler (mainly to return request information)")
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Access
|
||||||
|
|
||||||
|
execute_starts_with (a_path: READABLE_STRING_8; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||||
|
local
|
||||||
|
s: STRING_8
|
||||||
|
p: WSF_PAGE_RESPONSE
|
||||||
|
v: STRING_8
|
||||||
|
do
|
||||||
|
if (create {RT_DEBUGGER}).rt_workbench_wait_for_debugger (1050) then
|
||||||
|
end
|
||||||
|
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
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
note
|
||||||
|
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, 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
|
||||||
66
library/server/wsf/router/filter/wsf_custom_header_filter.e
Normal file
66
library/server/wsf/router/filter/wsf_custom_header_filter.e
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
note
|
||||||
|
description: "Summary description for {WSF_CUSTOM_HEADER_FILTER}."
|
||||||
|
date: "$Date: 2013-05-23 21:54:29 +0200 (jeu., 23 mai 2013) $"
|
||||||
|
revision: "$Revision: 92585 $"
|
||||||
|
|
||||||
|
class
|
||||||
|
WSF_CUSTOM_HEADER_FILTER
|
||||||
|
|
||||||
|
inherit
|
||||||
|
WSF_FILTER
|
||||||
|
|
||||||
|
create
|
||||||
|
make
|
||||||
|
|
||||||
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
|
make (n: INTEGER)
|
||||||
|
do
|
||||||
|
create custom_header.make_with_count (n)
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Access
|
||||||
|
|
||||||
|
custom_header: HTTP_HEADER
|
||||||
|
|
||||||
|
feature -- Basic operations
|
||||||
|
|
||||||
|
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||||
|
-- Execute the filter
|
||||||
|
do
|
||||||
|
res.put_header_lines (custom_header)
|
||||||
|
execute_next (req, res)
|
||||||
|
end
|
||||||
|
|
||||||
|
note
|
||||||
|
copyright: "Copyright (c) 1984-2013, Eiffel Software"
|
||||||
|
license: "GPL version 2 (see http://www.eiffel.com/licensing/gpl.txt)"
|
||||||
|
licensing_options: "http://www.eiffel.com/licensing"
|
||||||
|
copying: "[
|
||||||
|
This file is part of Eiffel Software's Eiffel Development Environment.
|
||||||
|
|
||||||
|
Eiffel Software's Eiffel Development Environment is free
|
||||||
|
software; you can redistribute it and/or modify it under
|
||||||
|
the terms of the GNU General Public License as published
|
||||||
|
by the Free Software Foundation, version 2 of the License
|
||||||
|
(available at the URL listed under "license" above).
|
||||||
|
|
||||||
|
Eiffel Software's Eiffel Development Environment is
|
||||||
|
distributed in the hope that it will be useful, but
|
||||||
|
WITHOUT ANY WARRANTY; without even the implied warranty
|
||||||
|
of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
||||||
|
See the GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public
|
||||||
|
License along with Eiffel Software's Eiffel Development
|
||||||
|
Environment; if not, write to the Free Software Foundation,
|
||||||
|
Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||||
|
]"
|
||||||
|
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
|
||||||
Reference in New Issue
Block a user