Compare commits

...

8 Commits

18 changed files with 143 additions and 112 deletions

View File

@@ -17,10 +17,21 @@ create
make_server_by_port
create {NETWORK_STREAM_SOCKET}
make_from_descriptor_and_address
make_from_descriptor_and_address,
make_empty
feature {NONE} -- Initialization
make_server_by_address_and_port (a_address: INET_ADDRESS; a_port: INTEGER)
-- Create server socket on `a_address' and `a_port'.
require
valid_port: a_port >= 0
do
make
create address.make_from_address_and_port (a_address, a_port)
bind
end
make
-- Create a network stream socket.
do
@@ -28,16 +39,6 @@ feature {NONE} -- Initialization
set_reuse_address
end
make_server_by_address_and_port (an_address: INET_ADDRESS; a_port: INTEGER)
-- Create server socket on `an_address' and `a_port'.
require
valid_port: a_port >= 0
do
make
create address.make_from_address_and_port (an_address, a_port)
bind
end
feature -- Basic operation
send_message (a_msg: STRING)

View File

@@ -29,16 +29,6 @@ feature {NONE} -- Initialization
set_reuse_address
end
make_server_by_address_and_port (an_address: INET_ADDRESS; a_port: INTEGER)
-- Create server socket on `an_address' and `a_port'.
require
valid_port: a_port >= 0
do
make
create address.make_from_address_and_port (an_address, a_port)
bind
end
feature -- Basic operation
send_message (a_msg: STRING)

View File

@@ -22,13 +22,13 @@
<file_rule>
<exclude>tcp_stream_socket.e</exclude>
<condition>
<version type="compiler" max="15.01.9.6506"/>
<version type="compiler" max="16.11"/>
</condition>
</file_rule>
</cluster>
<cluster name="spec_before_15_01" location=".\library\spec\before_15_01\" recursive="true">
<cluster name="spec_until_16_05" location=".\library\spec\until_16_05\" recursive="true">
<condition>
<version type="compiler" max="15.01.9.6506"/>
<version type="compiler" max="16.11"/>
</condition>
</cluster>
</target>

View File

@@ -1,35 +1,35 @@
<?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="nino" uuid="32C1D67D-33DE-4F1E-864B-D45388F2E3E6" library_target="nino">
<target name="nino">
<root all_classes="true"/>
<file_rule>
<exclude>/.git$</exclude>
<exclude>/EIFGENs$</exclude>
<exclude>/CVS$</exclude>
<exclude>/.svn$</exclude>
</file_rule>
<option warning="true" void_safety="none">
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
</option>
<setting name="concurrency" value="thread"/>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="net" location="$ISE_LIBRARY\library\net\net.ecf"/>
<library name="thread" location="$ISE_LIBRARY\library\thread\thread.ecf"/>
<cluster name="nino" location=".\library\" recursive="true">
<file_rule>
<exclude>spec</exclude>
</file_rule>
<file_rule>
<exclude>tcp_stream_socket.e</exclude>
<condition>
<version type="compiler" max="15.01.9.6506"/>
</condition>
</file_rule>
</cluster>
<cluster name="spec_before_15_01" location=".\library\spec\before_15_01\" recursive="true">
<condition>
<version type="compiler" max="15.01.9.6506"/>
</condition>
</cluster>
</target>
</system>
<?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="nino" uuid="32C1D67D-33DE-4F1E-864B-D45388F2E3E6" library_target="nino">
<target name="nino">
<root all_classes="true"/>
<file_rule>
<exclude>/.git$</exclude>
<exclude>/EIFGENs$</exclude>
<exclude>/CVS$</exclude>
<exclude>/.svn$</exclude>
</file_rule>
<option warning="true" void_safety="none">
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
</option>
<setting name="concurrency" value="thread"/>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="net" location="$ISE_LIBRARY\library\net\net.ecf"/>
<library name="thread" location="$ISE_LIBRARY\library\thread\thread.ecf"/>
<cluster name="nino" location=".\library\" recursive="true">
<file_rule>
<exclude>spec</exclude>
</file_rule>
<file_rule>
<exclude>tcp_stream_socket.e</exclude>
<condition>
<version type="compiler" max="16.11"/>
</condition>
</file_rule>
</cluster>
<cluster name="spec_until_16_05" location=".\library\spec\until_16_05\" recursive="true">
<condition>
<version type="compiler" max="16.11"/>
</condition>
</cluster>
</target>
</system>

View File

@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-13-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-13-0 http://www.eiffel.com/developers/xml/configuration-1-13-0.xsd" name="desktop_app" uuid="E015841A-D456-46E1-8A18-E0CEB9E69CD5">
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-15-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-15-0 http://www.eiffel.com/developers/xml/configuration-1-15-0.xsd" name="desktop_app" uuid="E015841A-D456-46E1-8A18-E0CEB9E69CD5">
<description>Vision2+web browser widget+embedded web service</description>
<target name="desktop_app">
<description>This example demonstrates how to build a vision2 desktop application that embed a web browser accessing the service of an embedded web service.</description>
<root class="DESKTOP_APP" feature="make_and_launch"/>
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="transitional" syntax="transitional">
<option warning="true" full_class_checking="true" is_attached_by_default="true" is_obsolete_routine_type="true" void_safety="all" syntax="transitional">
<assertions precondition="true" postcondition="true" check="true"/>
</option>
<setting name="concurrency" value="thread"/>
<setting name="concurrency" value="scoop"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="ewsgi" location="..\..\library\server\ewsgi\ewsgi-safe.ecf"/>
<library name="thread" location="$ISE_LIBRARY\library\thread\thread-safe.ecf"/>
@@ -18,9 +18,9 @@
<library name="wsf_standalone_connector" location="..\..\library\server\ewsgi\connectors\standalone\standalone-safe.ecf"/>
<cluster name="src" location=".\src\" recursive="true">
<file_rule>
<exclude>/EIFGENs$</exclude>
<exclude>/CVS$</exclude>
<exclude>/.svn$</exclude>
<exclude>/CVS$</exclude>
<exclude>/EIFGENs$</exclude>
</file_rule>
</cluster>
</target>

View File

@@ -24,20 +24,25 @@ feature {NONE} -- Initialization
-- then launch the application.
local
l_win: like main_window
l_embedded_service: APP_EMBEDDED_WEB_SERVICE
l_embedded_service: separate APP_EMBEDDED_WEB_SERVICE
do
default_create
create l_win.make
main_window := l_win
l_win.show
create l_embedded_service.make
l_embedded_service.set_port_number (0) -- Use first available port number
l_embedded_service.on_launched_actions.force (agent on_web_service_launched (l_win, l_embedded_service))
l_embedded_service.launch
setup_and_launch_web_service (l_embedded_service)
launch
end
setup_and_launch_web_service (a_web_service: separate APP_EMBEDDED_WEB_SERVICE)
do
a_web_service.set_port_number (0) -- Use first available port number
a_web_service.set_on_launched_action (agent on_web_service_launched (a_web_service))
a_web_service.launch
end
on_quit
do
if attached main_window as win then
@@ -45,13 +50,15 @@ feature {NONE} -- Initialization
end
end
on_web_service_launched (a_win: attached like main_window; s: APP_EMBEDDED_WEB_SERVICE)
on_web_service_launched (a_web_service: separate APP_EMBEDDED_WEB_SERVICE)
do
add_idle_action_kamikaze (agent wait_for_termination (s, Void))
add_idle_action_kamikaze (agent a_win.open_link)
if attached main_window as win then
add_idle_action_kamikaze (agent wait_for_termination (a_web_service, Void))
add_idle_action_kamikaze (agent win.open_link)
end
end
wait_for_termination (s: APP_EMBEDDED_WEB_SERVICE; a_timeout: detachable EV_TIMEOUT)
wait_for_termination (a_web_service: separate APP_EMBEDDED_WEB_SERVICE; a_timeout: detachable EV_TIMEOUT)
local
t: detachable EV_TIMEOUT
do
@@ -60,7 +67,7 @@ feature {NONE} -- Initialization
t.set_interval (0)
end
if
attached s.observer as obs and then
attached a_web_service.observer as obs and then
observer_has_terminaded (obs)
then
if t /= Void then
@@ -70,7 +77,7 @@ feature {NONE} -- Initialization
else
if t = Void then
create t
t.actions.extend (agent wait_for_termination (s, t))
t.actions.extend (agent wait_for_termination (a_web_service, t))
else
t.set_interval (1_000)
end

View File

@@ -17,19 +17,21 @@ inherit
feature {NONE} -- Execution
execute_embedded
execute_embedded
-- Execute the request
-- See `request.input' for input stream
-- `request.meta_variables' for the CGI meta variable
-- and `response' for output buffer
local
filter: WSF_AGENT_FILTER
m: WSF_PAGE_RESPONSE
do
if local_connection_restriction_enabled then
if
attached request.remote_addr as l_remote_addr and then
l_remote_addr.is_case_insensitive_equal_general ("127.0.0.1")
(
l_remote_addr.is_case_insensitive_equal_general ("127.0.0.1")
or else l_remote_addr.is_case_insensitive_equal_general ("localhost")
)
then
execute
else
@@ -41,7 +43,7 @@ feature {NONE} -- Execution
execute
end
end
execute
deferred
end

View File

@@ -16,7 +16,6 @@ feature -- Initialization
make
do
create on_launched_actions
end
feature -- Execution
@@ -27,7 +26,6 @@ feature -- Execution
opts: WSF_SERVICE_LAUNCHER_OPTIONS
do
create opts.default_create
opts.set_verbose (True)
opts.set_option ("port", port_number)
create launcher.make (opts)
observer := launcher.connector.observer
@@ -40,11 +38,23 @@ feature -- Execution
on_launched (conn: WGI_STANDALONE_CONNECTOR [G])
do
set_port_number (conn.port)
on_launched_actions.call (Void)
if attached on_launched_action as act then
call_action (act)
end
end
call_action (act: attached like on_launched_action)
do
act.call (Void)
end
feature -- Access
on_launched_actions: ACTION_SEQUENCE [TUPLE]
on_launched_action: detachable separate PROCEDURE [ANY, TUPLE]
set_on_launched_action (act: like on_launched_action)
do
on_launched_action := act
end
end

View File

@@ -20,10 +20,13 @@
</target>
<target name="upload_image_standalone" extends="upload_image_common">
<root class="IMAGE_UPLOADER" feature="make"/>
<setting name="concurrency" value="thread"/>
<setting name="concurrency" value="scoop"/>
<library name="default_standalone" location="..\..\library\server\wsf\default\standalone-safe.ecf" readonly="false" use_application_options="true"/>
<cluster name="src" location="src\" recursive="true"/>
</target>
<target name="upload_image_standalone_st" extends="upload_image_standalone">
<setting name="concurrency" value="none"/>
</target>
<target name="upload_image_libfcgi" extends="upload_image_common">
<root class="IMAGE_UPLOADER" feature="make"/>
<setting name="concurrency" value="none"/>

View File

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-16-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-16-0 http://www.eiffel.com/developers/xml/configuration-1-16-0.xsd" name="demo" uuid="DC4D6549-D5F4-4E1A-959A-6BD536737A21" library_target="demo">
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-15-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-15-0 http://www.eiffel.com/developers/xml/configuration-1-15-0.xsd" name="demo" uuid="DC4D6549-D5F4-4E1A-959A-6BD536737A21" library_target="demo">
<target name="demo">
<root class="APPLICATION" feature="make_and_launch"/>
<file_rule>
@@ -7,9 +7,10 @@
<exclude>/CVS$</exclude>
<exclude>/EIFGENs$</exclude>
</file_rule>
<option concurrency="scoop" root_catcall_detection="none" root_concurrency="scoop" root_void_safety="all" warning="true" full_class_checking="false" is_attached_by_default="true" is_obsolete_routine_type="true" void_safety="all" syntax="transitional">
<option warning="true" full_class_checking="false" is_attached_by_default="true" is_obsolete_routine_type="true" void_safety="all" syntax="transitional">
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
</option>
<setting name="concurrency" value="scoop"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="ewsgi" location="..\..\..\..\server\ewsgi\ewsgi-safe.ecf" readonly="false"/>
<library name="ewsgi_standalone_connector" location="..\..\..\..\server\ewsgi\connectors\standalone\standalone-safe.ecf" readonly="false"/>
@@ -20,6 +21,6 @@
<cluster name="src" location=".\" recursive="true"/>
</target>
<target name="demo_mt" extends="demo">
<option concurrency="thread" />
<setting name="concurrency" value="thread"/>
</target>
</system>

View File

@@ -31,7 +31,7 @@ feature {NONE} -- Initialization
reset
do
reset_request
reset_request (False)
reset_error
if attached internal_client_socket as l_sock then
@@ -40,10 +40,18 @@ feature {NONE} -- Initialization
internal_client_socket := Void
end
reset_request
reset_request (a_is_reusing_connection: BOOLEAN)
-- Reset the request, and `a_is_reusing_connection' says if the peristent connection is
-- still alive.
do
if a_is_reusing_connection then
-- Keep `remote_info' as it stays the same for the successive
-- persistent connections.
else
remote_info := Void
end
version := Void
remote_info := Void
-- FIXME: optimize to just wipe_out if needed
create method.make_empty
@@ -247,7 +255,7 @@ feature -- Execution
or not is_next_persistent_connection_supported -- related to `max_keep_alive_requests'
or not is_persistent_connection_requested
or has_error or l_socket.is_closed or not l_socket.is_open_read
reset_request
reset_request (not l_exit)
end
if l_exit and has_error and not l_socket.is_closed then
l_socket.close
@@ -261,6 +269,7 @@ feature -- Execution
is_connected: is_connected
reuse_connection_when_possible: a_is_reusing_connection implies is_persistent_connection_supported
no_error: not has_error
remote_info_set: remote_info /= Void
local
l_socket: like client_socket
do
@@ -511,12 +520,12 @@ feature -- Parsing
elseif a_socket.readable then
a_socket.read_line_noexception
Result := a_socket.last_string
-- Do no check `socket_ok' before socket operation,
-- Do no check `was_error' before socket operation,
-- otherwise it may be False, due to error during other socket operation in same thread.
if not a_socket.socket_ok then
if a_socket.was_error then
report_error ("Socket error")
if is_verbose then
log (request_header +"%N" + Result + "%N## socket_ok=False! ##", debug_level)
log (request_header +"%N" + Result + "%N## was_error=False! ##", debug_level)
end
end
else

View File

@@ -40,9 +40,9 @@ extern int setsockopt(int, int, int, char*, int);
extern int recv(int, char *, int, int);
extern int send(int, char *, int, int);
#else
extern int setsockopt(int, int, int, (struct timeval*), int);
extern int recv(int, char *, int, int);
extern int send(int, char *, int, int);
extern int setsockopt(int, int, int, const void*, socklen_t);
extern ssize_t recv(int, void *, size_t, int);
extern ssize_t send(int, const void *, size_t, int);
#endif
#ifdef __cplusplus

View File

@@ -38,7 +38,7 @@ feature {NONE} -- Initialization
make_with_base (a_base: detachable separate READABLE_STRING_8)
-- Create current standalone connector with base url `a_base'
require
a_base_starts_with_slash: a_base /= Void implies is_valid_base (a_base)
a_base_starts_with_slash: (a_base /= Void and then not a_base.is_empty) implies is_valid_base (a_base)
do
make
set_base (a_base)
@@ -181,6 +181,13 @@ feature -- Element change
feature -- Server
launch_on_port (a_port_number: INTEGER)
-- Launch server listening on port `a_port_number'.
do
set_port_number (a_port_number)
launch
end
launch
-- Launch web server listening.
do

View File

@@ -42,8 +42,8 @@ feature -- Input
src: like source
do
src := source
if src.readable then
src.read_character
if src.readable and not src.was_error then
src.read_character_noexception
last_character := src.last_character
else
last_character := '%U'
@@ -56,8 +56,8 @@ feature -- Input
do
src := source
last_string.wipe_out
if src.readable then
src.read_stream_thread_aware (nb)
if src.readable and not src.was_error then
src.read_stream_noexception (nb)
last_string.append_string (src.last_string)
end
end
@@ -85,11 +85,11 @@ feature -- Status report
end_of_input: BOOLEAN
-- Has the end of input stream been reached?
do
Result := not source.readable
Result := not source.readable or source.was_error
end
;note
copyright: "2011-2015, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
copyright: "2011-2016, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -90,7 +90,7 @@ feature -- Output
put_character (c: CHARACTER_8)
do
last_target_call_succeed := False
target.put_character (c)
target.put_character_noexception (c)
last_target_call_succeed := not target.was_error
end

View File

@@ -15,13 +15,13 @@ feature {NONE} -- Initialization
make
do
print ("Example: start a Standalone web server on port " + port_number.out + ", %Nand reply Hello World for any request such as http://localhost:8123/%N")
(create {STANDALONE_SERVICE [HELLO_WORLD_EXECUTION]}.make_custom ("")).listen (port_number)
(create {WGI_STANDALONE_CONNECTOR [HELLO_WORLD_EXECUTION]}.make_with_base ("")).launch_on_port (port_number)
end
port_number: INTEGER = 8123
note
copyright: "2011-2015, Eiffel Software and others"
copyright: "2011-2016, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -18,12 +18,12 @@ feature {NONE} -- Initialization
execute
do
response.set_status_code (200, Void)
response.put_header_text ("Content-Type: text/plain%R%N")
response.put_header_text ("Content-Length: 13%R%NContent-Type: text/plain%R%N")
response.put_string ("Hello World!%N")
end
note
copyright: "2011-2015, Eiffel Software and others"
copyright: "2011-2016, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -11,15 +11,16 @@
</option>
<setting name="concurrency" value="thread"/>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="connector_nino" location="..\..\ewsgi\connectors\nino\nino.ecf" readonly="false"/>
<library name="connector_null" location="..\..\ewsgi\connectors\null\null.ecf" readonly="false"/>
<library name="dft_nino" location="..\default\nino.ecf"/>
<library name="connector_standalone" location="..\..\ewsgi\connectors\standalone\standalone.ecf" readonly="false"/>
<library name="dft_standalone" location="..\default\standalone.ecf"/>
<library name="ewsgi" location="..\..\ewsgi\ewsgi.ecf" readonly="false"/>
<library name="http" location="..\..\..\network\protocol\http\http.ecf" readonly="false"/>
<library name="http_client" location="..\..\..\network\http_client\http_client.ecf" readonly="false"/>
<library name="http_client" location="..\..\..\network\http_client\net_http_client.ecf" readonly="false"/>
<library name="thread" location="$ISE_LIBRARY\library\thread\thread.ecf"/>
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
<library name="wsf" location="..\wsf.ecf" readonly="false"/>
<library name="wsf_standalone" location="..\..\wsf\connector\standalone.ecf" readonly="false"/>
<cluster name="server" location=".\server\" recursive="true"/>
</target>
<target name="wsf_tests" extends="server">