merged from upstream

This commit is contained in:
Colin Adams
2012-12-08 08:25:47 +00:00
51 changed files with 472 additions and 269 deletions

View File

@@ -1,40 +0,0 @@
note
description: "Logging filter."
author: "Olivier Ligot"
date: "$Date$"
revision: "$Revision$"
class
LOGGING_FILTER
inherit
WSF_FILTER
feature -- Basic operations
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute the filter
local
l_user_agent: STRING
l_date: DATE_TIME
do
if attached req.http_user_agent as ua then
l_user_agent := ua.as_string_8
else
l_user_agent := "-"
end
create l_date.make_now
io.put_string ("[" + l_date.formatted_out (Date_time_format) + "] %"" + req.request_method + " " + req.request_uri
+ " " + {HTTP_CONSTANTS}.http_version_1_1 + "%" " + res.status_code.out + " " + l_user_agent)
io.put_new_line
execute_next (req, res)
end
feature -- Constants
Date_time_format: STRING = "yyyy/[0]mm/[0]dd [0]hh:[0]mi:[0]ss.ff3"
note
copyright: "2011-2012, Olivier Ligot, Jocelyn Fiat and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end

View File

@@ -53,7 +53,7 @@ feature {NONE} -- Initialization
setup_filter
-- Setup `filter'
local
l_logging_filter: LOGGING_FILTER
l_logging_filter: WSF_LOGGING_FILTER
do
create l_logging_filter
filter.set_next (l_logging_filter)

View File

@@ -17,7 +17,7 @@ feature {NONE} -- Initialization
local
h: LIBCURL_HTTP_CLIENT
sess: HTTP_CLIENT_SESSION
resp : HTTP_CLIENT_RESPONSE
resp : detachable HTTP_CLIENT_RESPONSE
l_location : detachable READABLE_STRING_8
body : STRING
do
@@ -39,7 +39,7 @@ feature {NONE} -- Initialization
-- Update the Order
if attached resp.body as l_body then
if resp /= Void and then attached resp.body as l_body then
body := l_body.as_string_8
body.replace_substring_all ("takeAway", "in Shop")
print ("%N Update Order %N")
@@ -47,11 +47,10 @@ feature {NONE} -- Initialization
end
end
update_order ( sess: HTTP_CLIENT_SESSION; uri : detachable READABLE_STRING_8; a_body : STRING) : HTTP_CLIENT_RESPONSE
update_order ( sess: HTTP_CLIENT_SESSION; uri : detachable READABLE_STRING_8; a_body : STRING): detachable HTTP_CLIENT_RESPONSE
local
context : HTTP_CLIENT_REQUEST_CONTEXT
do
create Result.make
if attached uri as l_uri then
sess.set_base_url (l_uri)
create context.make
@@ -74,9 +73,8 @@ feature {NONE} -- Initialization
end
read_order ( sess: HTTP_CLIENT_SESSION; uri : detachable READABLE_STRING_8) : HTTP_CLIENT_RESPONSE
read_order ( sess: HTTP_CLIENT_SESSION; uri : detachable READABLE_STRING_8): detachable HTTP_CLIENT_RESPONSE
do
create Result.make
if attached uri as l_uri then
sess.set_base_url (l_uri)
Result := sess.get ("", Void)

View File

@@ -10,6 +10,9 @@ inherit
ANY
WSF_URI_TEMPLATE_ROUTED_SERVICE
redefine
execute_default
end
WSF_HANDLER_HELPER
@@ -30,10 +33,13 @@ feature {NONE} -- Initialization
setup_router
local
order_handler: ORDER_HANDLER
doc: WSF_ROUTER_SELF_DOCUMENTATION_HANDLER
do
create order_handler
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
feature -- Execution
@@ -54,6 +60,7 @@ feature -- Execution
h.put_content_type_text_plain
l_api_doc := "%NPlease check the API%NURI:/order METHOD: POST%NURI:/order/{orderid} METHOD: GET, PUT, DELETE%N"
l_description := req.request_method + req.request_uri + " is not allowed" + "%N" + l_api_doc
l_description.append ("%NHTML documentation:/api/doc METHOD: GET%N")
h.put_content_length (l_description.count)
h.put_current_date
res.set_status_code ({HTTP_STATUS_CODE}.method_not_allowed)

View File

@@ -62,7 +62,7 @@ feature -- Execution
end
note
copyright: "2011-2011, Eiffel Software and others"
copyright: "2011-2012, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -61,7 +61,7 @@ feature -- Request processing
process_request (a_handler: HTTP_CONNECTION_HANDLER; a_socket: TCP_STREAM_SOCKET)
-- Process request ...
local
env, vars: HASH_TABLE [STRING, STRING]
env: HASH_TABLE [STRING, STRING]
p: INTEGER
l_request_uri, l_script_name, l_query_string, l_path_info: STRING
l_server_name, l_server_port: detachable STRING
@@ -73,8 +73,16 @@ feature -- Request processing
l_request_uri := a_handler.uri
a_headers_map := a_handler.request_header_map
create e
vars := e.starting_environment_variables
env := vars.twin
if attached e.starting_environment_variables as vars then
create env.make (vars.count)
across
vars as c
loop
env.force (c.item.to_string_8, c.key.to_string_8)
end
else
create env.make (0)
end
--| for Any Abc-Def-Ghi add (or replace) the HTTP_ABC_DEF_GHI variable to `env'
from
@@ -189,7 +197,7 @@ feature -- Request processing
end
note
copyright: "2011-2011, Eiffel Software and others"
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

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-8-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-8-0 http://www.eiffel.com/developers/xml/configuration-1-8-0.xsd" name="connector_cgi" uuid="3BCBC1C5-9D99-45BB-B15D-B03D2C069CED" library_target="connector_cgi">
<target name="connector_cgi">
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-8-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-8-0 http://www.eiffel.com/developers/xml/configuration-1-8-0.xsd" name="connector_cgi" uuid="D55DC7A7-AAFA-43C6-B432-A192FF64141E" library_target="connector_null">
<target name="connector_null">
<root all_classes="true"/>
<file_rule>
<exclude>/EIFGENs$</exclude>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-8-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-8-0 http://www.eiffel.com/developers/xml/configuration-1-8-0.xsd" name="connector_cgi" uuid="3BCBC1C5-9D99-45BB-B15D-B03D2C069CED" library_target="connector_cgi">
<target name="connector_cgi">
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-8-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-8-0 http://www.eiffel.com/developers/xml/configuration-1-8-0.xsd" name="connector_cgi" uuid="D55DC7A7-AAFA-43C6-B432-A192FF64141E" library_target="connector_null">
<target name="connector_null">
<root all_classes="true"/>
<file_rule>
<exclude>/EIFGENs$</exclude>

View File

@@ -19,7 +19,7 @@ create
feature {NONE} -- Initialization
make (a_vars: HASH_TABLE [READABLE_STRING_8, READABLE_STRING_8]; a_input: like input; a_wgi_connector: like wgi_connector)
make (a_vars: HASH_TABLE [READABLE_STRING_GENERAL, READABLE_STRING_GENERAL]; a_input: like input; a_wgi_connector: like wgi_connector)
require
vars_attached: a_vars /= Void
do
@@ -244,7 +244,7 @@ feature -- Access: Extension to CGI meta parameters - 1.1
feature {NONE} -- Element change: CGI meta parameter related to PATH_INFO
set_meta_variables (a_vars: HASH_TABLE [READABLE_STRING_8, READABLE_STRING_8])
set_meta_variables (a_vars: HASH_TABLE [READABLE_STRING_GENERAL, READABLE_STRING_GENERAL])
-- Fill with variable from `a_vars'
local
s: like meta_string_variable
@@ -264,7 +264,7 @@ feature {NONE} -- Element change: CGI meta parameter related to PATH_INFO
until
a_vars.after
loop
table.force (a_vars.item_for_iteration, a_vars.key_for_iteration)
table.force (a_vars.item_for_iteration.to_string_8, a_vars.key_for_iteration.to_string_8)
a_vars.forth
end

View File

@@ -1,52 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-6-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-6-0 http://www.eiffel.com/developers/xml/configuration-1-6-0.xsd" name="fcgi" uuid="3F4BCF74-3503-4533-9D74-5A65EC4CA3C4" library_target="fcgi">
<target name="fcgi">
<root all_classes="true"/>
<file_rule>
<exclude>/\.svn$</exclude>
<exclude>/\.git$</exclude>
<exclude>/EIFGENs$</exclude>
</file_rule>
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" >
</option>
<external_include location="$ECF_CONFIG_PATH/spec/include/libfcgi">
<condition>
<platform excluded_value="windows"/>
</condition>
</external_include>
<external_include location="$ECF_CONFIG_PATH\spec\include\libfcgi">
<condition>
<platform value="windows"/>
</condition>
</external_include>
<external_library location="$ECF_CONFIG_PATH\spec\lib\$ISE_PLATFORM\$ISE_C_COMPILER\libfcgi.lib">
<condition>
<platform value="windows"/>
</condition>
</external_library>
<external_library location="/usr/lib/libfcgi.so">
<condition>
<platform excluded_value="windows"/>
</condition>
</external_library>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<cluster name="interface" location="interface" recursive="true"/>
<cluster name="implementation" location="implementation" recursive="true">
<file_rule>
<exclude>/linux$</exclude>
<exclude>/fake$</exclude>
<condition>
<platform value="windows"/>
</condition>
</file_rule>
<file_rule>
<exclude>/windows$</exclude>
<exclude>/fake$</exclude>
<condition>
<platform excluded_value="windows"/>
</condition>
</file_rule>
</cluster>
</target>
</system>

View File

@@ -1,52 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-6-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-6-0 http://www.eiffel.com/developers/xml/configuration-1-6-0.xsd" name="fcgi" uuid="3F4BCF74-3503-4533-9D74-5A65EC4CA3C4" library_target="fcgi">
<target name="fcgi">
<root all_classes="true"/>
<file_rule>
<exclude>/\.svn$</exclude>
<exclude>/\.git$</exclude>
<exclude>/EIFGENs$</exclude>
</file_rule>
<option warning="true" full_class_checking="true">
</option>
<external_include location="$ECF_CONFIG_PATH/spec/include/libfcgi">
<condition>
<platform excluded_value="windows"/>
</condition>
</external_include>
<external_include location="$ECF_CONFIG_PATH\spec\include\libfcgi">
<condition>
<platform value="windows"/>
</condition>
</external_include>
<external_library location="$ECF_CONFIG_PATH\spec\lib\$ISE_PLATFORM\$ISE_C_COMPILER\libfcgi.lib">
<condition>
<platform value="windows"/>
</condition>
</external_library>
<external_library location="/usr/lib/libfcgi.so">
<condition>
<platform excluded_value="windows"/>
</condition>
</external_library>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<cluster name="interface" location="interface" recursive="true"/>
<cluster name="implementation" location="implementation" recursive="true">
<file_rule>
<exclude>/linux$</exclude>
<exclude>/fake$</exclude>
<condition>
<platform value="windows"/>
</condition>
</file_rule>
<file_rule>
<exclude>/windows$</exclude>
<exclude>/fake$</exclude>
<condition>
<platform excluded_value="windows"/>
</condition>
</file_rule>
</cluster>
</target>
</system>

View File

@@ -10,7 +10,7 @@
<setting name="console_application" value="true"/>
<setting name="concurrency" value="thread"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="fcgi" location="..\fcgi-safe.ecf" readonly="false"/>
<library name="fcgi" location="..\libfcgi-safe.ecf" readonly="false"/>
<cluster name="application" location=".\" recursive="true"/>
</target>
</system>

View File

@@ -10,7 +10,7 @@
<setting name="console_application" value="true"/>
<setting name="concurrency" value="thread"/>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="fcgi" location="..\fcgi.ecf" readonly="false"/>
<library name="fcgi" location="..\libfcgi.ecf" readonly="false"/>
<cluster name="application" location=".\" recursive="true"/>
</target>
</system>

View File

@@ -1 +0,0 @@
Now the router library is part of ../../wsf library

View File

@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-8-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-8-0 http://www.eiffel.com/developers/xml/configuration-1-8-0.xsd" name="router" uuid="7E530655-8578-4AF8-99CA-175A0025D843" library_target="router">
<target name="router">
<root all_classes="true"/>
<file_rule>
<exclude>/.git$</exclude>
<exclude>/EIFGENs$</exclude>
<exclude>/.svn$</exclude>
</file_rule>
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="provisional">
<assertions precondition="true"/>
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="wsf" location="..\..\wsf\wsf-safe.ecf" readonly="false"/>
</target>
</system>

View File

@@ -1,16 +0,0 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-8-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-8-0 http://www.eiffel.com/developers/xml/configuration-1-8-0.xsd" name="router" uuid="7E530655-8578-4AF8-99CA-175A0025D843" library_target="router">
<target name="router">
<root all_classes="true"/>
<file_rule>
<exclude>/.git$</exclude>
<exclude>/EIFGENs$</exclude>
<exclude>/.svn$</exclude>
</file_rule>
<option warning="true" full_class_checking="true" syntax="provisional">
<assertions precondition="true"/>
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="wsf" location="..\..\wsf\wsf.ecf"/>
</target>
</system>

View File

@@ -8,6 +8,7 @@
<exclude>/\.svn$</exclude>
</file_rule>
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="provisional"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="wsf" location="../wsf-safe.ecf"/>
<library name="wsf_cgi" location="../connector/cgi-safe.ecf"/>
<cluster name="default_cgi" location="./cgi" recursive="true"/>

View File

@@ -9,6 +9,7 @@
</file_rule>
<option warning="true" full_class_checking="true" syntax="provisional">
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="wsf" location="../wsf.ecf"/>
<library name="wsf_cgi" location="../connector/cgi.ecf"/>
<cluster name="default_cgi" location="./cgi" recursive="true"/>

View File

@@ -8,6 +8,7 @@
<exclude>/\.svn$</exclude>
</file_rule>
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="provisional"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="wsf" location="../wsf-safe.ecf"/>
<library name="wsf_libfcgi" location="../connector/libfcgi-safe.ecf"/>
<cluster name="default_libfcgi" location="./libfcgi" recursive="true"/>

View File

@@ -8,6 +8,7 @@
<exclude>/\.svn$</exclude>
</file_rule>
<option warning="true" full_class_checking="true" syntax="provisional"/>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="wsf" location="../wsf.ecf"/>
<library name="wsf_libfcgi" location="../connector/libfcgi.ecf"/>
<cluster name="default_libfcgi" location="./libfcgi" recursive="true"/>

View File

@@ -8,6 +8,7 @@
<exclude>/\.svn$</exclude>
</file_rule>
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="provisional"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="wsf" location="../wsf-safe.ecf"/>
<library name="wsf_nino" location="../connector/nino-safe.ecf"/>
<cluster name="default_nino" location="./nino" recursive="true"/>

View File

@@ -8,6 +8,7 @@
<exclude>/\.svn$</exclude>
</file_rule>
<option warning="true" full_class_checking="true" syntax="provisional"/>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="wsf" location="../wsf.ecf"/>
<library name="wsf_nino" location="../connector/nino.ecf"/>
<cluster name="default_nino" location="./nino" recursive="true"/>

View File

@@ -9,6 +9,9 @@ deferred class
inherit
WSF_ROUTER_MAPPING
redefine
debug_output
end
feature -- Access
@@ -17,6 +20,14 @@ feature -- Access
deferred
end
feature -- Status report
debug_output: STRING
-- String that should be displayed in debugger to represent `Current'.
do
Result := Precursor + " {" + ({C}).name + "}"
end
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"

View File

@@ -17,8 +17,11 @@ inherit
on_mapped
end
WSF_SELF_DOCUMENTED_HANDLER
create
make
make,
make_hidden
feature {NONE} -- Initialization
@@ -27,10 +30,28 @@ feature {NONE} -- Initialization
router := a_router
end
make_hidden (a_router: WSF_ROUTER)
do
make (a_router)
is_hidden := True
end
router: WSF_ROUTER
resource: detachable STRING
is_hidden: BOOLEAN
-- Current mapped handler should be hidden from self documentation
feature -- Documentation
mapping_documentation (m: WSF_ROUTER_MAPPING): WSF_ROUTER_MAPPING_DOCUMENTATION
do
create Result.make (m)
Result.set_is_hidden (is_hidden)
Result.add_description ("Self generated documentation based on the router's setup")
end
feature {WSF_ROUTER} -- Mapping
on_mapped (a_mapping: WSF_ROUTER_MAPPING; a_rqst_methods: detachable WSF_ROUTER_METHODS)

View File

@@ -195,7 +195,6 @@ feature {WSF_RESPONSE} -- Output
local
l_url: detachable STRING_8
l_base_url: detachable READABLE_STRING_8
hdl: WSF_HANDLER
l_doc: detachable WSF_ROUTER_MAPPING_DOCUMENTATION
do
if attached {WSF_SELF_DOCUMENTED_ROUTER_MAPPING} m as l_doc_mapping then
@@ -223,21 +222,24 @@ feature {WSF_RESPONSE} -- Output
s.append ("</code>")
if meths /= Void then
s.append (" [ ")
s.append (" [")
across
meths as rq
loop
s.append_character (' ')
if l_url /= Void and then rq.item.is_case_insensitive_equal ("GET") then
s.append ("<a href=%"" + l_base_url + l_url + "%">" + rq.item + "</a>")
else
s.append (rq.item)
end
if not rq.is_last then
s.append (",")
end
s.append (" ")
s.append_character (',')
end
s.append ("]")
if s[s.count] = ',' then
s.put (' ', s.count)
else
s.append_character (' ')
end
s.append_character (']')
end
s.append (" <em class=%"mappingdoc%">" + html_encoder.encoded_string (m.description) + "</em> ")

View File

@@ -0,0 +1,93 @@
note
description: "Logging filter."
author: "Olivier Ligot"
date: "$Date$"
revision: "$Revision$"
class
WSF_LOGGING_FILTER
inherit
WSF_FILTER
redefine
default_create
end
create
default_create,
make_with_output
feature {NONE} -- Initialization
default_create
do
Precursor
output := io.output
end
make_with_output (a_output: like output)
-- Create Current with `a_output' as `output'
require
a_output_opened: a_output.is_open_read
do
default_create
output := a_output
end
output: FILE
-- Output file
--| Could be stdout, or a file...
feature -- Basic operations
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute the filter
local
l_date: DATE_TIME
s: STRING
do
create s.make (64)
s.append (req.remote_addr)
s.append (" - - [")
create l_date.make_now_utc
s.append (l_date.formatted_out (Date_time_format))
s.append (" GMT] %"")
s.append (req.request_method)
s.append_character (' ')
s.append (req.request_uri)
s.append_character (' ')
s.append ({HTTP_CONSTANTS}.http_version_1_1)
s.append_character ('%"')
s.append_character (' ')
s.append_integer (res.status_code)
s.append_character (' ')
s.append_natural_64 (res.transfered_content_length)
s.append_character (' ')
if attached req.http_referer as r then
s.append_character ('%"')
s.append_character ('%"')
s.append (r)
s.append_character (' ')
end
if attached req.http_user_agent as ua then
s.append_character ('%"')
s.append (ua)
s.append_character ('%"')
else
s.append_character ('-')
end
output.put_string (s)
output.put_new_line
execute_next (req, res)
end
feature -- Constants
Date_time_format: STRING = "[0]dd/[0]mm/yyyy [0]hh:[0]mi:[0]ss"
note
copyright: "2011-2012, Olivier Ligot, Jocelyn Fiat and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end

View File

@@ -10,6 +10,8 @@ class
inherit
WSF_ROUTER_MAPPING
WSF_SELF_DOCUMENTED_ROUTER_MAPPING
create
make

View File

@@ -12,8 +12,6 @@ inherit
WSF_SELF_DOCUMENTED_ROUTER_MAPPING
DEBUG_OUTPUT
create
make,
make_from_template
@@ -47,14 +45,6 @@ feature -- Documentation
description: STRING_32 = "Match-URI-Template"
feature -- Status report
debug_output: STRING
-- String that should be displayed in debugger to represent `Current'.
do
Result := "URI-template: " + template.template
end
feature -- Element change
set_handler (h: like handler)

View File

@@ -11,8 +11,9 @@ inherit
WSF_ROUTER_CONTEXT_MAPPING [C]
WSF_SELF_DOCUMENTED_ROUTER_MAPPING
DEBUG_OUTPUT
undefine
debug_output
end
create
make,
@@ -45,15 +46,7 @@ feature -- Access
feature -- Documentation
description: STRING_32 = "Is-URI"
feature -- Status report
debug_output: STRING
-- String that should be displayed in debugger to represent `Current'.
do
Result := "URI-template: " + template.template
end
description: STRING_32 = "Match-URI-Template"
feature -- Element change

View File

@@ -47,7 +47,11 @@ feature -- Execution
execute_default (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Default procedure
deferred
local
not_found: WSF_NOT_FOUND_RESPONSE
do
create not_found.make (req)
res.send (not_found)
end
feature -- Access

View File

@@ -1,6 +1,10 @@
note
description: "Summary description for {EWF_ROUTER}."
author: ""
description: "[
URL dispatching of request
Map a route to an handler according to the request method and path
]"
date: "$Date$"
revision: "$Revision$"
@@ -10,6 +14,8 @@ class
inherit
ITERABLE [WSF_ROUTER_ITEM]
WSF_REQUEST_EXPORTER
create
make,
make_with_base_url
@@ -53,8 +59,15 @@ feature -- Mapping
map_with_request_methods (a_mapping: WSF_ROUTER_MAPPING; rqst_methods: detachable WSF_ROUTER_METHODS)
-- Map `a_mapping' for request methods `rqst_methods'
do
if attached rqst_methods as l_rm and then l_rm.has ({HTTP_REQUEST_METHODS}.method_get) then
l_rm.enable_head
debug ("router")
-- Display conflict in mapping
if has_item_associated_with_resource (a_mapping.associated_resource, rqst_methods) then
io.error.put_string ("Mapping: " + a_mapping.debug_output + ": conflict with existing mapping")
if attached item_associated_with_resource (a_mapping.associated_resource, rqst_methods) as l_conflicted then
io.error.put_string (": " + l_conflicted.debug_output)
end
io.error.put_string ("%N")
end
end
mappings.extend (create {WSF_ROUTER_ITEM}.make_with_request_methods (a_mapping, rqst_methods))
a_mapping.handler.on_mapped (a_mapping, rqst_methods)
@@ -95,10 +108,28 @@ feature -- Access
-- And return the associated handler if mapping found and handler executed.
local
l_req_method: READABLE_STRING_8
head_res: WSF_HEAD_RESPONSE_WRAPPER
do
l_req_method := request_method (req)
is_dispatched := False
Result := dispatch_and_return_handler_for_request_method (req, res, l_req_method)
if Result = Void and l_req_method = {HTTP_REQUEST_METHODS}.method_head then
check is_not_dispatched: not is_dispatched end
create head_res.make_from_response (res)
req.set_request_method ({HTTP_REQUEST_METHODS}.method_GET)
Result := dispatch_and_return_handler_for_request_method (req, head_res, {HTTP_REQUEST_METHODS}.method_GET)
end
end
feature {NONE} -- Dispatch implementation
dispatch_and_return_handler_for_request_method (req: WSF_REQUEST; res: WSF_RESPONSE; a_request_method: READABLE_STRING_8): detachable WSF_HANDLER
-- Dispatch request `req' among the `mappings'
-- And return the associated handler if mapping found and handler executed.
local
m: WSF_ROUTER_MAPPING
do
is_dispatched := False
l_req_method := request_method (req)
across
mappings as c
@@ -106,7 +137,7 @@ feature -- Access
Result /= Void
loop
if attached c.item as l_info then
if is_matching_request_methods (l_req_method, l_info.request_methods) then
if is_matching_request_methods (a_request_method, l_info.request_methods) then
m := l_info.mapping
if attached m.routed_handler (req, res, Current) as r then
is_dispatched := True

View File

@@ -1,6 +1,11 @@
note
description: "Summary description for {WSF_ROUTER_ITEM}."
author: ""
description: "[
Entry of WSF_ROUTER
It contains
- mapping
- request methods
]"
date: "$Date$"
revision: "$Revision$"
@@ -38,11 +43,7 @@ feature -- Status report
debug_output: STRING
-- String that should be displayed in debugger to represent `Current'.
do
if attached {DEBUG_OUTPUT} mapping as d then
create Result.make_from_string (d.debug_output)
else
create Result.make_from_string (mapping.generator)
end
create Result.make_from_string (mapping.debug_output)
if attached request_methods as mtds then
Result.append_string (" [ ")
across
@@ -66,4 +67,15 @@ feature -- Change
invariant
mapping_attached: mapping /= Void
note
copyright: "2011-2012, 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

View File

@@ -7,6 +7,9 @@ note
deferred class
WSF_ROUTER_MAPPING
inherit
DEBUG_OUTPUT
feature {NONE} -- Initialization
make (a_resource: READABLE_STRING_8; h: like handler)
@@ -33,6 +36,14 @@ feature -- Documentation
deferred
end
feature -- Status report
debug_output: STRING
-- String that should be displayed in debugger to represent `Current'.
do
Result := description.as_string_8 + " : " + associated_resource
end
feature -- Status
routed_handler (req: WSF_REQUEST; res: WSF_RESPONSE; a_router: WSF_ROUTER): detachable WSF_HANDLER

View File

@@ -0,0 +1,81 @@
note
description: "[
This class is a wrapper on a standard WSF_RESPONSE
It is used to compute a HEAD request based on a GET request method handling
]"
date: "$Date$"
revision: "$Revision$"
class
WSF_HEAD_RESPONSE_WRAPPER
inherit
WSF_RESPONSE
redefine
put_character,
put_string,
put_substring,
put_chunk,
put_chunk_end
end
WSF_RESPONSE_EXPORTER
create
make_from_response
feature {NONE} -- Initialization
make_from_response (res: WSF_RESPONSE)
do
wsf_response := res
make_from_wgi (res.wgi_response)
end
feature {WSF_RESPONSE} -- Access
wsf_response: WSF_RESPONSE
-- Wrapped response
feature -- Output operation
put_character (c: CHARACTER_8)
do
-- HEAD has no content
end
put_string (s: READABLE_STRING_8)
do
-- HEAD has no content
end
put_substring (s: READABLE_STRING_8; a_begin_index, a_end_index: INTEGER)
do
-- HEAD has no content
end
put_chunk (s: READABLE_STRING_8; a_extension: detachable READABLE_STRING_8)
do
-- HEAD has no content
end
put_chunk_end
do
-- HEAD has no content
end
invariant
transfered_content_length_is_zero: transfered_content_length = 0
note
copyright: "2011-2012, 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

View File

@@ -39,6 +39,7 @@ feature {NONE} -- Initialization
tb: like meta_variables_table
do
wgi_request := r
create string_equality_tester
if attached r.meta_variables as l_vars then
create tb.make_with_key_tester (l_vars.count, string_equality_tester)
@@ -55,21 +56,26 @@ feature {NONE} -- Initialization
create error_handler.make
create uploaded_files_table.make_with_key_tester (0, string_equality_tester)
set_raw_input_data_recorded (False)
create {STRING_32} empty_string.make_empty
create {IMMUTABLE_STRING_32} empty_string.make_empty
create execution_variables_table.make_with_key_tester (0, string_equality_tester)
execution_variables_table.compare_objects
initialize
analyze
ensure
wgi_request_set: wgi_request = r
request_method_set: request_method.same_string (r.request_method)
end
initialize
-- Specific initialization
local
s8: detachable READABLE_STRING_8
req: WGI_REQUEST
do
init_mime_handlers
req := wgi_request
--| Content-Length
if attached content_length as s and then s.is_natural_64 then
@@ -79,18 +85,21 @@ feature {NONE} -- Initialization
end
-- Content-Type
s8 := wgi_request.content_type
s8 := req.content_type
if s8 /= Void then
create content_type.make_from_string (s8)
else
content_type := Void
end
--| Request Methods
request_method := req.request_method
--| PATH_INFO
path_info := raw_url_encoder.decoded_string (wgi_request.path_info)
path_info := raw_url_encoder.decoded_string (req.path_info)
--| PATH_TRANSLATED
s8 := wgi_request.path_translated
s8 := req.path_translated
if s8 /= Void then
path_translated := raw_url_encoder.decoded_string (s8)
end
@@ -211,6 +220,15 @@ feature -- Eiffel WGI access
Result := wgi_request.wgi_connector
end
feature {WSF_REQUEST_EXPORTER} -- Override value
set_request_method (a_request_method: like request_method)
-- Set `request_method' to `a_request_method'
-- note: this is mainly to have smart handling of HEAD request
do
request_method := a_request_method
end
feature {NONE} -- Access: global variable
items_table: HASH_TABLE_EX [WSF_VALUE, READABLE_STRING_GENERAL]
@@ -679,9 +697,6 @@ feature -- Access: CGI meta parameters - 1.1
-- This variable is specific to requests made with HTTP.
--
-- Servers MUST provide this metavariable to scripts.
do
Result := wgi_request.request_method
end
script_name: READABLE_STRING_8
-- The SCRIPT_NAME metavariable is set to a URL path that could

View File

@@ -1,5 +1,13 @@
${NOTE_KEYWORD}
copyright: "2011-${YEAR}, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
note
description: "Objects that can access low level features of {WSF_REQUEST}"
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_REQUEST_EXPORTER
note
copyright: "2011-2012, 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
@@ -8,3 +16,5 @@ ${NOTE_KEYWORD}
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -31,6 +31,8 @@ feature {NONE} -- Initialization
wgi_response := r
end
feature {WSF_RESPONSE_EXPORTER} -- Properties
wgi_response: WGI_RESPONSE
-- Associated WGI_RESPONSE

View File

@@ -0,0 +1,19 @@
note
description: "Objects that can access low level features of {WSF_RESPONSE}"
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_RESPONSE_EXPORTER
note
copyright: "2011-2012, 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

View File

@@ -12,7 +12,7 @@
<library name="base" location="$ISE_LIBRARY/library/base/base-safe.ecf"/>
<library name="http" location="../../network/protocol/http/http-safe.ecf"/>
<library name="ewsgi" location="..\ewsgi\ewsgi-safe.ecf"/>
<library name="wsf-safe" location="..\wsf\wsf-safe.ecf"/>
<library name="wsf-safe" location="wsf-safe.ecf"/>
<cluster name="extension" location="./extension" recursive="true"/>
</target>
</system>

View File

@@ -12,7 +12,7 @@
<library name="base" location="$ISE_LIBRARY/library/base/base.ecf"/>
<library name="http" location="../../network/protocol/http/http.ecf"/>
<library name="ewsgi" location="..\ewsgi\ewsgi.ecf"/>
<library name="wsf" location="..\wsf\wsf.ecf"/>
<library name="wsf" location="wsf.ecf"/>
<cluster name="extension" location="./extension" recursive="true"/>
</target>
</system>

View File

@@ -14,7 +14,7 @@
<library name="uuid" location="$ISE_LIBRARY/library/uuid/uuid-safe.ecf"/>
<library name="http" location="../../network/protocol/http/http-safe.ecf"/>
<library name="ewsgi" location="..\ewsgi\ewsgi-safe.ecf"/>
<library name="wsf-safe" location="..\wsf\wsf-safe.ecf"/>
<library name="wsf-safe" location="wsf-safe.ecf"/>
<cluster name="session" location="./session" recursive="true"/>
</target>
</system>

View File

@@ -14,7 +14,7 @@
<library name="uuid" location="$ISE_LIBRARY/library/uuid/uuid.ecf"/>
<library name="http" location="../../network/protocol/http/http.ecf"/>
<library name="ewsgi" location="..\ewsgi\ewsgi.ecf"/>
<library name="wsf" location="..\wsf\wsf.ecf"/>
<library name="wsf" location="wsf.ecf"/>
<cluster name="session" location="./session" recursive="true"/>
</target>
</system>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-9-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-9-0 http://www.eiffel.com/developers/xml/configuration-1-9-0.xsd" name="encoder" uuid="EE80E648-C64D-4802-8868-C57AAFEACC55" library_target="encoder">
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-8-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-8-0 http://www.eiffel.com/developers/xml/configuration-1-8-0.xsd" name="encoder" uuid="EE80E648-C64D-4802-8868-C57AAFEACC55" library_target="encoder">
<target name="encoder">
<root all_classes="true"/>
<file_rule>
@@ -7,7 +7,7 @@
<exclude>/EIFGENs$</exclude>
<exclude>/.svn$</exclude>
</file_rule>
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="transitional">
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="provisional">
<assertions precondition="true"/>
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
@@ -17,12 +17,12 @@
<exclude>/tests$</exclude>
<exclude>/spec$</exclude>
</file_rule>
<cluster name="src_before_70" location="$\spec\before_70" recursive="true">
<cluster name="src_before_70" location="$|spec\before_70\" recursive="true">
<condition>
<version type="compiler" max="7.0.8.7585"/>
</condition>
</cluster>
<cluster name="src_70" location="$\spec\70" recursive="true">
<cluster name="src_70" location="$|spec\70\" recursive="true">
<condition>
<version type="compiler" min="7.0.8.7586"/>
</condition>

View File

@@ -7,7 +7,7 @@
<exclude>/EIFGENs$</exclude>
<exclude>/.svn$</exclude>
</file_rule>
<option warning="true" full_class_checking="true">
<option warning="true" full_class_checking="true" syntax="provisional">
<assertions precondition="true"/>
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>

View File

@@ -7,7 +7,7 @@
<exclude>/EIFGENs$</exclude>
<exclude>/.svn$</exclude>
</file_rule>
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all">
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="provisional">
<assertions precondition="true"/>
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>

View File

@@ -7,7 +7,7 @@
<exclude>/EIFGENs$</exclude>
<exclude>/.svn$</exclude>
</file_rule>
<option warning="true" full_class_checking="true">
<option warning="true" full_class_checking="true" syntax="provisional">
<assertions precondition="true"/>
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>

39
tests/all-safe.ecf Normal file
View File

@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-10-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-10-0 http://www.eiffel.com/developers/xml/configuration-1-10-0.xsd" name="all" uuid="1172C52C-6979-4293-8F01-80FADA5A2B69">
<description>compile many lib from EWF</description>
<target name="all">
<root all_classes="true"/>
<file_rule>
<exclude>/.git$</exclude>
<exclude>/EIFGENs$</exclude>
<exclude>/.svn$</exclude>
</file_rule>
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="standard">
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="connector_cgi" location="..\library\server\ewsgi\connectors\cgi\cgi-safe.ecf" readonly="false"/>
<library name="connector_libfcgi" location="..\library\server\ewsgi\connectors\libfcgi\libfcgi-safe.ecf" readonly="false"/>
<library name="connector_nino" location="..\library\server\ewsgi\connectors\nino\nino-safe.ecf" readonly="false"/>
<library name="connector_null" location="..\library\server\ewsgi\connectors\null\null-safe.ecf" readonly="false"/>
<library name="conneg" location="..\library\network\protocol\conneg\conneg-safe.ecf" readonly="false"/>
<library name="ewsgi" location="..\library\server\ewsgi\ewsgi-safe.ecf" readonly="false"/>
<library name="http" location="..\library\network\protocol\http\http-safe.ecf" readonly="false"/>
<library name="http_authorization" location="..\library\server\authentication\http_authorization\http_authorization-safe.ecf" readonly="false"/>
<library name="http_client" location="..\library\network\http_client\http_client-safe.ecf" readonly="false"/>
<library name="thread" location="$ISE_LIBRARY\library\thread\thread-safe.ecf"/>
<library name="wsf" location="..\library\server\wsf\wsf-safe.ecf" readonly="false"/>
<library name="wsf_extension" location="..\library\server\wsf\wsf_extension-safe.ecf" readonly="false"/>
<library name="wsf_session" location="..\library\server\wsf\wsf_session-safe.ecf" readonly="false"/>
</target>
<target name="all_windows" extends="all">
<description>Compiling as Windows , on other platforms than Windows</description>
<root all_classes="true"/>
<setting name="platform" value="windows"/>
</target>
<target name="all_unix" extends="all">
<description>Compiling as UNIX , on other platforms than Unix</description>
<root all_classes="true"/>
<setting name="platform" value="unix"/>
</target>
</system>

View File

@@ -0,0 +1,15 @@
#!/bin/sh
mkdir tmp
ecb -config ewf_ise_wizard-safe.ecf -target wizard -finalize -c_compile -project_path tmp
mkdir -p spec/$ISE_PLATFORM
mv tmp/EIFGENs/wizard/F_code/wizard spec/$ISE_PLATFORM/wizard
rm -rf tmp
WIZ_TARGET=$ISE_EIFFEL/studio/wizards/new_projects/ewf
rm -rf $WIZ_TARGET
mkdir $WIZ_TARGET
cp -r resources $WIZ_TARGET/resources
cp -r spec $WIZ_TARGET/spec
cp ewf.dsc $WIZ_TARGET/../ewf.dsc
rm -rf spec

View File

@@ -0,0 +1,16 @@
#!/bin/sh
mkdir tmp
ecb -config ewf_ise_wizard-safe.ecf -target custom_wizard -finalize -c_compile -project_path tmp
mkdir -p custom/spec/$ISE_PLATFORM
mv tmp/EIFGENs/custom_wizard/F_code/wizard custom/spec/$ISE_PLATFORM/wizard
rm -rf tmp
WIZ_TARGET=$ISE_EIFFEL/studio/wizards/new_projects/ewf_custom
rm -rf $WIZ_TARGET
mkdir $WIZ_TARGET
cp -r resources $WIZ_TARGET/resources
cp -f custom/resources/* $WIZ_TARGET/resources
cp -r custom/spec $WIZ_TARGET/spec
cp custom/ewf.dsc $WIZ_TARGET/../ewf_custom.dsc
rm -rf custom/spec

View File

@@ -26,8 +26,6 @@ feature -- Execution
-- Default request handler if no other are relevant
local
mesg: WSF_HTML_PAGE_RESPONSE
s: STRING_8
l_user_name: READABLE_STRING_32
do
create mesg.make
mesg.set_title ("Hello World!")
@@ -44,9 +42,6 @@ feature {NONE} -- Initialization
--| If you don't need any custom options, you are not obliged to redefine `initialize'
Precursor
--| Initialize router
initialize_router
end
end

View File

@@ -119,15 +119,14 @@ feature -- Form
tfn.add_extension ("ecf")
copy_resource_template ("template.ecf", tfn.string)
create res.make (tfn.string, d.name)
create tfn.make_from_string (dn.string)
tfn.set_file_name ("ewf")
tfn.add_extension ("ini")
copy_resource_template ("ewf.ini", tfn.string)
create res.make (tfn.string, d.name)
create dn.make_from_string (pdn)
dn.extend (pn)
dn.extend ("src")