First integration of the new GW_ design more centralized on connector, and does not require specific feature on GW_APPLICATION depending on the connector.

So this is really more flexible this way, and much easier to write application supporting CGI, FCGI, Nino and so on .. as demonstrated in hello_world

This is a first version, more will come later, mainly migrating from Eiffel Web Reloaded to this Eiffel Web Framework project.
This commit is contained in:
Jocelyn Fiat
2011-07-12 11:53:00 +02:00
parent 4fb42df5fb
commit f74ac66569
101 changed files with 7651 additions and 107 deletions

View File

@@ -0,0 +1,16 @@
<?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">
<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">
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="ewsgi" location="..\..\ewsgi-safe.ecf" readonly="false"/>
<cluster name="src" location=".\src\" recursive="true"/>
</target>
</system>

View File

@@ -0,0 +1,16 @@
<?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">
<root all_classes="true"/>
<file_rule>
<exclude>/EIFGENs$</exclude>
<exclude>/\.git$</exclude>
<exclude>/\.svn$</exclude>
</file_rule>
<option warning="true" full_class_checking="true">
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="ewsgi" location="..\ewsgi.ecf" readonly="false"/>
<cluster name="src" location=".\src\" recursive="true"/>
</target>
</system>

View File

@@ -0,0 +1 @@
reference:forum2

View File

@@ -0,0 +1,36 @@
note
description: "Summary description for {GW_CGI_CONNECTOR}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
GW_CGI_CONNECTOR
inherit
GW_CONNECTOR
create
make
feature -- Execution
launch
local
env: GW_ENVIRONMENT_VARIABLES
do
create env.make_with_variables ((create {EXECUTION_ENVIRONMENT}).starting_environment_variables)
application.process (env, create {GW_CGI_INPUT_STREAM}.make, create {GW_CGI_OUTPUT_STREAM}.make)
end
note
copyright: "Copyright (c) 1984-2011, 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,39 @@
note
description: "Summary description for GW_CGI_INPUT_STREAM."
legal: "See notice at end of class."
status: "See notice at end of class."
date: "$Date$"
revision: "$Revision$"
class
GW_CGI_INPUT_STREAM
inherit
GW_INPUT_STREAM
CONSOLE
rename
make as console_make
end
create
make
feature {NONE} -- Initialization
make
do
make_open_stdin ("stdin")
end
note
copyright: "2011-2011, 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,39 @@
note
description: "Summary description for GW_CGI_OUTPUT_STREAM."
legal: "See notice at end of class."
status: "See notice at end of class."
date: "$Date$"
revision: "$Revision$"
class
GW_CGI_OUTPUT_STREAM
inherit
GW_OUTPUT_STREAM
CONSOLE
rename
make as console_make
end
create
make
feature {NONE} -- Initialization
make
do
make_open_stdout ("stdout")
end
note
copyright: "2011-2011, 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,17 @@
<?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_libfcgi" uuid="59C57E56-3EE6-4EF7-873F-7ED084B0EB22" library_target="connector_libfcgi">
<target name="connector_libfcgi">
<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">
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="ewsgi" location="..\..\ewsgi-safe.ecf" readonly="false"/>
<library name="libfcgi" location="..\..\..\libfcgi\libfcgi-safe.ecf" />
<cluster name="src" location=".\" recursive="true"/>
</target>
</system>

View File

@@ -0,0 +1,17 @@
<?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_libfcgi" uuid="59C57E56-3EE6-4EF7-873F-7ED084B0EB22" library_target="connector_libfcgi">
<target name="connector_libfcgi">
<root all_classes="true"/>
<file_rule>
<exclude>/EIFGENs$</exclude>
<exclude>/\.git$</exclude>
<exclude>/\.svn$</exclude>
</file_rule>
<option warning="true" full_class_checking="true">
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="ewsgi" location="..\..\ewsgi.ecf" readonly="false"/>
<library name="libfcgi" location="..\..\libfcgi\libfcgi.ecf" />
<cluster name="src" location=".\" recursive="true"/>
</target>
</system>

View File

@@ -0,0 +1 @@
reference:forum2

View File

@@ -0,0 +1,81 @@
note
description: "Summary description for {GW_LIBFCGI_CONNECTOR}."
legal: "See notice at end of class."
status: "See notice at end of class."
date: "$Date$"
revision: "$Revision$"
class
GW_LIBFCGI_CONNECTOR
inherit
GW_CONNECTOR
redefine
initialize
end
create
make
feature {NONE} -- Initialization
initialize
do
create fcgi.make
create {GW_LIBFCGI_INPUT_STREAM} input.make (fcgi)
create {GW_LIBFCGI_OUTPUT_STREAM} output.make (fcgi)
end
feature -- Server
launch
local
res: INTEGER
do
from
res := fcgi.fcgi_listen
until
res < 0
loop
process_fcgi_request (fcgi.updated_environ_variables, input, output)
res := fcgi.fcgi_listen
end
end
feature -- Execution
process_fcgi_request (vars: HASH_TABLE [STRING, STRING]; a_input: like input; a_output: like output)
local
gw_env: GW_ENVIRONMENT_VARIABLES
do
create gw_env.make_with_variables (vars)
application.process (gw_env, a_input, a_output)
end
feature -- Input/Output
input: GW_INPUT_STREAM
-- Input from client (from httpd server via FCGI)
output: GW_OUTPUT_STREAM
-- Output to client (via httpd server/fcgi)
feature {NONE} -- Implementation
fcgi: FCGI
invariant
fcgi_attached: fcgi /= Void
note
copyright: "Copyright (c) 1984-2011, 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,66 @@
note
description: "Summary description for GW_LIBFCGI_INPUT_STREAM."
legal: "See notice at end of class."
status: "See notice at end of class."
date: "$Date$"
revision: "$Revision$"
class
GW_LIBFCGI_INPUT_STREAM
inherit
GW_INPUT_STREAM
STRING_HANDLER
create
make
feature {NONE} -- Initialization
make (a_fcgi: like fcgi)
require
valid_fcgi: a_fcgi /= Void
do
fcgi := a_fcgi
initialize
end
initialize
-- Initialize Current
do
create last_string.make_empty
end
feature -- Basic operation
read_stream (nb_char: INTEGER)
-- Read a string of at most `nb_char' bound characters
-- or until end of file.
-- Make result available in `last_string'.
do
fcgi.fill_string_from_stdin (last_string, nb_char)
end
feature -- Access
last_string: STRING
-- Last string read
feature {NONE} -- Implementation
fcgi: FCGI;
-- Bridge to FCGI world
note
copyright: "Copyright (c) 1984-2011, 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,57 @@
note
description: "Summary description for {GW_LIBFCGI_OUTPUT_STREAM}."
legal: "See notice at end of class."
status: "See notice at end of class."
date: "$Date$"
revision: "$Revision$"
class
GW_LIBFCGI_OUTPUT_STREAM
inherit
GW_OUTPUT_STREAM
create
make
feature {NONE} -- Initialization
make (a_fcgi: like fcgi)
require
valid_fcgi: a_fcgi /= Void
do
fcgi := a_fcgi
end
feature -- Basic operation
put_string (s: STRING)
-- Send `s' to http client
do
fcgi.put_string (s)
end
flush
do
end
feature {NONE} -- Implementation
fcgi: FCGI
-- Bridge to FCGI world
invariant
fcgi_attached: fcgi /= Void
note
copyright: "Copyright (c) 1984-2011, 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 @@
reference:forum2

View File

@@ -0,0 +1,17 @@
<?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_nino" uuid="F91861FB-4FEA-455F-9570-828D7903DC64" library_target="connector_nino">
<target name="connector_nino">
<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">
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="ewsgi" location="..\..\ewsgi-safe.ecf" readonly="false"/>
<library name="nino" location="..\..\..\..\..\ext\server\nino\nino-safe.ecf" readonly="false"/>
<cluster name="src" location=".\src\" recursive="true"/>
</target>
</system>

View File

@@ -0,0 +1,17 @@
<?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_nino" uuid="F91861FB-4FEA-455F-9570-828D7903DC64" library_target="connector_nino">
<target name="connector_nino">
<root all_classes="true"/>
<file_rule>
<exclude>/EIFGENs$</exclude>
<exclude>/\.git$</exclude>
<exclude>/\.svn$</exclude>
</file_rule>
<option warning="true" full_class_checking="true">
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="ewsgi" location="..\ewsgi.ecf" readonly="false"/>
<library name="nino" location="..\..\..\..\..\ext\server\nino\nino.ecf" readonly="false"/>
<cluster name="src" location=".\src\" recursive="true"/>
</target>
</system>

View File

@@ -0,0 +1,93 @@
note
description: "Summary description for {GW_NINO_CONNECTOR}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
GW_NINO_CONNECTOR
inherit
GW_CONNECTOR
redefine
initialize
end
create
make,
make_with_base
feature {NONE} -- Initialization
make_with_base (a_app: like application; a_base: like base)
do
make (a_app)
base := a_base
end
feature {NONE} -- Initialization
initialize
local
cfg: HTTP_SERVER_CONFIGURATION
do
create cfg.make
create server.make (cfg)
end
feature -- Access
server: HTTP_SERVER
configuration: HTTP_SERVER_CONFIGURATION
do
Result := server.configuration
end
feature -- Access
base: detachable STRING
-- Root url base
feature -- Element change
set_base (b: like base)
do
base := b
end
feature -- Server
launch
local
l_http_handler : HTTP_HANDLER
do
create {GW_NINO_HANDLER} l_http_handler.make_with_callback (server, "GW_NINO_HANDLER", Current)
debug ("nino")
if attached base as l_base then
print ("Base=" + l_base + "%N")
end
end
server.setup (l_http_handler)
end
process_request (env: HASH_TABLE [STRING, STRING]; a_headers_text: STRING; a_input: HTTP_INPUT_STREAM; a_output: HTTP_OUTPUT_STREAM)
local
gw_env: GW_ENVIRONMENT_VARIABLES
do
create gw_env.make_with_variables (env)
gw_env.set_variable ("RAW_HEADER_DATA", a_headers_text)
application.process (gw_env, create {GW_NINO_INPUT_STREAM}.make (a_input), create {GW_NINO_OUTPUT_STREAM}.make (a_output))
end
note
copyright: "Copyright (c) 1984-2011, 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,156 @@
note
description : "Objects that ..."
author : "$Author$"
date : "$Date$"
revision : "$Revision$"
class
GW_NINO_HANDLER
inherit
HTTP_CONNECTION_HANDLER
create
make_with_callback
feature {NONE} -- Initialization
make_with_callback (a_main_server: like main_server; a_name: STRING; a_callback: like callback)
-- Initialize `Current'.
do
make (a_main_server, a_name)
callback := a_callback
end
callback: GW_NINO_CONNECTOR
feature -- Access
base: detachable STRING
-- Root url base
feature -- Element change
set_base (a_uri: like base)
-- Set `base' to `a_uri'
do
base := a_uri
end
feature -- Request processing
process_request (a_handler: HTTP_CONNECTION_HANDLER; a_input: HTTP_INPUT_STREAM; a_output: HTTP_OUTPUT_STREAM)
-- Process request ...
local
env, vars: 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
a_headers_map: HASH_TABLE [STRING, STRING]
vn: STRING
e: EXECUTION_ENVIRONMENT
do
l_request_uri := a_handler.uri
a_headers_map := a_handler.request_header_map
create e
vars := e.starting_environment_variables
env := vars.twin
--| for Any Abc-Def-Ghi add (or replace) the HTTP_ABC_DEF_GHI variable to `env'
from
a_headers_map.start
until
a_headers_map.after
loop
vn := a_headers_map.key_for_iteration.as_upper
vn.replace_substring_all ("-", "_")
add_environment_variable (a_headers_map.item_for_iteration, vn, env)
a_headers_map.forth
end
--| Specific cases
p := l_request_uri.index_of ('?', 1)
if p > 0 then
l_script_name := l_request_uri.substring (1, p - 1)
l_query_string := l_request_uri.substring (p + 1, l_request_uri.count)
else
l_script_name := l_request_uri.string
l_query_string := ""
end
if attached a_headers_map.item ("Host") as l_host then
add_environment_variable (l_host, "HTTP_HOST", env)
p := l_host.index_of (':', 1)
if p > 0 then
l_server_name := l_host.substring (1, p - 1)
l_server_port := l_host.substring (p+1, l_host.count)
else
l_server_name := l_host
l_server_port := "80" -- Default
end
end
if attached a_headers_map.item ("Authorization") as l_authorization then
add_environment_variable (l_authorization, "HTTP_AUTHORIZATION", env)
p := l_authorization.index_of (' ', 1)
if p > 0 then
add_environment_variable (l_authorization.substring (1, p - 1), "AUTH_TYPE", env)
end
end
add_environment_variable ("CGI/1.1", "GATEWAY_INTERFACE", env)
add_environment_variable (l_query_string, "QUERY_STRING", env)
if attached a_handler.remote_info as l_remote_info then
add_environment_variable (l_remote_info.addr, "REMOTE_ADDR", env)
add_environment_variable (l_remote_info.hostname, "REMOTE_HOST", env)
add_environment_variable (l_remote_info.port.out, "REMOTE_PORT", env)
-- add_environment_variable (Void, "REMOTE_IDENT", env)
-- add_environment_variable (Void, "REMOTE_USER", env)
end
add_environment_variable (l_request_uri, "REQUEST_URI", env)
add_environment_variable (a_handler.method, "REQUEST_METHOD", env)
add_environment_variable (l_script_name, "SCRIPT_NAME", env)
add_environment_variable (l_server_name, "SERVER_NAME", env)
add_environment_variable (l_server_port, "SERVER_PORT", env)
add_environment_variable (a_handler.version, "SERVER_PROTOCOL", env)
add_environment_variable ({HTTP_SERVER_CONFIGURATION}.Server_details, "SERVER_SOFTWARE", env)
--| Apply `base' value
if attached base as l_base and then l_request_uri /= Void then
if l_request_uri.starts_with (l_base) then
l_path_info := l_request_uri.substring (l_base.count + 1, l_request_uri.count)
p := l_path_info.index_of ('?', 1)
if p > 0 then
l_path_info.keep_head (p - 1)
end
env.force (l_path_info, "PATH_INFO")
env.force (l_base, "SCRIPT_NAME")
end
end
callback.process_request (env, a_handler.request_header, a_input, a_output)
end
add_environment_variable (a_value: detachable STRING; a_var_name: STRING; env: HASH_TABLE [STRING, STRING])
-- Add variable `a_var_name => a_value' to `env'
do
if a_value /= Void then
env.force (a_value, a_var_name)
end
end
note
copyright: "2011-2011, 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,61 @@
note
description: "Summary description for {GW_NINO_INPUT_STREAM}."
legal: "See notice at end of class."
status: "See notice at end of class."
date: "$Date$"
revision: "$Revision$"
class
GW_NINO_INPUT_STREAM
inherit
GW_INPUT_STREAM
create
make
feature {NONE} -- Initialization
make (a_nino_input: like nino_input)
do
create last_string.make_empty
set_nino_input (a_nino_input)
end
feature {GW_NINO_APPLICATION} -- Nino
set_nino_input (i: like nino_input)
do
nino_input := i
end
nino_input: HTTP_INPUT_STREAM
feature -- Basic operation
read_stream (nb_char: INTEGER)
-- Read a string of at most `nb_char' bound characters
-- or until end of file.
-- Make result available in `last_string'.
do
nino_input.read_stream (nb_char)
last_string := nino_input.last_string
end
feature -- Access
last_string: STRING
-- Last string read
;note
copyright: "Copyright (c) 1984-2011, 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,60 @@
note
description: "Summary description for {GW_NINO_OUTPUT_STREAM}."
legal: "See notice at end of class."
status: "See notice at end of class."
date: "$Date$"
revision: "$Revision$"
class
GW_NINO_OUTPUT_STREAM
inherit
GW_OUTPUT_STREAM
create
make
feature {NONE} -- Initialization
make (a_nino_output: like nino_output)
do
set_nino_output (a_nino_output)
end
feature {GW_NINO_APPLICATION} -- Nino
set_nino_output (o: like nino_output)
do
nino_output := o
end
nino_output: HTTP_OUTPUT_STREAM
feature -- Basic operation
put_string (s: STRING_8)
-- Send `s' to http client
do
debug ("nino")
print (s)
end
nino_output.put_string (s)
end
flush
-- Flush the output stream
do
end
note
copyright: "2011-2011, 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