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

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ISO-8859-1"?> <?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_routed_world" uuid="7C9887BD-4AE4-47F2-A0AA-4BBB6736D433"> <system xmlns="http://www.eiffel.com/developers/xml/configuration-1-9-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-9-0 http://www.eiffel.com/developers/xml/configuration-1-9-0.xsd" name="hello_routed_world" uuid="7C9887BD-4AE4-47F2-A0AA-4BBB6736D433">
<target name="hello_routed_world"> <target name="hello_routed_world">
<root class="HELLO_ROUTED_WORLD" feature="make"/> <root class="HELLO_ROUTED_WORLD" feature="make"/>
<file_rule> <file_rule>
@@ -8,14 +8,14 @@
<exclude>/\.svn$</exclude> <exclude>/\.svn$</exclude>
</file_rule> </file_rule>
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="provisional"> <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"/> <assertions precondition="true" postcondition="true" check="true" invariant="true" supplier_precondition="true"/>
</option> </option>
<setting name="concurrency" value="thread"/> <setting name="concurrency" value="thread"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/> <library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="connector_nino" location="..\..\library\server\ewsgi\connectors\nino\nino-safe.ecf" readonly="false"/> <library name="connector_nino" location="..\..\library\server\ewsgi\connectors\nino\nino-safe.ecf" readonly="false"/>
<library name="default_nino" location="..\..\library\server\ewsgi\default\ewsgi_nino-safe.ecf" readonly="false"/> <library name="default_nino" location="..\..\library\server\wsf\default\nino-safe.ecf" readonly="false"/>
<library name="encoder" location="..\..\library\text\encoder\encoder-safe.ecf" readonly="false"/> <library name="encoder" location="..\..\library\text\encoder\encoder-safe.ecf" readonly="false"/>
<library name="ewsgi" location="..\..\library\server\ewsgi\ewsgi-safe.ecf" readonly="false"/> <library name="wsf" location="..\..\library\server\wsf\wsf-safe.ecf" readonly="false"/>
<library name="http" location="..\..\library\protocol\http\http-safe.ecf" readonly="false"/> <library name="http" location="..\..\library\protocol\http\http-safe.ecf" readonly="false"/>
<library name="router" location="..\..\library\server\request\router\router-safe.ecf" readonly="false"/> <library name="router" location="..\..\library\server\request\router\router-safe.ecf" readonly="false"/>
<library name="uri_template" location="..\..\library\protocol\uri_template\uri_template-safe.ecf" readonly="false"/> <library name="uri_template" location="..\..\library\protocol\uri_template\uri_template-safe.ecf" readonly="false"/>

View File

@@ -14,7 +14,7 @@ inherit
ROUTED_APPLICATION_HELPER ROUTED_APPLICATION_HELPER
DEFAULT_WGI_APPLICATION DEFAULT_APPLICATION
create create
make make
@@ -82,9 +82,9 @@ feature {NONE} -- Initialization
feature -- Execution feature -- Execution
execute_default (req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) execute_default (req: WSF_REQUEST; res: WSF_RESPONSE)
local local
h: EWF_HEADER h: WSF_HEADER
l_url: STRING l_url: STRING
e: EXECUTION_ENVIRONMENT e: EXECUTION_ENVIRONMENT
n: INTEGER n: INTEGER
@@ -133,7 +133,7 @@ feature -- Execution
write_chunk (Void, res) write_chunk (Void, res)
end end
write_chunk (s: detachable READABLE_STRING_8; res: WGI_RESPONSE_BUFFER) write_chunk (s: detachable READABLE_STRING_8; res: WSF_RESPONSE)
do do
if s /= Void then if s /= Void then
res.write_string (s.count.to_hex_string + {HTTP_CONSTANTS}.crlf) res.write_string (s.count.to_hex_string + {HTTP_CONSTANTS}.crlf)
@@ -144,7 +144,7 @@ feature -- Execution
res.flush res.flush
end end
execute_home (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) execute_home (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE)
local local
l_body: STRING_8 l_body: STRING_8
do do
@@ -168,10 +168,10 @@ feature -- Execution
res.write_string (l_body) res.write_string (l_body)
end end
execute_hello (req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER; a_name: detachable READABLE_STRING_32; ctx: REQUEST_HANDLER_CONTEXT) execute_hello (req: WSF_REQUEST; res: WSF_RESPONSE; a_name: detachable READABLE_STRING_32; ctx: REQUEST_HANDLER_CONTEXT)
local local
l_response_content_type: detachable STRING l_response_content_type: detachable STRING
h: EWF_HEADER h: WSF_HEADER
content_type_supported: ARRAY [STRING] content_type_supported: ARRAY [STRING]
l_body: STRING_8 l_body: STRING_8
do do
@@ -207,33 +207,33 @@ feature -- Execution
end end
end end
handle_hello (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) handle_hello (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE)
do do
execute_hello (req, res, Void, ctx) execute_hello (req, res, Void, ctx)
end end
handle_anonymous_hello (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) handle_anonymous_hello (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE)
do do
execute_hello (req, res, ctx.string_parameter ("name"), ctx) execute_hello (req, res, ctx.string_parameter ("name"), ctx)
end end
handle_method_any (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) handle_method_any (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE)
do do
execute_hello (req, res, req.request_method, ctx) execute_hello (req, res, req.request_method, ctx)
end end
handle_method_get (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) handle_method_get (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE)
do do
execute_hello (req, res, "GET", ctx) execute_hello (req, res, "GET", ctx)
end end
handle_method_post (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) handle_method_post (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE)
do do
execute_hello (req, res, "POST", ctx) execute_hello (req, res, "POST", ctx)
end end
handle_method_get_or_post (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) handle_method_get_or_post (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE)
do do
execute_hello (req, res, "GET or POST", ctx) execute_hello (req, res, "GET or POST", ctx)
end end

View File

@@ -13,9 +13,9 @@
<setting name="concurrency" value="thread"/> <setting name="concurrency" value="thread"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/> <library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="connector_nino" location="..\..\library\server\ewsgi\connectors\nino\nino-safe.ecf" readonly="false"/> <library name="connector_nino" location="..\..\library\server\ewsgi\connectors\nino\nino-safe.ecf" readonly="false"/>
<library name="default_nino" location="..\..\library\server\ewsgi\default\ewsgi_nino-safe.ecf" readonly="false"/> <library name="default_nino" location="..\..\library\server\wsf\default\nino-safe.ecf" readonly="false"/>
<library name="encoder" location="..\..\library\text\encoder\encoder-safe.ecf" readonly="false"/> <library name="encoder" location="..\..\library\text\encoder\encoder-safe.ecf" readonly="false"/>
<library name="ewsgi" location="..\..\library\server\ewsgi\ewsgi-safe.ecf" readonly="false"/> <library name="wsf" location="..\..\library\server\wsf\wsf-safe.ecf" readonly="false"/>
<library name="json" location="..\..\ext\text\json\library\json-safe.ecf" readonly="false"/> <library name="json" location="..\..\ext\text\json\library\json-safe.ecf" readonly="false"/>
<library name="http" location="..\..\library\protocol\http\http-safe.ecf" readonly="false"/> <library name="http" location="..\..\library\protocol\http\http-safe.ecf" readonly="false"/>
<library name="router" location="..\..\library\server\request\router\router-safe.ecf" readonly="false"/> <library name="router" location="..\..\library\server\request\router\router-safe.ecf" readonly="false"/>

View File

@@ -22,7 +22,7 @@ inherit
feature -- execute feature -- execute
execute (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) execute (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute request handler -- Execute request handler
do do
execute_methods (ctx, req, res) execute_methods (ctx, req, res)
@@ -34,7 +34,7 @@ feature -- API DOC
feature -- HTTP Methods feature -- HTTP Methods
do_get (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) do_get (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
-- Using GET to retrieve resource information. -- Using GET to retrieve resource information.
-- If the GET request is SUCCESS, we response with -- If the GET request is SUCCESS, we response with
-- 200 OK, and a representation of the order -- 200 OK, and a representation of the order
@@ -53,9 +53,9 @@ feature -- HTTP Methods
end end
end end
compute_response_get (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER; l_order : ORDER) compute_response_get (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE; l_order : ORDER)
local local
h: EWF_HEADER h: WSF_HEADER
l_msg : STRING l_msg : STRING
do do
create h.make create h.make
@@ -73,12 +73,12 @@ feature -- HTTP Methods
end end
end end
do_put (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) do_put (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
local local
l_post: STRING l_post: STRING
l_location : STRING l_location : STRING
l_order : detachable ORDER l_order : detachable ORDER
h : EWF_HEADER h : WSF_HEADER
do do
fixme ("TODO handle an Internal Server Error") fixme ("TODO handle an Internal Server Error")
fixme ("Refactor the code, create new abstractions") fixme ("Refactor the code, create new abstractions")
@@ -111,10 +111,10 @@ feature -- HTTP Methods
end end
end end
do_delete (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) do_delete (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
local local
id: STRING id: STRING
h : EWF_HEADER h : WSF_HEADER
do do
fixme ("TODO handle an Internal Server Error") fixme ("TODO handle an Internal Server Error")
fixme ("Refactor the code, create new abstractions") fixme ("Refactor the code, create new abstractions")
@@ -136,7 +136,7 @@ feature -- HTTP Methods
end end
end end
do_post (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) do_post (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
-- Here the convention is the following. -- Here the convention is the following.
-- POST is used for creation and the server determines the URI -- POST is used for creation and the server determines the URI
-- of the created resource. -- of the created resource.
@@ -158,9 +158,9 @@ feature -- HTTP Methods
end end
end end
compute_response_post (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER; l_order : ORDER) compute_response_post (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE; l_order : ORDER)
local local
h: EWF_HEADER h: WSF_HEADER
l_msg : STRING l_msg : STRING
l_location : STRING l_location : STRING
joc : JSON_ORDER_CONVERTER joc : JSON_ORDER_CONVERTER

View File

@@ -14,7 +14,7 @@ inherit
ROUTED_APPLICATION_HELPER ROUTED_APPLICATION_HELPER
DEFAULT_WGI_APPLICATION DEFAULT_APPLICATION
create create
make make
@@ -43,12 +43,12 @@ feature {NONE} -- Initialization
feature -- Execution feature -- Execution
execute_default (req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) execute_default (req: WSF_REQUEST; res: WSF_RESPONSE)
-- I'm using this method to handle the method not allowed response -- I'm using this method to handle the method not allowed response
-- in the case that the given uri does not have a corresponding http method -- in the case that the given uri does not have a corresponding http method
-- to handle it. -- to handle it.
local local
h : EWF_HEADER h : WSF_HEADER
l_description : STRING l_description : STRING
l_api_doc : STRING l_api_doc : STRING
do do

View File

@@ -10,6 +10,7 @@
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all"> <option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all">
</option> </option>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/> <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="ewsgi" location="..\..\ewsgi-safe.ecf" readonly="false"/>
<library name="http" location="..\..\..\..\protocol\http\http-safe.ecf"/> <library name="http" location="..\..\..\..\protocol\http\http-safe.ecf"/>
<cluster name="src" location=".\src\" recursive="true"/> <cluster name="src" location=".\src\" recursive="true"/>

View File

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

View File

@@ -1,11 +1,11 @@
note note
description: "Summary description for {EWF_CGI_CONNECTOR}." description: "Summary description for {WGI_CGI_CONNECTOR}."
author: "" author: ""
date: "$Date$" date: "$Date$"
revision: "$Revision$" revision: "$Revision$"
class class
EWF_CGI_CONNECTOR WGI_CGI_CONNECTOR
inherit inherit
WGI_CONNECTOR WGI_CONNECTOR
@@ -22,8 +22,8 @@ feature -- Execution
rescued: BOOLEAN rescued: BOOLEAN
do do
if not rescued then if not rescued then
create req.make ((create {EXECUTION_ENVIRONMENT}).starting_environment_variables, create {EWF_CGI_INPUT_STREAM}.make) create req.make ((create {EXECUTION_ENVIRONMENT}).starting_environment_variables, create {WGI_CGI_INPUT_STREAM}.make)
create res.make (create {EWF_CGI_OUTPUT_STREAM}.make) create res.make (create {WGI_CGI_OUTPUT_STREAM}.make)
application.execute (req, res) application.execute (req, res)
else else
if attached (create {EXCEPTION_MANAGER}).last_exception as e and then attached e.exception_trace as l_trace then 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 note
description: "Summary description for EWF_CGI_INPUT_STREAM." description: "Summary description for WGI_CGI_INPUT_STREAM."
legal: "See notice at end of class." legal: "See notice at end of class."
status: "See notice at end of class." status: "See notice at end of class."
date: "$Date$" date: "$Date$"
revision: "$Revision$" revision: "$Revision$"
class class
EWF_CGI_INPUT_STREAM WGI_CGI_INPUT_STREAM
inherit inherit
WGI_INPUT_STREAM WGI_INPUT_STREAM

View File

@@ -1,12 +1,12 @@
note note
description: "Summary description for EWF_CGI_OUTPUT_STREAM." description: "Summary description for WGI_CGI_OUTPUT_STREAM."
legal: "See notice at end of class." legal: "See notice at end of class."
status: "See notice at end of class." status: "See notice at end of class."
date: "$Date$" date: "$Date$"
revision: "$Revision$" revision: "$Revision$"
class class
EWF_CGI_OUTPUT_STREAM WGI_CGI_OUTPUT_STREAM
inherit inherit
WGI_OUTPUT_STREAM 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 warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all">
</option> </option>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/> <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="ewsgi" location="..\..\ewsgi-safe.ecf" readonly="false"/>
<library name="libfcgi" location="..\..\..\libfcgi\libfcgi-safe.ecf" /> <library name="libfcgi" location="..\..\..\libfcgi\libfcgi-safe.ecf" />
<library name="http" location="..\..\..\..\protocol\http\http-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 warning="true" full_class_checking="true">
</option> </option>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/> <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="ewsgi" location="..\..\ewsgi.ecf" readonly="false"/>
<library name="libfcgi" location="..\..\..\libfcgi\libfcgi.ecf" /> <library name="libfcgi" location="..\..\..\libfcgi\libfcgi.ecf" />
<library name="http" location="..\..\..\..\protocol\http\http.ecf"/> <library name="http" location="..\..\..\..\protocol\http\http.ecf"/>

View File

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

View File

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

View File

@@ -1,12 +1,12 @@
note note
description: "Summary description for {EWF_LIBFCGI_OUTPUT_STREAM}." description: "Summary description for {WGI_LIBFCGI_OUTPUT_STREAM}."
legal: "See notice at end of class." legal: "See notice at end of class."
status: "See notice at end of class." status: "See notice at end of class."
date: "$Date$" date: "$Date$"
revision: "$Revision$" revision: "$Revision$"
class class
EWF_LIBFCGI_OUTPUT_STREAM WGI_LIBFCGI_OUTPUT_STREAM
inherit inherit
WGI_OUTPUT_STREAM 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 warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all">
</option> </option>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/> <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="ewsgi" location="..\..\ewsgi-safe.ecf" readonly="false"/>
<library name="http" location="..\..\..\..\protocol\http\http-safe.ecf"/> <library name="http" location="..\..\..\..\protocol\http\http-safe.ecf"/>
<library name="nino" location="..\..\..\..\..\ext\server\nino\nino-safe.ecf" readonly="false"> <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 warning="true" full_class_checking="true">
</option> </option>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/> <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="ewsgi" location="..\..\ewsgi.ecf" readonly="false"/>
<library name="http" location="..\..\..\..\protocol\http\http.ecf"/> <library name="http" location="..\..\..\..\protocol\http\http.ecf"/>
<library name="nino" location="..\..\..\..\..\ext\server\nino\nino.ecf" readonly="false"> <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) create connector.make_with_base (app, a_base_url)
end end
connector: EWF_NINO_CONNECTOR connector: WGI_NINO_CONNECTOR
-- Web server connector -- Web server connector
feature -- Status settings feature -- Status settings

View File

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

View File

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

View File

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

View File

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

Binary file not shown.

View File

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

View File

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

@@ -42,7 +42,7 @@
<root class="APP_SERVER" feature="make"/> <root class="APP_SERVER" feature="make"/>
<setting name="executable_name" value="sample"/> <setting name="executable_name" value="sample"/>
<library name="ewsgi_nino" location="..\..\..\ewsgi/connectors\nino\nino-safe.ecf" readonly="false"/> <library name="ewsgi_nino" location="..\..\..\ewsgi/connectors\nino\nino-safe.ecf" readonly="false"/>
<library name="ewsgi_default_nino" location="..\..\..\ewsgi/default\ewsgi_nino-safe.ecf" readonly="false"/> <library name="default_nino" location="..\..\..\wsf\default\nino-safe.ecf" readonly="false"/>
<cluster name="src" location=".\src\" recursive="true"> <cluster name="src" location=".\src\" recursive="true">

View File

@@ -8,7 +8,7 @@ feature -- Access
build_gateway_and_launch build_gateway_and_launch
local local
cgi: EWF_CGI_CONNECTOR cgi: WGI_CGI_CONNECTOR
do do
create cgi.make (Current) create cgi.make (Current)
cgi.launch cgi.launch

View File

@@ -8,7 +8,7 @@ feature -- Access
build_gateway_and_launch build_gateway_and_launch
local local
libfcgi: EWF_LIBFCGI_CONNECTOR libfcgi: WGI_LIBFCGI_CONNECTOR
do do
create libfcgi.make (Current) create libfcgi.make (Current)
libfcgi.launch libfcgi.launch

View File

@@ -18,7 +18,7 @@ feature -- Access
print ("Example: start a Nino web server on port " + port_number.out + 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") ", %Nand reply Hello World for any request such as http://localhost:" + port_number.out + "/" + base_url + "%N")
end end
create app.make_custom (agent execute, base_url) create app.make_custom (agent wgi_execute, base_url)
app.force_single_threaded app.force_single_threaded
app.listen (port_number) app.listen (port_number)

View File

@@ -16,14 +16,14 @@ create
feature -- Format feature -- Format
get_format_id (a_format_variable_name: detachable READABLE_STRING_GENERAL; a_content_type_supported: detachable ARRAY [STRING_8]) get_format_id (a_format_variable_name: detachable READABLE_STRING_8; a_content_type_supported: detachable ARRAY [STRING_8])
do do
if internal_format_id = 0 then if internal_format_id = 0 then
internal_format_id := request_format_id (a_format_variable_name, a_content_type_supported) internal_format_id := request_format_id (a_format_variable_name, a_content_type_supported)
end end
end end
get_format_name (a_format_variable_name: detachable READABLE_STRING_GENERAL; a_content_type_supported: detachable ARRAY [STRING_8]) get_format_name (a_format_variable_name: detachable READABLE_STRING_8; a_content_type_supported: detachable ARRAY [STRING_8])
do do
if internal_format_name = Void then if internal_format_name = Void then
internal_format_name := request_format (a_format_variable_name, a_content_type_supported) internal_format_name := request_format (a_format_variable_name, a_content_type_supported)

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="ISO-8859-1"?> <?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"> <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="default_cgi" uuid="A9137009-B5BA-4C58-BCD3-7753909918B5" library_target="default_cgi">
<target name="ewsgi_cgi"> <target name="default_cgi">
<root all_classes="true"/> <root all_classes="true"/>
<file_rule> <file_rule>
<exclude>/EIFGENs$</exclude> <exclude>/EIFGENs$</exclude>
@@ -11,8 +11,9 @@
</option> </option>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/> <library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/> <library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
<library name="ewsgi" location="../ewsgi-safe.ecf"/> <library name="ewsgi" location="../../ewsgi/ewsgi-safe.ecf"/>
<library name="connector_cgi" location="../connectors/cgi/cgi-safe.ecf"/> <library name="wsf" location="../wsf-safe.ecf"/>
<library name="connector_cgi" location="../../ewsgi/connectors/cgi/cgi-safe.ecf"/>
<library name="error" location="..\..\..\error\error-safe.ecf"/> <library name="error" location="..\..\..\error\error-safe.ecf"/>
<library name="http" location="..\..\..\protocol\http\http-safe.ecf"/> <library name="http" location="..\..\..\protocol\http\http-safe.ecf"/>
<library name="encoder" location="..\..\..\text\encoder\encoder-safe.ecf" readonly="false"/> <library name="encoder" location="..\..\..\text\encoder\encoder-safe.ecf" readonly="false"/>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="ISO-8859-1"?> <?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"> <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="default_cgi" uuid="A9137009-B5BA-4C58-BCD3-7753909918B5" library_target="default_cgi">
<target name="ewsgi_cgi"> <target name="default_cgi">
<root all_classes="true"/> <root all_classes="true"/>
<file_rule> <file_rule>
<exclude>/EIFGENs$</exclude> <exclude>/EIFGENs$</exclude>
@@ -11,8 +11,9 @@
</option> </option>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/> <library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="time" location="$ISE_LIBRARY\library\time\time.ecf"/> <library name="time" location="$ISE_LIBRARY\library\time\time.ecf"/>
<library name="ewsgi" location="../ewsgi.ecf"/> <library name="ewsgi" location="../../ewsgi/ewsgi.ecf"/>
<library name="connector_cgi" location="../connectors/cgi/cgi.ecf"/> <library name="wsf" location="../wsf.ecf"/>
<library name="connector_cgi" location="../../ewsgi/connectors/cgi/cgi.ecf"/>
<library name="error" location="..\..\..\error\error.ecf"/> <library name="error" location="..\..\..\error\error.ecf"/>
<library name="http" location="..\..\..\protocol\http\http.ecf"/> <library name="http" location="..\..\..\protocol\http\http.ecf"/>
<library name="encoder" location="..\..\..\text\encoder\encoder.ecf" readonly="false"/> <library name="encoder" location="..\..\..\text\encoder\encoder.ecf" readonly="false"/>

View File

@@ -1,19 +1,19 @@
note note
description: "Summary description for {DEFAULT_WGI_APPLICATION}." description: "Summary description for {DEFAULT_APPLICATION}."
date: "$Date$" date: "$Date$"
revision: "$Revision$" revision: "$Revision$"
deferred class deferred class
DEFAULT_WGI_APPLICATION DEFAULT_APPLICATION
inherit inherit
WGI_APPLICATION WSF_APPLICATION
feature {NONE} -- Initialization feature {NONE} -- Initialization
make_and_launch make_and_launch
local local
cgi: EWF_CGI_CONNECTOR cgi: WGI_CGI_CONNECTOR
do do
create cgi.make (Current) create cgi.make (Current)
cgi.launch cgi.launch

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="ISO-8859-1"?> <?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"> <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="default_nino" uuid="ACBEDC97-956C-45F5-97E3-65A6D9987625" library_target="default_nino">
<target name="ewsgi_nino"> <target name="default_nino">
<root all_classes="true"/> <root all_classes="true"/>
<file_rule> <file_rule>
<exclude>/EIFGENs$</exclude> <exclude>/EIFGENs$</exclude>
@@ -11,8 +11,9 @@
</option> </option>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/> <library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/> <library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
<library name="ewsgi" location="../ewsgi-safe.ecf"/> <library name="ewsgi" location="../../ewsgi/ewsgi-safe.ecf"/>
<library name="connector_nino" location="../connectors/nino/nino-safe.ecf"/> <library name="wsf" location="../wsf-safe.ecf"/>
<library name="connector_nino" location="../../ewsgi/connectors/nino/nino-safe.ecf"/>
<library name="nino" location="..\..\..\..\ext\server\nino\nino-safe.ecf" readonly="false"> <library name="nino" location="..\..\..\..\ext\server\nino\nino-safe.ecf" readonly="false">
<renaming old_name="HTTP_CONSTANTS" new_name="NINO_HTTP_CONSTANTS"/> <renaming old_name="HTTP_CONSTANTS" new_name="NINO_HTTP_CONSTANTS"/>
</library> </library>

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="ISO-8859-1"?> <?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"> <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="default_nino" uuid="ACBEDC97-956C-45F5-97E3-65A6D9987625" library_target="default_nino">
<target name="ewsgi_nino"> <target name="default_nino">
<root all_classes="true"/> <root all_classes="true"/>
<file_rule> <file_rule>
<exclude>/EIFGENs$</exclude> <exclude>/EIFGENs$</exclude>
@@ -11,8 +11,9 @@
</option> </option>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/> <library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="time" location="$ISE_LIBRARY\library\time\time.ecf"/> <library name="time" location="$ISE_LIBRARY\library\time\time.ecf"/>
<library name="ewsgi" location="../ewsgi.ecf"/> <library name="ewsgi" location="../../ewsgi/ewsgi.ecf"/>
<library name="connector_nino" location="../connectors/nino/nino.ecf"/> <library name="wsf" location="../wsf.ecf"/>
<library name="connector_nino" location="../../ewsgi/connectors/nino/nino.ecf"/>
<library name="nino" location="..\..\..\..\ext\server\nino\nino.ecf" readonly="false"> <library name="nino" location="..\..\..\..\ext\server\nino\nino.ecf" readonly="false">
<renaming old_name="HTTP_CONSTANTS" new_name="NINO_HTTP_CONSTANTS"/> <renaming old_name="HTTP_CONSTANTS" new_name="NINO_HTTP_CONSTANTS"/>
</library> </library>

View File

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

View File

@@ -23,424 +23,12 @@ class
WSF_HEADER WSF_HEADER
inherit inherit
ANY EWF_HEADER
HTTP_STATUS_CODE_MESSAGES --| useful for `put_status'
export
{NONE} all
end
create create
make, make,
make_with_count make_with_count
feature {NONE} -- Initialization
make
-- Initialize current
do
make_with_count (3)
end
make_with_count (n: INTEGER)
-- Make with a capacity of `n' header entries
do
create {ARRAYED_LIST [READABLE_STRING_8]} headers.make (n)
end
feature -- Recycle
recycle
-- Recycle current object
do
headers.wipe_out
end
feature -- Access
headers: LIST [READABLE_STRING_8]
-- Header's lines
string: STRING
-- String representation of the headers
local
l_headers: like headers
do
create Result.make (32)
l_headers := headers
if l_headers.is_empty then
put_content_type_text_html -- See if this make sense to define a default content-type
else
from
l_headers.start
until
l_headers.after
loop
append_line_to (l_headers.item, Result)
l_headers.forth
end
end
append_end_of_line_to (Result)
end
feature -- Header change: general
add_header (h: READABLE_STRING_8)
-- Add header `h'
-- if it already exists, there will be multiple header with same name
-- which can also be valid
require
h_not_empty: not h.is_empty
do
headers.force (h)
end
put_header (h: READABLE_STRING_8)
-- Add header `h' or replace existing header of same header name
require
h_not_empty: not h.is_empty
do
force_header_by_name (header_name (h), h)
end
add_header_key_value (k,v: READABLE_STRING_8)
-- Add header `k:v', or replace existing header of same header name/key
do
add_header (k + colon_space + v)
end
put_header_key_value (k,v: READABLE_STRING_8)
-- Add header `k:v', or replace existing header of same header name/key
do
put_header (k + colon_space + v)
end
feature -- Status related
put_status (c: INTEGER)
-- Put "Status: " header
-- Rarely used
local
s: STRING
do
create s.make_from_string (c.out)
if attached http_status_code_message (c) as msg then
s.append_character (' ')
s.append (msg)
end
put_header_key_value ("Status", s)
end
feature -- Content related header
put_content_type (t: READABLE_STRING_8)
do
put_header_key_value ({HTTP_HEADER_NAMES}.header_content_type, t)
end
add_content_type (t: READABLE_STRING_8)
-- same as `put_content_type', but allow multiple definition of "Content-Type"
do
add_header_key_value ({HTTP_HEADER_NAMES}.header_content_type, t)
end
put_content_type_with_name (t: READABLE_STRING_8; n: READABLE_STRING_8)
do
put_header_key_value ({HTTP_HEADER_NAMES}.header_content_type, t + "; name=%"" + n + "%"")
end
add_content_type_with_name (t: READABLE_STRING_8; n: READABLE_STRING_8)
-- same as `put_content_type_with_name', but allow multiple definition of "Content-Type"
do
add_header_key_value ({HTTP_HEADER_NAMES}.header_content_type, t + "; name=%"" + n + "%"")
end
put_content_length (n: INTEGER)
do
put_header_key_value ({HTTP_HEADER_NAMES}.header_content_length, n.out)
end
put_content_transfer_encoding (a_mechanism: READABLE_STRING_8)
-- Put "Content-Transfer-Encoding" header with for instance "binary"
--| encoding := "Content-Transfer-Encoding" ":" mechanism
--|
--| mechanism := "7bit" ; case-insensitive
--| / "quoted-printable"
--| / "base64"
--| / "8bit"
--| / "binary"
--| / x-token
do
put_header_key_value ({HTTP_HEADER_NAMES}.header_content_transfer_encoding, a_mechanism)
end
put_transfer_encoding (a_enc: READABLE_STRING_8)
-- Put "Transfer-Encoding" header with for instance "chunked"
do
put_header_key_value ({HTTP_HEADER_NAMES}.header_transfer_encoding, a_enc)
end
put_transfer_encoding_chunked
-- Put "Transfer-Encoding: chunked" header
do
put_transfer_encoding ("chunked")
end
put_content_disposition (a_type: READABLE_STRING_8; a_params: detachable READABLE_STRING_8)
-- Put "Content-Disposition" header
--| See RFC2183
--| disposition := "Content-Disposition" ":"
--| disposition-type
--| *(";" disposition-parm)
--| disposition-type := "inline"
--| / "attachment"
--| / extension-token
--| ; values are not case-sensitive
--| disposition-parm := filename-parm
--| / creation-date-parm
--| / modification-date-parm
--| / read-date-parm
--| / size-parm
--| / parameter
--| filename-parm := "filename" "=" value
--| creation-date-parm := "creation-date" "=" quoted-date-time
--| modification-date-parm := "modification-date" "=" quoted-date-time
--| read-date-parm := "read-date" "=" quoted-date-time
--| size-parm := "size" "=" 1*DIGIT
--| quoted-date-time := quoted-string
--| ; contents MUST be an RFC 822 `date-time'
--| ; numeric timezones (+HHMM or -HHMM) MUST be used
do
if a_params /= Void then
put_header_key_value ({HTTP_HEADER_NAMES}.header_content_disposition, a_type + semi_colon_space + a_params)
else
put_header_key_value ({HTTP_HEADER_NAMES}.header_content_disposition, a_type)
end
end
feature -- Content-type helpers
put_content_type_text_css do put_content_type ({HTTP_MIME_TYPES}.text_css) end
put_content_type_text_csv do put_content_type ({HTTP_MIME_TYPES}.text_csv) end
put_content_type_text_html do put_content_type ({HTTP_MIME_TYPES}.text_html) end
put_content_type_text_javascript do put_content_type ({HTTP_MIME_TYPES}.text_javascript) end
put_content_type_text_json do put_content_type ({HTTP_MIME_TYPES}.text_json) end
put_content_type_text_plain do put_content_type ({HTTP_MIME_TYPES}.text_plain) end
put_content_type_text_xml do put_content_type ({HTTP_MIME_TYPES}.text_xml) end
put_content_type_application_json do put_content_type ({HTTP_MIME_TYPES}.application_json) end
put_content_type_application_javascript do put_content_type ({HTTP_MIME_TYPES}.application_javascript) end
put_content_type_application_zip do put_content_type ({HTTP_MIME_TYPES}.application_zip) end
put_content_type_image_gif do put_content_type ({HTTP_MIME_TYPES}.image_gif) end
put_content_type_image_png do put_content_type ({HTTP_MIME_TYPES}.image_png) end
put_content_type_image_jpg do put_content_type ({HTTP_MIME_TYPES}.image_jpg) end
put_content_type_image_svg_xml do put_content_type ({HTTP_MIME_TYPES}.image_svg_xml) end
put_content_type_message_http do put_content_type ({HTTP_MIME_TYPES}.message_http) end
put_content_type_multipart_mixed do put_content_type ({HTTP_MIME_TYPES}.multipart_mixed) end
put_content_type_multipart_alternative do put_content_type ({HTTP_MIME_TYPES}.multipart_alternative) end
put_content_type_multipart_related do put_content_type ({HTTP_MIME_TYPES}.multipart_related) end
put_content_type_multipart_form_data do put_content_type ({HTTP_MIME_TYPES}.multipart_form_data) end
put_content_type_multipart_signed do put_content_type ({HTTP_MIME_TYPES}.multipart_signed) end
put_content_type_multipart_encrypted do put_content_type ({HTTP_MIME_TYPES}.multipart_encrypted) end
feature -- Date
put_date (s: READABLE_STRING_8)
-- Put "Date: " header
do
put_header_key_value ({HTTP_HEADER_NAMES}.header_date, s)
end
put_current_date
-- Put current date time with "Date" header
do
put_utc_date (create {DATE_TIME}.make_now_utc)
end
put_utc_date (dt: DATE_TIME)
-- Put UTC date time `dt' with "Date" header
do
put_date (dt.formatted_out ("ddd,[0]dd mmm yyyy [0]hh:[0]mi:[0]ss.ff2") + " GMT")
end
feature -- Others
put_expires (n: INTEGER)
do
put_header_key_value ("Expires", n.out)
end
put_cache_control (s: READABLE_STRING_8)
-- `s' could be for instance "no-cache, must-revalidate"
do
put_header_key_value ("Cache-Control", s)
end
put_pragma (s: READABLE_STRING_8)
do
put_header_key_value ("Pragma", s)
end
put_pragma_no_cache
do
put_pragma ("no-cache")
end
feature -- Redirection
put_location (a_location: READABLE_STRING_8)
-- Tell the client the new location `a_location'
require
a_location_valid: not a_location.is_empty
do
put_header_key_value ({HTTP_HEADER_NAMES}.header_location, a_location)
end
put_refresh (a_location: READABLE_STRING_8; a_timeout_in_seconds: INTEGER)
-- Tell the client to refresh page with `a_location' after `a_timeout_in_seconds' in seconds
require
a_location_valid: not a_location.is_empty
do
put_header_key_value ({HTTP_HEADER_NAMES}.header_refresh, a_timeout_in_seconds.out + "; url=" + a_location)
end
feature -- Cookie
put_cookie (key, value: READABLE_STRING_8; expiration, path, domain, secure: detachable READABLE_STRING_8)
-- Set a cookie on the client's machine
-- with key 'key' and value 'value'.
require
make_sense: (key /= Void and value /= Void) and then (not key.is_empty and not value.is_empty)
local
s: STRING
do
s := {HTTP_HEADER_NAMES}.header_set_cookie + colon_space + key + "=" + value
if expiration /= Void then
s.append ("; expires=" + expiration)
end
if path /= Void then
s.append ("; path=" + path)
end
if domain /= Void then
s.append ("; domain=" + domain)
end
if secure /= Void then
s.append ("; secure=" + secure)
end
add_header (s)
end
feature -- Status report
has_header_named (a_name: READABLE_STRING_8): BOOLEAN
-- Has header item for `n'?
local
c: like headers.new_cursor
n: INTEGER
l_line: READABLE_STRING_8
do
from
n := a_name.count
c := headers.new_cursor
until
c.after or Result
loop
l_line := c.item
if l_line.starts_with (a_name) then
if l_line.valid_index (n + 1) then
Result := l_line [n + 1] = ':'
end
end
c.forth
end
end
has_content_length: BOOLEAN
-- Has header "content_length"
do
Result := has_header_named ({HTTP_HEADER_NAMES}.header_content_length)
end
feature {NONE} -- Implementation: Header
force_header_by_name (n: detachable READABLE_STRING_8; h: READABLE_STRING_8)
-- Add header `h' or replace existing header of same header name `n'
require
h_has_name_n: (n /= Void and attached header_name (h) as hn) implies n.same_string (hn)
local
l_headers: like headers
do
if n /= Void then
from
l_headers := headers
l_headers.start
until
l_headers.after or l_headers.item.starts_with (n)
loop
l_headers.forth
end
if not l_headers.after then
l_headers.replace (h)
else
add_header (h)
end
else
add_header (h)
end
end
header_name (h: READABLE_STRING_8): detachable READABLE_STRING_8
-- If any, header's name with colon
--| ex: for "Foo-bar: something", this will return "Foo-bar:"
local
s: detachable STRING_8
i,n: INTEGER
c: CHARACTER
do
from
i := 1
n := h.count
create s.make (10)
until
i > n or c = ':' or s = Void
loop
c := h[i]
inspect c
when ':' then
s.extend (c)
when '-', 'a' .. 'z', 'A' .. 'Z' then
s.extend (c)
else
s := Void
end
i := i + 1
end
Result := s
end
feature {NONE} -- Implementation
append_line_to (s: READABLE_STRING_8; h: like string)
do
h.append_string (s)
append_end_of_line_to (h)
end
append_end_of_line_to (h: like string)
do
h.append_character ('%R')
h.append_character ('%N')
end
feature {NONE} -- Constants
colon_space: STRING = ": "
semi_colon_space: STRING = "; "
note note
copyright: "2011-2011, Eiffel Software and others" copyright: "2011-2011, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"

View File

@@ -1393,7 +1393,7 @@ feature {NONE} -- Implementation
report_bad_request_error (a_message: detachable STRING) report_bad_request_error (a_message: detachable STRING)
-- Report error -- Report error
local local
e: EWF_ERROR e: WSF_ERROR
do do
create e.make ({HTTP_STATUS_CODE}.bad_request) create e.make ({HTTP_STATUS_CODE}.bad_request)
if a_message /= Void then if a_message /= Void then

View File

@@ -17,6 +17,11 @@ inherit
on_clean on_clean
end end
WSF_APPLICATION
undefine
default_create
end
feature {NONE} -- Events feature {NONE} -- Events
web_app: detachable NINO_APPLICATION web_app: detachable NINO_APPLICATION
@@ -33,7 +38,7 @@ feature {NONE} -- Events
do do
port_number := 8087 port_number := 8087
base_url := "test/" base_url := "test/"
create app.make_custom (agent execute, base_url) create app.make_custom (agent wgi_execute, base_url)
web_app := app web_app := app
create wt.make (agent app.listen (port_number)) create wt.make (agent app.listen (port_number))
@@ -43,7 +48,7 @@ feature {NONE} -- Events
e.sleep (1_000_000_000 * 5) e.sleep (1_000_000_000 * 5)
end end
execute (req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER) execute (req: WSF_REQUEST; res: WSF_RESPONSE)
local local
q: detachable STRING_32 q: detachable STRING_32
do do

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ISO-8859-1"?> <?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"> <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="CA72F5B3-E608-4FA5-8F05-A812441DB961">
<target name="tests"> <target name="tests">
<root class="ANY" feature="default_create"/> <root class="ANY" feature="default_create"/>
<file_rule> <file_rule>
@@ -11,11 +11,11 @@
</option> </option>
<setting name="concurrency" value="thread"/> <setting name="concurrency" value="thread"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/> <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="connector_nino" location="..\..\ewsgi\connectors\nino\nino-safe.ecf" readonly="false"/>
<library name="ewsgi" location="..\ewsgi-safe.ecf" readonly="false"/> <library name="wsf" location="..\wsf-safe.ecf" readonly="false"/>
<library name="http_client" location="..\..\..\client\http_client\http_client-safe.ecf"/> <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="testing" location="$ISE_LIBRARY\library\testing\testing-safe.ecf"/>
<library name="thread" location="$ISE_LIBRARY\library\thread\thread-safe.ecf"/> <library name="thread" location="$ISE_LIBRARY\library\thread\thread-safe.ecf"/>
<tests name="src" location=".\" recursive="true"/> <tests name="src" location=".\" recursive="false"/>
</target> </target>
</system> </system>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ISO-8859-1"?> <?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"> <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="CA72F5B3-E608-4FA5-8F05-A812441DB961">
<target name="tests"> <target name="tests">
<root class="ANY" feature="default_create"/> <root class="ANY" feature="default_create"/>
<file_rule> <file_rule>
@@ -11,8 +11,8 @@
</option> </option>
<setting name="concurrency" value="none"/> <setting name="concurrency" value="none"/>
<library name="base" location="$ISE_LIBRARY/library/base/base.ecf"/> <library name="base" location="$ISE_LIBRARY/library/base/base.ecf"/>
<library name="ewsgi_nino" location="..\default\ewsgi_nino.ecf"/> <library name="dft_nino" location="..\default\nino.ecf"/>
<library name="ewsgi" location="..\ewsgi.ecf"/> <library name="wsf" location="..\wsf.ecf"/>
<library name="http_client" location="..\..\..\client\http_client\http_client.ecf"/> <library name="http_client" location="..\..\..\client\http_client\http_client.ecf"/>
<library name="testing" location="$ISE_LIBRARY/library/testing/testing.ecf"/> <library name="testing" location="$ISE_LIBRARY/library/testing/testing.ecf"/>
<library name="thread" location="$ISE_LIBRARY\library\thread\thread-safe.ecf"/> <library name="thread" location="$ISE_LIBRARY\library\thread\thread-safe.ecf"/>

View File

@@ -14,7 +14,7 @@
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/> <library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
<library name="error" location="..\..\error\error-safe.ecf"/> <library name="error" location="..\..\error\error-safe.ecf"/>
<library name="http" location="..\..\protocol\http\http-safe.ecf"/> <library name="http" location="..\..\protocol\http\http-safe.ecf"/>
<library name="encoder" location="..\..\text\encoder\encoder-safe.ecf" readonly="false"/> <library name="encoder" location="..\..\text\encoder\encoder-safe.ecf"/>
<cluster name="src" location=".\" recursive="true"/> <cluster name="src" location=".\src" recursive="true"/>
</target> </target>
</system> </system>

View File

@@ -9,8 +9,12 @@
</file_rule> </file_rule>
<option warning="true" full_class_checking="true" void_safety="none" syntax="standard"> <option warning="true" full_class_checking="true" void_safety="none" syntax="standard">
</option> </option>
<library name="ewsgi" location="..\ewsgi\ewsgi.ecf"/>
<library name="base" location="$ISE_LIBRARY/library/base/base.ecf"/> <library name="base" location="$ISE_LIBRARY/library/base/base.ecf"/>
<cluster name="src" location="." recursive="true"/> <library name="ewsgi" location="..\ewsgi\ewsgi.ecf"/>
<library name="time" location="$ISE_LIBRARY\library\time\time.ecf"/>
<library name="error" location="..\..\error\error.ecf"/>
<library name="http" location="..\..\protocol\http\http.ecf"/>
<library name="encoder" location="..\..\text\encoder\encoder.ecf"/>
<cluster name="src" location=".\src" recursive="true"/>
</target> </target>
</system> </system>