Added SCOOP support for WSF.

WSF_SERVICE is deeply changed, and addition of WSF_EXECUTION.
Todo: code cleaning, removing useless things.
This commit is contained in:
2015-03-24 23:21:49 +01:00
parent ddf73077b3
commit bf0eb9a02d
51 changed files with 951 additions and 316 deletions

View File

@@ -18,40 +18,36 @@ note
revision: "$Revision$"
class
WSF_CGI_SERVICE_LAUNCHER
WSF_CGI_SERVICE_LAUNCHER [G -> WSF_EXECUTION create make end]
inherit
WSF_SERVICE_LAUNCHER
WSF_SERVICE_LAUNCHER [G]
create
make,
make_and_launch,
make_callback,
make_callback_and_launch
make_and_launch
feature {NONE} -- Initialization
initialize
do
create connector.make (Current)
create connector
end
feature -- Execution
launch
do
if attached connector as conn then
conn.launch
end
connector.launch
end
feature -- Status report
connector: detachable WGI_CGI_CONNECTOR
connector: WGI_CGI_CONNECTOR [G]
-- Default service name
;note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
copyright: "2011-2015, 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

@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-12-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-12-0 http://www.eiffel.com/developers/xml/configuration-1-12-0.xsd" name="wsf_httpd" uuid="9BF2D71A-0986-4025-9C97-15B65F07C568" library_target="wsf_httpd">
<target name="wsf_httpd">
<root all_classes="true"/>
<file_rule>
<exclude>/EIFGENs$</exclude>
<exclude>/\.git$</exclude>
<exclude>/\.svn$</exclude>
</file_rule>
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="provisional">
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="connector_httpd" location="..\..\ewsgi\connectors\httpd\httpd-safe.ecf"/>
<library name="encoder" location="..\..\..\text\encoder\encoder-safe.ecf" readonly="false"/>
<library name="error" location="..\..\..\utility\general\error\error-safe.ecf"/>
<library name="ewsgi" location="..\..\ewsgi\ewsgi-safe.ecf"/>
<library name="http" location="..\..\..\network\protocol\http\http-safe.ecf"/>
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
<library name="wsf" location="..\wsf-safe.ecf"/>
<cluster name="wsf_httpd" location=".\httpd\" recursive="true"/>
</target>
</system>

View File

@@ -0,0 +1,168 @@
note
description: "[
Component to launch the service using the default connector
Eiffel Web httpd for this class
The httpd default connector support options:
port: numeric such as 8099 (or equivalent string as "8099")
base: base_url (very specific to standalone server)
verbose: to display verbose output, useful for Nino
force_single_threaded: use only one thread, useful for Nino
check WSF_SERVICE_LAUNCHER for more documentation
]"
date: "$Date$"
revision: "$Revision$"
class
WSF_HTTPD_SERVICE_LAUNCHER [G -> WSF_EXECUTION create make end]
inherit
WSF_SERVICE_LAUNCHER [G]
redefine
launchable
end
create
make,
make_and_launch
feature {NONE} -- Initialization
initialize
local
conn: like connector
do
create on_launched_actions
create on_stopped_actions
port_number := 80 --| Default, but quite often, this port is already used ...
base_url := ""
if attached options as opts then
if attached {READABLE_STRING_GENERAL} opts.option ("server_name") as l_server_name then
server_name := l_server_name.to_string_8
end
if attached {INTEGER} opts.option ("port") as l_port then
port_number := l_port
elseif
attached {READABLE_STRING_GENERAL} opts.option ("port") as l_port_str and then
l_port_str.is_integer
then
port_number := l_port_str.as_string_8.to_integer
end
if attached {READABLE_STRING_GENERAL} opts.option ("base") as l_base_str then
base_url := l_base_str.as_string_8
end
if attached {BOOLEAN} opts.option ("force_single_threaded") as l_single_threaded then
single_threaded := l_single_threaded
elseif attached {READABLE_STRING_GENERAL} opts.option ("force_single_threaded") as l_single_threaded_str then
single_threaded := l_single_threaded_str.as_lower.same_string ("true")
end
if attached {BOOLEAN} opts.option ("verbose") as l_verbose then
verbose := l_verbose
elseif attached {READABLE_STRING_GENERAL} opts.option ("verbose") as l_verbose_str then
verbose := l_verbose_str.as_lower.same_string ("true")
end
end
create conn.make
connector := conn
conn.on_launched_actions.extend (agent on_launched)
conn.on_stopped_actions.extend (agent on_stopped)
conn.set_base (base_url)
update_configuration (conn.configuration)
end
feature -- Execution
update_configuration (cfg: separate HTTPD_CONFIGURATION)
do
if single_threaded then
cfg.set_force_single_threaded (True)
end
cfg.set_is_verbose (verbose)
if attached server_name as l_server_name then
cfg.set_http_server_name (l_server_name)
end
-- conn.set_port_number (port_number)
cfg.http_server_port := port_number
end
launch
-- <Precursor/>
-- using `port_number', `base_url', `verbose' and `single_threaded'
local
conn: like connector
do
conn := connector
conn.set_base (base_url)
debug ("nino")
if verbose then
io.error.put_string ("Launching Nino web server on port " + port_number.out)
if attached server_name as l_name then
io.error.put_string ("%N http://" + l_name + ":" + port_number.out + "/" + base_url + "%N")
else
io.error.put_string ("%N http://localhost:" + port_number.out + "/" + base_url + "%N")
end
end
end
update_configuration (conn.configuration)
conn.launch
end
feature -- Callback
on_launched_actions: ACTION_SEQUENCE [TUPLE [WGI_CONNECTOR]]
-- Actions triggered when launched
on_stopped_actions: ACTION_SEQUENCE [TUPLE [WGI_CONNECTOR]]
-- Actions triggered when stopped
feature {NONE} -- Implementation
on_launched (conn: WGI_CONNECTOR)
do
on_launched_actions.call ([conn])
end
on_stopped (conn: WGI_CONNECTOR)
do
on_stopped_actions.call ([conn])
end
port_number: INTEGER
server_name: detachable READABLE_STRING_8
base_url: READABLE_STRING_8
verbose: BOOLEAN
single_threaded: BOOLEAN
feature -- Status report
connector: WGI_HTTPD_CONNECTOR [G]
-- Default connector
launchable: BOOLEAN
do
Result := Precursor and port_number >= 0
end
;note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, 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

@@ -18,40 +18,36 @@ note
revision: "$Revision$"
class
WSF_LIBFCGI_SERVICE_LAUNCHER
WSF_LIBFCGI_SERVICE_LAUNCHER [G -> WSF_EXECUTION create make end]
inherit
WSF_SERVICE_LAUNCHER
WSF_SERVICE_LAUNCHER [G]
create
make,
make_and_launch,
make_callback,
make_callback_and_launch
make_and_launch
feature {NONE} -- Initialization
initialize
do
create connector.make (Current)
create connector
end
feature -- Execution
launch
do
if attached connector as conn then
conn.launch
end
connector.launch
end
feature -- Status report
connector: detachable WGI_LIBFCGI_CONNECTOR
connector: WGI_LIBFCGI_CONNECTOR [G]
-- Default service name
;note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
copyright: "2011-2015, 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

@@ -17,19 +17,17 @@ note
revision: "$Revision$"
class
WSF_NINO_SERVICE_LAUNCHER
WSF_NINO_SERVICE_LAUNCHER [G -> WSF_EXECUTION create make end]
inherit
WSF_SERVICE_LAUNCHER
WSF_SERVICE_LAUNCHER [G]
redefine
launchable
end
create
make,
make_and_launch,
make_callback,
make_callback_and_launch
make_and_launch
feature {NONE} -- Initialization
@@ -70,9 +68,10 @@ feature {NONE} -- Initialization
end
end
create conn.make (Current)
connector := conn
conn.on_launched_actions.extend (agent on_launched)
conn.on_stopped_actions.extend (agent on_stopped)
connector := conn
conn.set_base (base_url)
if single_threaded then
conn.configuration.set_force_single_threaded (True)
@@ -85,29 +84,30 @@ feature -- Execution
launch
-- <Precursor/>
-- using `port_number', `base_url', `verbose' and `single_threaded'
local
conn: like connector
do
if attached connector as conn then
conn.set_base (base_url)
if single_threaded then
conn.configuration.set_force_single_threaded (True)
end
conn.configuration.set_is_verbose (verbose)
debug ("nino")
if verbose then
io.error.put_string ("Launching Nino web server on port " + port_number.out)
if attached server_name as l_name then
io.error.put_string ("%N http://" + l_name + ":" + port_number.out + "/" + base_url + "%N")
else
io.error.put_string ("%N http://localhost:" + port_number.out + "/" + base_url + "%N")
end
conn := connector
conn.set_base (base_url)
if single_threaded then
conn.configuration.set_force_single_threaded (True)
end
conn.configuration.set_is_verbose (verbose)
debug ("nino")
if verbose then
io.error.put_string ("Launching Nino web server on port " + port_number.out)
if attached server_name as l_name then
io.error.put_string ("%N http://" + l_name + ":" + port_number.out + "/" + base_url + "%N")
else
io.error.put_string ("%N http://localhost:" + port_number.out + "/" + base_url + "%N")
end
end
if attached server_name as l_server_name then
conn.configuration.set_http_server_name (l_server_name)
end
conn.configuration.http_server_port := port_number
conn.launch
end
if attached server_name as l_server_name then
conn.configuration.set_http_server_name (l_server_name)
end
conn.configuration.http_server_port := port_number
conn.launch
end
feature -- Callback
@@ -142,7 +142,7 @@ feature {NONE} -- Implementation
feature -- Status report
connector: detachable WGI_NINO_CONNECTOR
connector: WGI_NINO_CONNECTOR [G]
-- Default connector
launchable: BOOLEAN
@@ -151,7 +151,7 @@ feature -- Status report
end
;note
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
copyright: "2011-2015, 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

@@ -5,19 +5,17 @@ note
revision: "$Revision$"
class
WSF_DEFAULT_SERVICE_LAUNCHER
WSF_DEFAULT_SERVICE_LAUNCHER [G -> WSF_EXECUTION create make end]
inherit
WSF_CGI_SERVICE_LAUNCHER
WSF_CGI_SERVICE_LAUNCHER [G]
create
make,
make_and_launch,
make_callback,
make_callback_and_launch
make_and_launch
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
copyright: "2011-2015, 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

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-12-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-12-0 http://www.eiffel.com/developers/xml/configuration-1-12-0.xsd" name="default_httpd" uuid="5CBA8C5A-3191-434A-8DE1-C0C3CAC9C4F4" library_target="default_httpd">
<target name="default_httpd">
<root all_classes="true"/>
<file_rule>
<exclude>/EIFGENs$</exclude>
<exclude>/\.git$</exclude>
<exclude>/\.svn$</exclude>
</file_rule>
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="provisional">
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="wsf" location="..\wsf-safe.ecf"/>
<library name="wsf_httpd" location="..\connector\httpd-safe.ecf"/>
<cluster name="default_httpd" location=".\httpd\" recursive="true"/>
</target>
</system>

View File

@@ -0,0 +1,24 @@
note
description: "Summary description for {WSF_DEFAULT_RESPONSE_SERVICE}."
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_DEFAULT_RESPONSE_SERVICE
inherit
WSF_DEFAULT_SERVICE
WSF_RESPONSE_SERVICE
note
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
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

@@ -0,0 +1,22 @@
note
description: "Summary description for {WSF_DEFAULT_SERVICE}."
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_DEFAULT_SERVICE [G -> WSF_EXECUTION create make end]
inherit
WSF_DEFAULT_SERVICE_I [WSF_DEFAULT_SERVICE_LAUNCHER [G]]
note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, 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

@@ -0,0 +1,29 @@
note
description: "[
Default launcher for WSF_SERVICE based on {WSF_HTTPD_SERVICE_LAUNCHER}
]"
date: "$Date$"
revision: "$Revision$"
class
WSF_DEFAULT_SERVICE_LAUNCHER [G -> WSF_EXECUTION create make end]
inherit
WSF_HTTPD_SERVICE_LAUNCHER [G]
create
make,
make_and_launch
note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, 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

@@ -4,10 +4,10 @@ note
revision: "$Revision$"
deferred class
WSF_DEFAULT_SERVICE
WSF_DEFAULT_SERVICE [G -> WSF_EXECUTION create make end]
inherit
WSF_DEFAULT_SERVICE_I [WSF_DEFAULT_SERVICE_LAUNCHER]
WSF_DEFAULT_SERVICE_I [WSF_DEFAULT_SERVICE_LAUNCHER [G]]
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"

View File

@@ -6,16 +6,14 @@ note
revision: "$Revision$"
class
WSF_DEFAULT_SERVICE_LAUNCHER
WSF_DEFAULT_SERVICE_LAUNCHER [G -> WSF_EXECUTION create make end]
inherit
WSF_NINO_SERVICE_LAUNCHER
WSF_NINO_SERVICE_LAUNCHER [G]
create
make,
make_and_launch,
make_callback,
make_callback_and_launch
make_and_launch
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"

View File

@@ -67,7 +67,11 @@ feature -- Access
create p.make_with_body (s)
if {PLATFORM}.is_windows and req.wgi_connector.name.is_case_insensitive_equal ("cgi") then
if
{PLATFORM}.is_windows and then
attached req.wgi_connector as conn and then
is_cgi_connector (conn)
then
--| FIXME: the CGI connector add %R for any single %N character, so update the Content-Length accordingly.
-- Dirty hack to handle correctly CGI on Windows, since it seems "abc%N" will be sent as "abc%R%N"
l_len := 0
@@ -96,9 +100,17 @@ feature -- Access
res.send (p)
end
is_cgi_connector (conn: separate WGI_CONNECTOR): BOOLEAN
local
s: STRING
do
create s.make_from_separate (conn.name)
Result := s.is_case_insensitive_equal_general ("cgi")
end
note
copyright: "2011-2014, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -61,12 +61,32 @@ feature -- Execution
a_output.append (" version=")
a_output.append (req.wgi_version)
a_output.append (" connector=%"")
a_output.append (req.wgi_connector.name)
a_output.append (" connector-version=")
a_output.append (req.wgi_connector.version)
if attached req.wgi_connector as conn then
append_connector_name_to (conn, a_output)
a_output.append ("%" connector-version=")
append_connector_version_to (conn, a_output)
else
a_output.append ("none")
end
a_output.append (eol)
end
append_connector_name_to (conn: separate WGI_CONNECTOR; a_output: STRING)
local
s: STRING
do
create s.make_from_separate (conn.name)
a_output.append (s)
end
append_connector_version_to (conn: separate WGI_CONNECTOR; a_output: STRING)
local
s: STRING
do
create s.make_from_separate (conn.version)
a_output.append (s)
end
append_cgi_variables_to (req: WSF_REQUEST; res: WSF_RESPONSE; a_output: STRING)
do
a_output.append ("CGI variables:")
@@ -385,7 +405,7 @@ feature -- Constants
invariant
note
copyright: "2011-2014, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -4,18 +4,18 @@ note
revision: "$Revision$"
deferred class
WSF_DEFAULT_SERVICE_I [G -> WSF_SERVICE_LAUNCHER create make_and_launch end]
WSF_DEFAULT_SERVICE_I [G -> WSF_SERVICE_LAUNCHER [WSF_EXECUTION] create make_and_launch end]
inherit
WSF_LAUNCHABLE_SERVICE
feature {NONE} -- Initialization
launch (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
launch (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
local
l_launcher: G
do
create l_launcher.make_and_launch (a_service, opts)
create l_launcher.make_and_launch (opts)
end
note

View File

@@ -14,7 +14,7 @@ feature {NONE} -- Initialization
frozen make_and_launch
do
initialize
launch (Current, service_options)
launch (service_options)
end
initialize
@@ -25,7 +25,7 @@ feature {NONE} -- Initialization
service_options: detachable WSF_SERVICE_LAUNCHER_OPTIONS
launch (a_service: WSF_SERVICE; opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
launch (opts: detachable WSF_SERVICE_LAUNCHER_OPTIONS)
deferred
end
@@ -47,7 +47,7 @@ feature -- Default service options
end
note
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -10,26 +10,8 @@ note
deferred class
WSF_SERVICE
feature -- Execution
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute the request
-- See `req.input' for input stream
-- `req.meta_variables' for the CGI meta variable
-- and `res' for output buffer
deferred
end
feature -- Conversion
to_wgi_service: WGI_SERVICE
-- Adapt Current WSF Service to plug into WGI component
do
create {WSF_TO_WGI_SERVICE} Result.make_from_service (Current)
end
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -32,45 +32,31 @@ note
revision: "$Revision$"
deferred class
WSF_SERVICE_LAUNCHER
WSF_SERVICE_LAUNCHER [G -> WSF_EXECUTION create make end]
inherit
WSF_TO_WGI_SERVICE
feature {NONE} -- Initialization
frozen make (a_service: like service; a_options: like options)
frozen make (a_options: like options)
do
make_from_service (a_service)
options := a_options
initialize
ensure
service_set: service = a_service
options_set: options = a_options
launchable: launchable
end
frozen make_and_launch (a_service: like service; a_options: like options)
frozen make_and_launch (a_options: like options)
do
make (a_service, a_options)
make (a_options)
launch
end
frozen make_callback (a_callback: PROCEDURE [ANY, TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]]; a_options: like options)
do
make (create {WSF_CALLBACK_SERVICE}.make (a_callback), a_options)
end
frozen make_callback_and_launch (a_callback: PROCEDURE [ANY, TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]]; a_options: like options)
do
make (create {WSF_CALLBACK_SERVICE}.make (a_callback), a_options)
end
initialize
-- Initialize Current using `options' if attached
-- and build the connector
require
service_set: service /= Void
deferred
ensure
connector_attached: connector /= Void
@@ -120,7 +106,7 @@ invariant
connector_attached: connector /= Void
note
copyright: "2011-2014, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -13,47 +13,8 @@ class
inherit
WGI_SERVICE
create
make_from_service
feature {NONE} -- Make
make_from_service (a_service: like service)
-- Make from WSF_SERVICE `a_service'
do
service := a_service
end
service: WSF_SERVICE
-- Associated WSF_SERVICE
feature {WGI_CONNECTOR} -- Implementation: Execution
execute (req: WGI_REQUEST; res: WGI_RESPONSE)
-- Delegate the WGI processing to the WSF_SERVICE object
-- <Precursor>
local
w_res: detachable WSF_RESPONSE
w_req: detachable WSF_REQUEST
do
create w_res.make_from_wgi (res)
create w_req.make_from_wgi (req)
service.execute (w_req, w_res)
w_req.destroy
rescue
if w_res /= Void then
if not (w_res.status_committed or w_res.header_committed) then
w_res.set_status_code ({HTTP_STATUS_CODE}.internal_server_error)
end
w_res.flush
end
if w_req /= Void then
w_req.destroy
end
end
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -7,6 +7,17 @@ note
deferred class
WSF_EXECUTION
inherit
WGI_EXECUTION
rename
request as wgi_request,
response as wgi_response
redefine
make,
execute,
clean
end
--create
-- make
@@ -14,24 +25,72 @@ feature {NONE} -- Initialization
make (req: WGI_REQUEST; res: WGI_RESPONSE)
do
create request.make_from_wgi (req)
create response.make_from_wgi (res)
Precursor (req, res)
create request.make_from_wgi (wgi_request)
create response.make_from_wgi (wgi_response)
end
feature {NONE} -- Access
request: WSF_REQUEST
-- Access to request data.
-- Header, Query, Post, Input data..
response: WSF_RESPONSE
-- Access to output stream, back to the client.
feature -- Status report
message_writable: BOOLEAN
do
Result := response.message_writable
end
feature -- Helpers
put_character (c: CHARACTER_8)
require
message_writable: message_writable
do
response.put_character (c)
end
put_string (s: READABLE_STRING_8)
require
message_writable: message_writable
do
response.put_string (s)
end
put_error (err: READABLE_STRING_8)
require
message_writable: message_writable
do
response.put_error (err)
end
feature -- Execution
execute
-- Execute Current `request',
-- getting data from `request'
-- and response to client via `response'.
deferred
ensure
response.status_is_set
ensure then
status_is_set: response.status_is_set
end
feature -- Cleaning
clean
-- Precursor
do
Precursor
request.destroy
end
note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Colin Adams, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -41,7 +41,7 @@ inherit
{NONE} all
end
create {WSF_TO_WGI_SERVICE, WSF_EXECUTION}
create {WSF_TO_WGI_SERVICE, WSF_EXECUTION, WGI_EXPORTER}
make_from_wgi
convert
@@ -426,7 +426,7 @@ feature -- Eiffel WGI access
Result := wgi_request.wgi_implementation
end
wgi_connector: detachable WGI_CONNECTOR
wgi_connector: detachable separate WGI_CONNECTOR
-- Associated Eiffel WGI connector
do
Result := wgi_request.wgi_connector

View File

@@ -19,7 +19,7 @@ note
class
WSF_RESPONSE
create {WSF_TO_WGI_SERVICE, WSF_EXECUTION}
create {WSF_TO_WGI_SERVICE, WSF_EXECUTION, WGI_EXPORTER}
make_from_wgi
create {WSF_RESPONSE}