Applied recent changes on WGI_ and WSF_

Moved classes away from ewsgi, restructured, cleaned
This commit is contained in:
Jocelyn Fiat
2011-10-21 16:56:23 +02:00
parent 79e12b8d04
commit 14a2c01f41
62 changed files with 163 additions and 1626 deletions

View File

@@ -10,6 +10,7 @@
<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="connector" location="..\connector-safe.ecf" readonly="false"/>
<library name="ewsgi" location="..\..\ewsgi-safe.ecf" readonly="false"/>
<library name="http" location="..\..\..\..\protocol\http\http-safe.ecf"/>
<cluster name="src" location=".\src\" recursive="true"/>

View File

@@ -10,6 +10,7 @@
<option warning="true" full_class_checking="true">
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="connector" location="..\connector.ecf" readonly="false"/>
<library name="ewsgi" location="..\..\ewsgi.ecf" readonly="false"/>
<library name="http" location="..\..\..\..\protocol\http\http.ecf"/>
<cluster name="src" location=".\src\" recursive="true"/>

View File

@@ -1,11 +1,11 @@
note
description: "Summary description for {EWF_CGI_CONNECTOR}."
description: "Summary description for {WGI_CGI_CONNECTOR}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
EWF_CGI_CONNECTOR
WGI_CGI_CONNECTOR
inherit
WGI_CONNECTOR
@@ -22,8 +22,8 @@ feature -- Execution
rescued: BOOLEAN
do
if not rescued then
create req.make ((create {EXECUTION_ENVIRONMENT}).starting_environment_variables, create {EWF_CGI_INPUT_STREAM}.make)
create res.make (create {EWF_CGI_OUTPUT_STREAM}.make)
create req.make ((create {EXECUTION_ENVIRONMENT}).starting_environment_variables, create {WGI_CGI_INPUT_STREAM}.make)
create res.make (create {WGI_CGI_OUTPUT_STREAM}.make)
application.execute (req, res)
else
if attached (create {EXCEPTION_MANAGER}).last_exception as e and then attached e.exception_trace as l_trace then

View File

@@ -1,12 +1,12 @@
note
description: "Summary description for EWF_CGI_INPUT_STREAM."
description: "Summary description for WGI_CGI_INPUT_STREAM."
legal: "See notice at end of class."
status: "See notice at end of class."
date: "$Date$"
revision: "$Revision$"
class
EWF_CGI_INPUT_STREAM
WGI_CGI_INPUT_STREAM
inherit
WGI_INPUT_STREAM

View File

@@ -1,12 +1,12 @@
note
description: "Summary description for EWF_CGI_OUTPUT_STREAM."
description: "Summary description for WGI_CGI_OUTPUT_STREAM."
legal: "See notice at end of class."
status: "See notice at end of class."
date: "$Date$"
revision: "$Revision$"
class
EWF_CGI_OUTPUT_STREAM
WGI_CGI_OUTPUT_STREAM
inherit
WGI_OUTPUT_STREAM

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" uuid="61FBBC8E-558A-4079-920E-204946E54EFB" library_target="connector">
<target name="connector">
<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="ewsgi" location="../ewsgi-safe.ecf"/>
<cluster name="common" location="./common" 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" uuid="61FBBC8E-558A-4079-920E-204946E54EFB" library_target="connector">
<target name="connector">
<root all_classes="true"/>
<file_rule>
<exclude>/.git$</exclude>
<exclude>/EIFGENs$</exclude>
<exclude>/.svn$</exclude>
</file_rule>
<option warning="true" full_class_checking="true" void_safety="none" syntax="standard">
</option>
<library name="base" location="$ISE_LIBRARY/library/base/base.ecf"/>
<library name="ewsgi" location="../ewsgi.ecf"/>
<cluster name="common" location="./common" recursive="true"/>
</target>
</system>

View File

@@ -10,6 +10,7 @@
<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="connector" location="..\connector-safe.ecf" readonly="false"/>
<library name="ewsgi" location="..\..\ewsgi-safe.ecf" readonly="false"/>
<library name="libfcgi" location="..\..\..\libfcgi\libfcgi-safe.ecf" />
<library name="http" location="..\..\..\..\protocol\http\http-safe.ecf"/>

View File

@@ -10,6 +10,7 @@
<option warning="true" full_class_checking="true">
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="connector" location="..\connector.ecf" readonly="false"/>
<library name="ewsgi" location="..\..\ewsgi.ecf" readonly="false"/>
<library name="libfcgi" location="..\..\..\libfcgi\libfcgi.ecf" />
<library name="http" location="..\..\..\..\protocol\http\http.ecf"/>

View File

@@ -1,12 +1,12 @@
note
description: "Summary description for {EWF_LIBFCGI_CONNECTOR}."
description: "Summary description for {WGI_LIBFCGI_CONNECTOR}."
legal: "See notice at end of class."
status: "See notice at end of class."
date: "$Date$"
revision: "$Revision$"
class
EWF_LIBFCGI_CONNECTOR
WGI_LIBFCGI_CONNECTOR
inherit
WGI_CONNECTOR
@@ -22,8 +22,8 @@ feature {NONE} -- Initialization
initialize
do
create fcgi.make
create {EWF_LIBFCGI_INPUT_STREAM} input.make (fcgi)
create {EWF_LIBFCGI_OUTPUT_STREAM} output.make (fcgi)
create {WGI_LIBFCGI_INPUT_STREAM} input.make (fcgi)
create {WGI_LIBFCGI_OUTPUT_STREAM} output.make (fcgi)
end
feature -- Server

View File

@@ -1,12 +1,12 @@
note
description: "Summary description for EWF_LIBFCGI_INPUT_STREAM."
description: "Summary description for WGI_LIBFCGI_INPUT_STREAM."
legal: "See notice at end of class."
status: "See notice at end of class."
date: "$Date$"
revision: "$Revision$"
class
EWF_LIBFCGI_INPUT_STREAM
WGI_LIBFCGI_INPUT_STREAM
inherit
WGI_INPUT_STREAM

View File

@@ -1,12 +1,12 @@
note
description: "Summary description for {EWF_LIBFCGI_OUTPUT_STREAM}."
description: "Summary description for {WGI_LIBFCGI_OUTPUT_STREAM}."
legal: "See notice at end of class."
status: "See notice at end of class."
date: "$Date$"
revision: "$Revision$"
class
EWF_LIBFCGI_OUTPUT_STREAM
WGI_LIBFCGI_OUTPUT_STREAM
inherit
WGI_OUTPUT_STREAM

View File

@@ -10,6 +10,7 @@
<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="connector" location="..\connector-safe.ecf" readonly="false"/>
<library name="ewsgi" location="..\..\ewsgi-safe.ecf" readonly="false"/>
<library name="http" location="..\..\..\..\protocol\http\http-safe.ecf"/>
<library name="nino" location="..\..\..\..\..\ext\server\nino\nino-safe.ecf" readonly="false">

View File

@@ -10,6 +10,7 @@
<option warning="true" full_class_checking="true">
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="connector" location="..\connector.ecf" readonly="false"/>
<library name="ewsgi" location="..\..\ewsgi.ecf" readonly="false"/>
<library name="http" location="..\..\..\..\protocol\http\http.ecf"/>
<library name="nino" location="..\..\..\..\..\ext\server\nino\nino.ecf" readonly="false">

View File

@@ -29,7 +29,7 @@ feature {NONE} -- Implementation
create connector.make_with_base (app, a_base_url)
end
connector: EWF_NINO_CONNECTOR
connector: WGI_NINO_CONNECTOR
-- Web server connector
feature -- Status settings

View File

@@ -1,11 +1,11 @@
note
description: "Summary description for {EWF_NINO_CONNECTOR}."
description: "Summary description for {WGI_NINO_CONNECTOR}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
EWF_NINO_CONNECTOR
WGI_NINO_CONNECTOR
inherit
WGI_CONNECTOR
@@ -68,7 +68,7 @@ feature -- Server
local
l_http_handler : HTTP_HANDLER
do
create {EWF_NINO_HANDLER} l_http_handler.make_with_callback (server, "NINO_HANDLER", Current)
create {WGI_NINO_HANDLER} l_http_handler.make_with_callback (server, "NINO_HANDLER", Current)
debug ("nino")
if attached base as l_base then
print ("Base=" + l_base + "%N")
@@ -84,8 +84,8 @@ feature -- Server
rescued: BOOLEAN
do
if not rescued then
create req.make (env, create {EWF_NINO_INPUT_STREAM}.make (a_input))
create res.make (create {EWF_NINO_OUTPUT_STREAM}.make (a_output))
create req.make (env, create {WGI_NINO_INPUT_STREAM}.make (a_input))
create res.make (create {WGI_NINO_OUTPUT_STREAM}.make (a_output))
req.set_meta_string_variable ("RAW_HEADER_DATA", a_headers_text)
application.execute (req, res)
else

View File

@@ -5,7 +5,7 @@ note
revision : "$Revision$"
class
EWF_NINO_HANDLER
WGI_NINO_HANDLER
inherit
HTTP_CONNECTION_HANDLER
@@ -23,7 +23,7 @@ feature {NONE} -- Initialization
callback := a_callback
end
callback: EWF_NINO_CONNECTOR
callback: WGI_NINO_CONNECTOR
feature -- Access

View File

@@ -1,12 +1,12 @@
note
description: "Summary description for {EWF_NINO_INPUT_STREAM}."
description: "Summary description for {WGI_NINO_INPUT_STREAM}."
legal: "See notice at end of class."
status: "See notice at end of class."
date: "$Date$"
revision: "$Revision$"
class
EWF_NINO_INPUT_STREAM
WGI_NINO_INPUT_STREAM
inherit
WGI_INPUT_STREAM
@@ -22,7 +22,7 @@ feature {NONE} -- Initialization
set_nino_input (a_nino_input)
end
feature {EWF_NINO_CONNECTOR, WGI_APPLICATION} -- Nino
feature {WGI_NINO_CONNECTOR, WGI_APPLICATION} -- Nino
set_nino_input (i: like nino_input)
do

View File

@@ -1,12 +1,12 @@
note
description: "Summary description for {EWF_NINO_OUTPUT_STREAM}."
description: "Summary description for {WGI_NINO_OUTPUT_STREAM}."
legal: "See notice at end of class."
status: "See notice at end of class."
date: "$Date$"
revision: "$Revision$"
class
EWF_NINO_OUTPUT_STREAM
WGI_NINO_OUTPUT_STREAM
inherit
WGI_OUTPUT_STREAM
@@ -26,7 +26,7 @@ feature {NONE} -- Initialization
set_nino_output (a_nino_output)
end
feature {EWF_NINO_CONNECTOR, WGI_APPLICATION} -- Nino
feature {WGI_NINO_CONNECTOR, WGI_APPLICATION} -- Nino
set_nino_output (o: like nino_output)
do

Binary file not shown.

View File

@@ -1,32 +0,0 @@
note
description: "Summary description for {DEFAULT_WGI_APPLICATION}."
date: "$Date$"
revision: "$Revision$"
deferred class
DEFAULT_WGI_APPLICATION
inherit
WGI_APPLICATION
feature {NONE} -- Initialization
make_and_launch
local
cgi: EWF_CGI_CONNECTOR
do
create cgi.make (Current)
cgi.launch
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

@@ -1,21 +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="ewsgi_cgi" uuid="82D0E5BA-3EBD-4E0F-94D1-776375158DAA" library_target="ewsgi_cgi">
<target name="ewsgi_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" syntax="provisional">
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
<library name="ewsgi" location="../ewsgi-safe.ecf"/>
<library name="connector_cgi" location="../connectors/cgi/cgi-safe.ecf"/>
<library name="error" location="..\..\..\error\error-safe.ecf"/>
<library name="http" location="..\..\..\protocol\http\http-safe.ecf"/>
<library name="encoder" location="..\..\..\text\encoder\encoder-safe.ecf" readonly="false"/>
<cluster name="default_cgi" location="./cgi" recursive="true"/>
</target>
</system>

View File

@@ -1,21 +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="ewsgi_cgi" uuid="82D0E5BA-3EBD-4E0F-94D1-776375158DAA" library_target="ewsgi_cgi">
<target name="ewsgi_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" syntax="provisional">
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="time" location="$ISE_LIBRARY\library\time\time.ecf"/>
<library name="ewsgi" location="../ewsgi.ecf"/>
<library name="connector_cgi" location="../connectors/cgi/cgi.ecf"/>
<library name="error" location="..\..\..\error\error.ecf"/>
<library name="http" location="..\..\..\protocol\http\http.ecf"/>
<library name="encoder" location="..\..\..\text\encoder\encoder.ecf" readonly="false"/>
<cluster name="default_cgi" location="./cgi" recursive="true"/>
</target>
</system>

View File

@@ -1,25 +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="ewsgi_nino" uuid="11D70618-3D82-4C5B-9501-8833DD04A3D6" library_target="ewsgi_nino">
<target name="ewsgi_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" syntax="provisional">
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
<library name="ewsgi" location="../ewsgi-safe.ecf"/>
<library name="connector_nino" location="../connectors/nino/nino-safe.ecf"/>
<library name="nino" location="..\..\..\..\ext\server\nino\nino-safe.ecf" readonly="false">
<renaming old_name="HTTP_CONSTANTS" new_name="NINO_HTTP_CONSTANTS"/>
</library>
<library name="error" location="..\..\..\error\error-safe.ecf"/>
<library name="http" location="..\..\..\protocol\http\http-safe.ecf"/>
<library name="encoder" location="..\..\..\text\encoder\encoder-safe.ecf" readonly="false"/>
<cluster name="default_nino" location="./nino" recursive="true"/>
</target>
</system>

View File

@@ -1,25 +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="ewsgi_nino" uuid="11D70618-3D82-4C5B-9501-8833DD04A3D6" library_target="ewsgi_nino">
<target name="ewsgi_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" syntax="provisional">
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="time" location="$ISE_LIBRARY\library\time\time.ecf"/>
<library name="ewsgi" location="../ewsgi.ecf"/>
<library name="connector_nino" location="../connectors/nino/nino.ecf"/>
<library name="nino" location="..\..\..\..\ext\server\nino\nino.ecf" readonly="false">
<renaming old_name="HTTP_CONSTANTS" new_name="NINO_HTTP_CONSTANTS"/>
</library>
<library name="error" location="..\..\..\error\error.ecf"/>
<library name="http" location="..\..\..\protocol\http\http.ecf"/>
<library name="encoder" location="..\..\..\text\encoder\encoder.ecf" readonly="false"/>
<cluster name="default_nino" location="./nino" recursive="true"/>
</target>
</system>

View File

@@ -1,44 +0,0 @@
note
description: "Summary description for {DEFAULT_WGI_APPLICATION}."
date: "$Date$"
revision: "$Revision$"
deferred class
DEFAULT_WGI_APPLICATION
inherit
WGI_APPLICATION
feature {NONE} -- Initialization
make_and_launch
local
app: NINO_APPLICATION
do
port_number := 80
base_url := ""
debug ("nino")
print ("Example: start a Nino web server on port " + port_number.out +
", %Nand reply Hello World for any request such as http://localhost:" + port_number.out + "/" + base_url + "%N")
end
create app.make_custom (agent execute, base_url)
app.listen (port_number)
end
port_number: INTEGER
base_url: STRING
invariant
port_number_valid: port_number > 0
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

@@ -11,7 +11,6 @@
</option>
<setting name="concurrency" value="thread"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="default_nino" location="..\..\default\ewsgi_nino-safe.ecf" readonly="false"/>
<library name="connector_nino" location="..\..\connectors\nino\nino-safe.ecf" readonly="false"/>
<library name="ewsgi" location="..\..\ewsgi-safe.ecf" readonly="false"/>
<cluster name="src" location="src\" recursive="true"/>

View File

@@ -11,7 +11,6 @@
</option>
<setting name="concurrency" value="thread"/>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="default_nino" location="..\..\default\ewsgi_nino.ecf" readonly="false"/>
<library name="connector_nino" location="..\..\connectors\nino\nino.ecf" readonly="false"/>
<library name="ewsgi" location="..\..\ewsgi.ecf" readonly="false"/>
<cluster name="src" location="src\" recursive="true"/>

View File

@@ -1,28 +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="hello_world" uuid="09AE4913-629B-4D3C-B15D-BB615D9A7B7F">
<target name="hello_world">
<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">
<assertions precondition="true" postcondition="true" invariant="true" supplier_precondition="true"/>
</option>
<setting name="concurrency" value="thread"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="ewsgi" location="..\..\ewsgi-safe.ecf" readonly="false"/>
</target>
<target name="hello_nino_world" extends="hello_world">
<root class="HELLO_WORLD" feature="make_and_launch"/>
<library name="connector_nino" location="..\..\connectors\nino\nino-safe.ecf" readonly="false"/>
<library name="default_nino" location="..\..\default\ewsgi_nino-safe.ecf" readonly="false"/>
<cluster name="src" location="src\" recursive="true"/>
</target>
<target name="hello_cgi_world" extends="hello_world">
<root class="HELLO_WORLD" feature="make_and_launch"/>
<library name="connector_cgi" location="..\..\connectors\cgi\cgi-safe.ecf" readonly="false"/>
<library name="default_cgi" location="..\..\default\ewsgi_cgi-safe.ecf" readonly="false"/>
<cluster name="src" location="src\" recursive="true"/>
</target>
</system>

View File

@@ -1,10 +0,0 @@
${NOTE_KEYWORD}
copyright: "2011-${YEAR}, 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
]"

View File

@@ -1,48 +0,0 @@
note
description : "Objects that ..."
author : "$Author$"
date : "$Date$"
revision : "$Revision$"
class
HELLO_WORLD
inherit
WGI_RESPONSE_APPLICATION
DEFAULT_WGI_APPLICATION
create
make_and_launch
feature -- Response
response (request: WGI_REQUEST): WGI_RESPONSE
do
if request.path_info.starts_with ("/streaming/") then
Result := streaming_response (request)
else
create Result.make
Result.set_status (200)
Result.set_header ("Content-Type", "text/html; charset=utf-8")
Result.set_message_body ("<html><body>Hello World</body></html>")
end
end
streaming_response (request: WGI_REQUEST): WGI_RESPONSE
do
create {HELLO_WORLD_RESPONSE} Result.make
Result.set_status (200)
Result.set_header ("Content-Type", "text/html; charset=utf-8")
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

@@ -1,70 +0,0 @@
note
description: "A streaming (non-buffered) Hello World example."
author: "Paul Cohen <paul.cohen@seibostudio.se>"
status: "Draft"
class HELLO_WORLD_RESPONSE
inherit
WGI_RESPONSE
redefine
make,
read_block
end
create
make
feature {NONE} -- Initialization
make
do
precursor
set_ready_to_transmit
current_hello := 0
end
feature {NONE} -- Entity body
read_block
-- Reads a block of 100000 lines of "Hello World".
local
i: INTEGER
do
if current_hello >= 10000 then
end_of_blocks := True
else
if current_hello = 0 then
current_block := "<html><style>div#status {position: absolute; top: 30%%; left: 40%%; border: red solid 1px; padding: 10px; background-color: #ffcccc;}</style><body>%N"
current_block.append ("<a name=%"top%">Welcome</a><br/><div id=%"status%">In progress</div>")
end
from
i := 0
until
i = 1000
loop
current_block.append ("Hello World ("+ current_hello.out +","+ i.out +")<br/>%N")
i := i + 1
end
current_hello := current_hello + i
current_block.append ("<div id=%"status%">In progress - "+ (100 * current_hello // 10000).out +"%%</div>")
if current_hello = 10000 then
current_block.append ("<a name=%"bottom%">Bye bye..</a><br/><div id=%"status%">Completed - GO TO <a href=%"#bottom%">BOTTOM</a></div></body></html>")
end_of_blocks := True
end
end
end
current_hello: INTEGER
;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

@@ -1,44 +0,0 @@
note
description: "Summary description for {WGI_CONNECTOR}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WGI_CONNECTOR
feature {NONE} -- Initialization
make (a_app: like application)
do
application := a_app
initialize
end
initialize
-- Initialize connector
do
end
feature {NONE} -- Access
application: WGI_APPLICATION
-- Gateway Application
feature -- Server
launch
deferred
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

@@ -1,76 +0,0 @@
note
description: "[
Contains all information of a rfc2109 cookie that was read from the request header
]"
legal: "See notice at end of class."
status: "See notice at end of class."
date: "$Date$"
revision: "$Revision$"
class
WGI_COOKIE
create
make
convert
value: {READABLE_STRING_8, STRING_8, READABLE_STRING_GENERAL, STRING_GENERAL}
feature {NONE} -- Initialization
make (a_name: STRING; a_value: STRING)
-- Creates current.
require
a_name_not_empty: a_name /= Void and then not a_name.is_empty
a_value_not_empty: a_value /= Void and then not a_value.is_empty
do
name := a_name
value := a_value
ensure
a_name_set: name = a_name
a_value_set: value = a_value
end
feature -- Access
name: STRING
-- Required. The name of the state information ("cookie") is NAME,
-- and its value is VALUE. NAMEs that begin with $ are reserved for
-- other uses and must not be used by applications.
value: STRING
-- The VALUE is opaque to the user agent and may be anything the
-- origin server chooses to send, possibly in a server-selected
-- printable ASCII encoding. "Opaque" implies that the content is of
-- interest and relevance only to the origin server. The content
-- may, in fact, be readable by anyone that examines the Set-Cookie
-- header.
feature -- Query
variables: detachable HASH_TABLE [STRING, STRING]
-- Potential variable contained in the encoded cookie's value.
feature -- Status report
value_is_string (s: READABLE_STRING_GENERAL): BOOLEAN
-- Is `value' same string as `s'
do
Result := s.same_string (value)
end
invariant
name_attached: name /= Void
value_attached: value /= Void
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

@@ -1,80 +0,0 @@
note
description : "[
Interface to access the variable stored in a container
]"
legal: "See notice at end of class."
status: "See notice at end of class."
date: "$Date$"
revision: "$Revision$"
deferred class
WGI_VARIABLES [G -> STRING_GENERAL]
inherit
ITERABLE [G]
feature -- Status report
has_variable (a_name: STRING): BOOLEAN
-- Has variable associated with `a_name'
require
a_name_not_empty: a_name /= Void and then not a_name.is_empty
deferred
end
feature -- Access
variable (a_name: STRING): detachable G
-- Value for variable associated with `a_name'
-- If not found, return Void
require
a_name_not_empty: a_name /= Void and then not a_name.is_empty
deferred
end
variable_or_default (a_name: STRING; a_default: G; use_default_when_empty: BOOLEAN): G
-- Value for variable `a_name'
-- If not found, return `a_default'
require
a_name_not_empty: a_name /= Void and then not a_name.is_empty
do
if attached variable (a_name) as s then
if use_default_when_empty and then s.is_empty then
Result := a_default
else
Result := s
end
else
Result := a_default
end
end
feature {WGI_REQUEST, WGI_APPLICATION, WGI_CONNECTOR} -- Element change
set_variable (a_name: STRING; a_value: G)
require
a_name_not_empty: a_name /= Void and then not a_name.is_empty
deferred
ensure
variable_set: has_variable (a_name) and then variable (a_name) ~ a_value
end
unset_variable (a_name: STRING)
require
a_name_not_empty: a_name /= Void and then not a_name.is_empty
deferred
ensure
variable_unset: not has_variable (a_name)
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

@@ -1,186 +0,0 @@
note
description: "Summary description for {EWF_BUFFERED_RESPONSE}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
EWF_BUFFERED_RESPONSE
inherit
WGI_RESPONSE_BUFFER
create {WGI_APPLICATION}
make
feature {NONE} -- Initialization
make (a_res: like response_buffer; a_buffer_size: INTEGER)
do
response_buffer := a_res
buffer_capacity := a_buffer_size
create buffer.make (a_buffer_size)
end
response_buffer: WGI_RESPONSE_BUFFER
buffer: STRING_8
buffer_capacity: INTEGER
buffer_count: INTEGER
feature {NONE} -- Core output operation
write (s: STRING)
-- Send the content of `s'
local
buf: like buffer
len_b, len_s: INTEGER
do
buf := buffer
len_s := s.count
len_b := buffer_count
if len_b + len_s >= buffer_capacity then
flush_buffer
if len_s >= buffer_capacity then
-- replace buffer by `s'
buffer := s
buffer_count := len_s
flush_buffer
-- restore buffer with `buf'
buffer := buf
else
buf.append (s)
buffer_count := len_s
end
else
buf.append (s)
buffer_count := len_b + len_s
end
end
feature -- Output operation
flush
do
flush_buffer
end
feature {NONE} -- Implementation
flush_buffer
require
buffer_count_match_buffer: buffer_count = buffer.count
do
response_buffer.write (buffer)
buffer_count := 0
ensure
buffer_flushed: buffer_count = 0 and buffer.count = 0
end
feature {WGI_APPLICATION} -- Commit
commit
do
flush_buffer
end
feature -- Status report
header_committed: BOOLEAN
-- Header committed?
message_committed: BOOLEAN
-- Message committed?
message_writable: BOOLEAN
-- Can message be written?
do
Result := status_is_set and header_committed
end
feature -- Status setting
status_is_set: BOOLEAN
-- Is status set?
do
Result := status_code /= 0
end
set_status_code (a_code: INTEGER)
-- Set response status code
-- Should be done before sending any data back to the client
do
status_code := a_code
response_buffer.set_status_code (a_code)
end
status_code: INTEGER
-- Response status
feature -- Header output operation
write_headers_string (a_headers: STRING)
do
write (a_headers)
header_committed := True
end
write_header (a_status_code: INTEGER; a_headers: detachable ARRAY [TUPLE [key: STRING; value: STRING]])
-- Send headers with status `a_status', and headers from `a_headers'
local
h: EWF_HEADER
i,n: INTEGER
do
set_status_code (a_status_code)
create h.make
h.put_status (a_status_code)
if a_headers /= Void then
from
i := a_headers.lower
n := a_headers.upper
until
i > n
loop
h.put_header_key_value (a_headers[i].key, a_headers[i].value)
i := i + 1
end
end
write_headers_string (h.string)
end
feature -- Output operation
write_string (s: STRING)
-- Send the string `s'
do
write (s)
end
write_substring (s: STRING; start_index, end_index: INTEGER)
-- Send the substring `start_index:end_index]'
--| Could be optimized according to the target output
do
flush_buffer
response_buffer.write_substring (s, start_index, end_index)
end
write_file_content (fn: STRING)
-- Send the content of file `fn'
do
flush_buffer
response_buffer.write_file_content (fn)
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

@@ -1,151 +0,0 @@
note
description: "Summary description for {EWF_IN_MEMORY_RESPONSE}."
date: "$Date$"
revision: "$Revision$"
class
EWF_IN_MEMORY_RESPONSE
inherit
WGI_RESPONSE_BUFFER
create {WGI_APPLICATION}
make
feature {NONE} -- Initialization
make (res: WGI_RESPONSE_BUFFER)
do
response_buffer := res
create header.make
create body.make (100)
end
response_buffer: WGI_RESPONSE_BUFFER
header: EWF_HEADER
body: STRING_8
feature {WGI_APPLICATION} -- Commit
commit
local
r: like response_buffer
do
r := response_buffer
r.set_status_code (status_code)
r.write_headers_string (header.string)
header_committed := True
r.write_string (body)
r.flush
end
feature -- Status report
header_committed: BOOLEAN
-- Header committed?
message_committed: BOOLEAN
-- Message committed?
message_writable: BOOLEAN
-- Can message be written?
do
Result := status_is_set and header_committed
end
feature -- Status setting
status_is_set: BOOLEAN
-- Is status set?
do
Result := status_code /= 0
end
set_status_code (a_code: INTEGER)
-- Set response status code
-- Should be done before sending any data back to the client
do
status_code := a_code
end
status_code: INTEGER
-- Response status
feature {NONE} -- Status output
write (s: STRING)
-- Send the content of `s'
do
body.append (s)
end
feature -- Header output operation
write_headers_string (a_headers: STRING)
do
write (a_headers)
header_committed := True
end
write_header (a_status_code: INTEGER; a_headers: detachable ARRAY [TUPLE [key: STRING; value: STRING]])
-- Send headers with status `a_status', and headers from `a_headers'
local
h: EWF_HEADER
i,n: INTEGER
do
set_status_code (a_status_code)
create h.make
if a_headers /= Void then
from
i := a_headers.lower
n := a_headers.upper
until
i > n
loop
h.put_header_key_value (a_headers[i].key, a_headers[i].value)
i := i + 1
end
end
header := h
end
feature -- Output operation
write_string (s: STRING)
-- Send the string `s'
do
write (s)
end
write_substring (s: STRING; start_index, end_index: INTEGER)
-- Send the substring `start_index:end_index]'
--| Could be optimized according to the target output
do
write_string (s.substring (start_index, end_index))
end
write_file_content (fn: STRING)
-- Send the content of file `fn'
do
response_buffer.write_file_content (fn)
end
flush
do
--| Do nothing ... this is in_memory response
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

@@ -1,59 +0,0 @@
note
description: "Summary description for {EWF_IN_MEMORY_RESPONSE_APPLICATION}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
EWF_IN_MEMORY_RESPONSE_APPLICATION
inherit
WGI_APPLICATION
rename
execute as app_execute
end
feature -- Execution
app_execute (req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
-- Execute the request
-- See `req.input' for input stream
-- `req.environment' for the Gateway environment
-- and `res' for output buffer
do
execute (req, new_response (req, res))
end
feature -- Execute
execute (req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
-- Execute the request
-- See `req.input' for input stream
-- `req.environment' for the Gateway environment
-- and `res' for output buffer
require
res_status_unset: not res.status_is_set
deferred
ensure
res_status_set: res.status_is_set
end
feature {NONE} -- Implementation
new_response (req: WGI_REQUEST; a_res: WGI_RESPONSE_BUFFER): EWF_IN_MEMORY_RESPONSE
do
create {EWF_IN_MEMORY_RESPONSE} Result.make (a_res)
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

@@ -1,226 +0,0 @@
note
description: "[
An EWSGI response. This may be used as is or specialized (subclassed)
if a developer wishes to reimplement their own version of the feature
'read_message_body_block' for supporting a block-based message body
response.
]"
author: "Paul Cohen <paul.cohen@seibostudio.se>"
status: "Draft"
class WGI_RESPONSE
create
make
feature {NONE} -- Initialization
make
-- Create new response object
do
is_buffered := False
ready_to_transmit := False
end_of_blocks := False
max_block_size := default_max_block_size
current_block := ""
create headers_table.make (10)
end
feature {WGI_RESPONSE_APPLICATION} -- Response status
transmit_to (res: WGI_RESPONSE_BUFFER)
do
res.set_status_code (status)
res.write_headers_string (headers)
from
read_block
res.write_string (last_block)
-- res.flush
until
end_of_blocks
loop
read_block
res.write_string (last_block)
-- res.flush
end
end
ready_to_transmit: BOOLEAN
-- Is this response ready to be transmitted?
set_ready_to_transmit
-- Set response to ready to transmit.
do
if is_buffered then
set_header ("Content-Length", current_block.count.out)
-- elseif tmp_file /= Void then
-- if tmp_file.is_open_write then
-- tmp_file.close
-- set_header ("Content-Length", tmp_file.count.out)
-- end
end
ready_to_transmit := True
ensure
ready_to_transmit
end
feature {WGI_RESPONSE_APPLICATION} -- Message start line and status
status: INTEGER
-- HTTP status code
set_status (s: INTEGER)
-- Set 'status_code'.
do
status := s
set_header ("Status", s.out)
ensure
status = s
end
start_line: STRING
-- HTTP message start-line
do
if attached status as st then
Result := "HTTP/1.1 " + st.out + " " + status_text (st) + crlf
else
Result := "HTTP/1.1 200 " + status_text (200) + crlf
end
end
feature {WGI_RESPONSE_APPLICATION} -- Message headers
headers: STRING
-- HTTP message headers including trailing empty line.
local
t: HASH_TABLE [STRING, STRING]
do
Result := ""
t := headers_table
from
t.start
until
t.after
loop
Result.append (t.key_for_iteration + ": " + t.item_for_iteration + crlf)
t.forth
end
Result.append (crlf)
end
headers_table: HASH_TABLE [STRING, STRING]
-- Hash table of HTTP headers
set_header (key, value: STRING)
-- Set the HTTP header with the given 'key' to the given 'value'.
do
headers_table.put (value, key)
ensure
headers_table.has (key) and headers_table @ key = value
end
feature {WGI_RESPONSE_APPLICATION} -- Message body
read_block
-- Read a message body block.
do
if is_buffered then
end_of_blocks := True
-- else
-- -- File based block-based output
-- -- TBD!
end
ensure
--Commented, since it is far from obvious to ensure that:
-- not is_buffered implies last_block.count <= max_block_size
end
last_block: STRING
-- Last message body block that has been read.
do
Result := current_block
end
is_buffered: BOOLEAN
-- Is the entire entity body buffered in memory (STRING)?
end_of_blocks: BOOLEAN
-- Has the last of the entity body blocks been read?
set_message_body (s: STRING)
-- Set the message body to 's'. Use this for when you want a memory
-- buffered response.
do
current_block := s
is_buffered := True
set_ready_to_transmit
ensure
is_buffered
ready_to_transmit
last_block.is_equal (s)
end
max_block_size: INTEGER
-- Maximum block size returned by message body if not buffered
set_max_block_size (block_size: INTEGER)
-- Set 'max_block_size'.
do
max_block_size := block_size
ensure
max_block_size = block_size
end
-- write_message_block (s: STRING)
-- -- Write message body block 's' to a temporary file. Us this when
-- -- you want a non-buffered response.
-- require
-- not is_buffered
-- do
-- -- TBD!
-- ensure
-- not is_buffered
-- not ready_to_transmit
-- end
feature {NONE} -- Implementation
-- tmp_file_name: STRING
-- tmp_file: detachable FILE
-- -- Created with mktmp
-- position: INTEGER
-- -- Current read position in tmp_file
current_block: STRING
-- Current message body block
default_max_block_size: INTEGER = 65536
-- Default value of 'max_block_size'
crlf: STRING = "%/13/%/10/"
status_text (code: INTEGER): STRING
do
inspect code
when 500 then
Result := "Internal Server Error"
when 200 then
Result := "OK"
else
Result := "Code " + code.out
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

@@ -1,56 +0,0 @@
note
description: "Summary description for {WGI_RESPONSE_APPLICATION} "
legal: "See notice at end of class."
status: "See notice at end of class."
date: "$Date$"
revision: "$Revision$"
deferred class
WGI_RESPONSE_APPLICATION
feature -- Execution
execute (req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
-- Execute the request
-- See `req.input' for input stream
-- `req.environment' for the Gateway environment
-- and `res.output' for output stream
local
rs: WGI_RESPONSE
do
rs := response (req)
if rs.ready_to_transmit then
rs.transmit_to (res)
else
-- Report internal server error.
-- Response not ready to transmit!
-- Implementor of WGI_APPLICATION has not done his job!
create rs.make
rs.set_status (500)
rs.set_header ("Content-Type", "text/plain")
rs.set_message_body ("Incomplete server implementation: Response not ready to transmit.%NTell the programmer to finish his/her job!")
rs.transmit_to (res)
end
end
feature -- Response
response (request: WGI_REQUEST): WGI_RESPONSE
-- HTTP response for given 'request'.
deferred
ensure
ready_to_transmit: Result.ready_to_transmit
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

@@ -1,66 +0,0 @@
note
description: "Summary description for {EWF_ERROR}."
legal: "See notice at end of class."
status: "See notice at end of class."
date: "$Date$"
revision: "$Revision$"
class
EWF_ERROR
inherit
ERROR
HTTP_STATUS_CODE_MESSAGES
create
make
feature {NONE} -- Initialization
make (a_code: INTEGER)
do
code := a_code
name := "HTTP Error"
if attached http_status_code_message (a_code) as m then
name := m
end
end
feature -- Access
code: INTEGER
name: STRING
message: detachable STRING_32
feature -- Element change
set_message (m: like message)
-- Set `message' to `m'
require
m_attached: m /= Void
do
message := m
end
feature -- Visitor
process (a_visitor: ERROR_VISITOR)
-- Process Current using `a_visitor'.
do
a_visitor.process_error (Current)
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

@@ -1,208 +0,0 @@
note
description: "[
Eiffel tests that can be executed by testing tool.
]"
author: "EiffelStudio test wizard"
date: "$Date$"
revision: "$Revision$"
testing: "type/manual"
class
TEST_EWSGI_REQUEST
inherit
EQA_TEST_SET
redefine
on_prepare,
on_clean
end
feature {NONE} -- Events
web_app: detachable NINO_APPLICATION
port_number: INTEGER
base_url: detachable STRING
on_prepare
-- <Precursor>
local
app: NINO_APPLICATION
wt: WORKER_THREAD
e: EXECUTION_ENVIRONMENT
do
port_number := 8087
base_url := "test/"
create app.make_custom (agent execute, base_url)
web_app := app
create wt.make (agent app.listen (port_number))
wt.launch
create e
e.sleep (1_000_000_000 * 5)
end
execute (req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
local
q: detachable STRING_32
do
if attached req.request_uri as l_uri then
if l_uri.starts_with (test_url ("get/01")) then
res.write_header (200, <<["Content-Type", "text/plain"]>>)
res.write_string ("get-01")
create q.make_empty
across
req.query_parameters as qcur
loop
if not q.is_empty then
q.append_character ('&')
end
q.append (qcur.item.name.as_string_32 + "=" + qcur.item.as_string)
end
if not q.is_empty then
res.write_string ("(" + q + ")")
end
elseif l_uri.starts_with (test_url ("post/01")) then
res.write_header (200, <<["Content-Type", "text/plain"]>>)
res.write_string ("post-01")
create q.make_empty
across
req.query_parameters as qcur
loop
if not q.is_empty then
q.append_character ('&')
end
q.append (qcur.item.name.as_string_32 + "=" + qcur.item.as_string)
end
if not q.is_empty then
res.write_string ("(" + q + ")")
end
create q.make_empty
across
req.form_data_parameters as fcur
loop
if not q.is_empty then
q.append_character ('&')
end
q.append (fcur.item.name.as_string_32 + "=" + fcur.item.as_string)
end
if not q.is_empty then
res.write_string (" : " + q )
end
else
res.write_header (200, <<["Content-Type", "text/plain"]>>)
res.write_string ("Hello")
end
else
res.write_header (200, <<["Content-Type", "text/plain"]>>)
res.write_string ("Bye")
end
end
test_url (a_query_url: READABLE_STRING_8): READABLE_STRING_8
local
b: like base_url
do
b := base_url
if b = Void then
b := ""
end
Result := "/" + b + a_query_url
end
on_clean
-- <Precursor>
do
if attached web_app as app then
app.shutdown
end
end
http_session: detachable HTTP_CLIENT_SESSION
get_http_session
local
h: LIBCURL_HTTP_CLIENT
b: like base_url
do
create h.make
b := base_url
if b = Void then
b := ""
end
if attached {HTTP_CLIENT_SESSION} h.new_session ("localhost:" + port_number.out + "/" + b) as sess then
http_session := sess
sess.set_timeout (-1)
sess.set_connect_timeout (-1)
end
end
test_get_request (a_url: READABLE_STRING_8; ctx: detachable HTTP_CLIENT_REQUEST_CONTEXT; a_expected_body: READABLE_STRING_8)
do
get_http_session
if attached http_session as sess then
if attached sess.get (a_url, ctx) as res and then not res.error_occurred and then attached res.body as l_body then
assert ("Good answer got=%""+l_body+"%" expected=%""+a_expected_body+"%"", l_body.same_string (a_expected_body))
else
assert ("Request %""+a_url+"%" failed", False)
end
end
end
test_post_request (a_url: READABLE_STRING_8; ctx: detachable HTTP_CLIENT_REQUEST_CONTEXT; a_expected_body: READABLE_STRING_8)
do
get_http_session
if attached http_session as sess then
if attached sess.post (a_url, ctx, Void) as res and then not res.error_occurred and then attached res.body as l_body then
assert ("Good answer got=%""+l_body+"%" expected=%""+a_expected_body+"%"", l_body.same_string (a_expected_body))
else
assert ("Request %""+a_url+"%" failed", False)
end
end
end
feature -- Test routines
test_get_request_01
-- New test routine
do
get_http_session
if attached http_session as sess then
test_get_request ("get/01", Void, "get-01")
test_get_request ("get/01/?foo=bar", Void, "get-01(foo=bar)")
test_get_request ("get/01/?foo=bar&abc=def", Void, "get-01(foo=bar&abc=def)")
test_get_request ("get/01/?lst=a&lst=b", Void, "get-01(lst=[a,b])")
else
assert ("not_implemented", False)
end
end
test_post_request_01
-- New test routine
local
ctx: HTTP_CLIENT_REQUEST_CONTEXT
do
get_http_session
if attached http_session as sess then
create ctx.make
ctx.add_form_data_parameter ("id", "123")
test_post_request ("post/01", ctx, "post-01 : id=123")
test_post_request ("post/01/?foo=bar", ctx, "post-01(foo=bar) : id=123")
test_post_request ("post/01/?foo=bar&abc=def", ctx, "post-01(foo=bar&abc=def) : id=123")
test_post_request ("post/01/?lst=a&lst=b", ctx, "post-01(lst=[a,b]) : id=123")
else
assert ("not_implemented", False)
end
end
end

View File

@@ -1,21 +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="tests" uuid="4C432110-F2DA-4D69-B80B-268CC1253B78">
<target name="tests">
<root class="ANY" feature="default_create"/>
<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">
</option>
<setting name="concurrency" value="thread"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="ewsgi_nino" location="..\default\ewsgi_nino-safe.ecf" readonly="false"/>
<library name="ewsgi" location="..\ewsgi-safe.ecf" readonly="false"/>
<library name="http_client" location="..\..\..\client\http_client\http_client-safe.ecf"/>
<library name="testing" location="$ISE_LIBRARY\library\testing\testing-safe.ecf"/>
<library name="thread" location="$ISE_LIBRARY\library\thread\thread-safe.ecf"/>
<tests name="src" location=".\" recursive="true"/>
</target>
</system>

View File

@@ -1,21 +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="tests" uuid="4C432110-F2DA-4D69-B80B-268CC1253B78">
<target name="tests">
<root class="ANY" feature="default_create"/>
<file_rule>
<exclude>/.git$</exclude>
<exclude>/EIFGENs$</exclude>
<exclude>/.svn$</exclude>
</file_rule>
<option warning="true" full_class_checking="true" void_safety="none" syntax="provisional">
</option>
<setting name="concurrency" value="none"/>
<library name="base" location="$ISE_LIBRARY/library/base/base.ecf"/>
<library name="ewsgi_nino" location="..\default\ewsgi_nino.ecf"/>
<library name="ewsgi" location="..\ewsgi.ecf"/>
<library name="http_client" location="..\..\..\client\http_client\http_client.ecf"/>
<library name="testing" location="$ISE_LIBRARY/library/testing/testing.ecf"/>
<library name="thread" location="$ISE_LIBRARY\library\thread\thread-safe.ecf"/>
<tests name="src" location="." recursive="true"/>
</target>
</system>