A few tests with passive region, and expanded objects.

This commit is contained in:
2016-06-14 14:43:26 +02:00
parent e53c960a89
commit 7a182fa02f
17 changed files with 220 additions and 81 deletions

View File

@@ -24,7 +24,7 @@ feature {NONE} -- Initialization
n: INTEGER
p: like pool
do
n := max_concurrent_connections (server)
n := max_concurrent_connections (server).max (1) -- At least one processor!
create p.make (n)
initialize_pool (p, n)
pool := p

View File

@@ -23,7 +23,7 @@ feature {NONE} -- Initialization
local
n: INTEGER
do
n := max_concurrent_connections (server)
n := max_concurrent_connections (server).max (1) -- At least one thread!
create pool.make (n.to_natural_32)
end

View File

@@ -15,12 +15,21 @@ feature {NONE} -- Initialization
max_tcp_clients := 100
socket_accept_timeout := 1_000
socket_connect_timeout := 5_000
keep_alive_timeout := 5
is_secure := False
create ca_crt.make_empty
create ca_key.make_empty
connection_settings.keep_alive_timeout := default_keep_alive_timeout
end
feature -- Default values
default_server_port: INTEGER = 80
default_max_concurrent_connections: INTEGER = 100
default_keep_alive_timeout: INTEGER = 5 -- in seconds.
feature -- Access
Server_details: STRING_8
@@ -45,6 +54,11 @@ feature -- Access
keep_alive_timeout: INTEGER assign set_keep_alive_timeout
-- Persistent connection timeout
-- Timeout unit in Seconds.
do
Result := connection_settings.keep_alive_timeout
end
connection_settings: HTTPD_CONNECTION_SETTINGS
has_ssl_support: BOOLEAN
-- Has SSL support?
@@ -126,6 +140,10 @@ feature -- Element change
end
set_force_single_threaded (v: like force_single_threaded)
-- Force server to handle incoming request in a single thread.
-- i.e set max_concurrent_connections to 0!
obsolete
"Use set_max_concurrent_connections (0) [June/2016]"
do
if v then
set_max_concurrent_connections (0)
@@ -139,6 +157,7 @@ feature -- Element change
-- Set `is_verbose' to `b'
do
is_verbose := b
connection_settings.is_verbose := b
ensure
is_verbose_set: is_verbose = b
end
@@ -146,7 +165,7 @@ feature -- Element change
set_keep_alive_timeout (a_seconds: like keep_alive_timeout)
-- Set `keep_alive_timeout' with `a_seconds'
do
keep_alive_timeout := a_seconds
connection_settings.keep_alive_timeout := a_seconds
ensure
keep_alive_timeout_set: keep_alive_timeout = a_seconds
end

View File

@@ -0,0 +1,34 @@
note
description: "[
Connection settings for the standalone HTTPd server.
]"
author: "$Author$"
date: "$Date$"
revision: "$Revision$"
expanded class
HTTPD_CONNECTION_SETTINGS
feature -- Access
is_verbose: BOOLEAN assign set_is_verbose
-- Is verbose?
keep_alive_timeout: INTEGER assign set_keep_alive_timeout
-- Keep-alive timeout, also known as persistent-connection timeout.
feature -- Change
set_is_verbose (b: BOOLEAN)
-- Set `is_verbose' to `b'.
do
is_verbose := True
end
set_keep_alive_timeout (a_timeout_in_seconds: INTEGER)
-- Set `keep_alive_timeout' to `a_timeout_in_seconds'.
do
keep_alive_timeout := a_timeout_in_seconds
end
end

View File

@@ -11,8 +11,9 @@ inherit
feature {NONE} -- Initialization
make
make (a_settings: HTTPD_CONNECTION_SETTINGS)
do
connection_settings := a_settings
reset
end
@@ -41,6 +42,10 @@ feature {NONE} -- Initialization
is_persistent_connection_requested := False
end
feature -- Access
connection_settings: HTTPD_CONNECTION_SETTINGS
feature -- Status report
is_connected: BOOLEAN
@@ -107,6 +112,9 @@ feature -- Access
feature -- Settings
is_verbose: BOOLEAN
do
Result := connection_settings.is_verbose
end
is_persistent_connection_supported: BOOLEAN
-- Is persistent connection supported?
@@ -114,24 +122,27 @@ feature -- Settings
Result := {HTTPD_SERVER}.is_persistent_connection_supported
end
persistent_connection_timeout: INTEGER = 5 -- seconds
persistent_connection_timeout: INTEGER -- seconds
-- Number of seconds for persistent connection timeout.
-- Default: 5 sec.
do
Result := connection_settings.keep_alive_timeout
end
feature -- Status report
has_error: BOOLEAN
-- Error occurred during `analyze_request_message'
feature -- Change
set_is_verbose (b: BOOLEAN)
-- Set `is_verbose' with `b'.
do
is_verbose := b
ensure
is_verbose_set: is_verbose = b
end
--feature -- Change
--
-- set_is_verbose (b: BOOLEAN)
-- -- Set `is_verbose' with `b'.
-- do
-- connection_settings.is_verbose := b
-- ensure
-- is_verbose_set: is_verbose = b
-- end
feature -- Execution
@@ -210,17 +221,8 @@ feature -- Execution
--| TODO: add configuration options for socket timeout.
--| set by default 5 seconds.
-- l_socket.set_timeout (persistent_connection_timeout) -- 5 seconds!
l_socket.set_timeout (1) -- 1 second!
from
i := persistent_connection_timeout -- * 1 sec
until
l_is_ready or i <= 0 or has_error
loop
l_is_ready := l_socket.ready_for_reading
check not l_socket.is_closed end
i := i - 1
end
l_socket.set_timeout (persistent_connection_timeout) -- 5 seconds!
l_is_ready := l_socket.ready_for_reading
if l_is_ready then
create l_remote_info
@@ -231,6 +233,9 @@ feature -- Execution
remote_info := l_remote_info
end
analyze_request_message (l_socket)
if is_verbose then
log (request_header)
end
else
has_error := True
debug ("dbglog")

View File

@@ -37,7 +37,7 @@ feature {NONE} -- Initialization
build_controller
-- Build `controller'.
do
create controller
create <NONE> controller
end
initialize

View File

@@ -19,18 +19,14 @@ inherit
SHARED_HTML_ENCODER
create
make,
make_with_connector
feature {NONE} -- Initialization
make_with_connector (conn: like connector)
make_with_connector (a_connection_settings: HTTPD_CONNECTION_SETTINGS; conn: like connector)
do
make
make (a_connection_settings)
connector := conn
-- if conn /= Void then
-- set_is_verbose (is_connector_verbose (conn))
-- end
end
feature -- Access
@@ -56,10 +52,10 @@ feature -- SCOOP helpers
Result := conn.base
end
is_connector_verbose (conn: separate WGI_STANDALONE_CONNECTOR [G]): BOOLEAN
do
Result := conn.is_verbose
end
-- is_connector_verbose (conn: separate WGI_STANDALONE_CONNECTOR [G]): BOOLEAN
-- do
-- Result := conn.is_verbose
-- end
feature -- Request processing

View File

@@ -1,5 +1,5 @@
note
description: "Implementation of WGI request handler factory for WGI_STANDALOE_CONNECTOR."
description: "Implementation of WGI request handler factory for WGI_STANDALONE_CONNECTOR."
date: "$Date$"
revision: "$Revision$"
@@ -14,11 +14,15 @@ feature -- Access
connector: detachable separate WGI_STANDALONE_CONNECTOR [G]
-- httpd solution.
connection_settings: HTTPD_CONNECTION_SETTINGS
-- Connection settings related to httpd solution.
feature -- Element change
set_connector (conn: like connector)
set_connector (a_settings: HTTPD_CONNECTION_SETTINGS; conn: like connector)
-- Set `connector' with `conn'.
do
connection_settings := a_settings
connector := conn
end
@@ -26,7 +30,7 @@ feature -- Factory
new_handler: separate WGI_HTTPD_REQUEST_HANDLER [G]
do
create Result.make_with_connector (connector)
create Result.make_with_connector (connection_settings, connector)
end
note

View File

@@ -26,13 +26,18 @@ feature {NONE} -- Initialization
create on_launched_actions
-- Server
create fac
-- create fac
create <NONE> fac
request_handler_factory := fac
create server.make (fac)
create observer
-- create <NONE> server.make (fac)
-- create observer
create <NONE> observer
configuration := server_configuration (server)
controller := server_controller (server)
set_factory_connector (Current, fac)
initialize_server (server)
set_factory_connector (configuration, Current, fac)
end
make_with_base (a_base: like base)
@@ -51,9 +56,9 @@ feature {NONE} -- Separate helper
a_server.set_observer (observer)
end
set_factory_connector (conn: detachable separate WGI_STANDALONE_CONNECTOR [G]; fac: separate WGI_HTTPD_REQUEST_HANDLER_FACTORY [G])
set_factory_connector (a_conf: like configuration; conn: detachable separate WGI_STANDALONE_CONNECTOR [G]; fac: separate WGI_HTTPD_REQUEST_HANDLER_FACTORY [G])
do
fac.set_connector (conn)
fac.set_connector (a_conf.connection_settings, conn)
end
server_configuration (a_server: like server): like configuration
@@ -61,6 +66,9 @@ feature {NONE} -- Separate helper
Result := a_server.configuration
end
request_handler_factory: separate WGI_HTTPD_REQUEST_HANDLER_FACTORY [G]
-- REQUEST Handler factory.
feature -- Access
name: STRING_8 = "httpd"
@@ -117,6 +125,11 @@ feature -- Event
feature -- Element change
update_configuration (cfg: separate HTTPD_CONFIGURATION)
do
set_factory_connector (cfg, Current, request_handler_factory)
end
set_base (v: like base)
-- Set base url `base' to `v'.
require

View File

@@ -24,7 +24,7 @@ feature {NONE} -- Initialization
set_source (a_source)
end
feature {WGI_STANDALONE_CONNECTOR, WGI_SERVICE} -- Nino
feature {WGI_STANDALONE_CONNECTOR, WGI_SERVICE} -- Standalone connector.
set_source (i: like source)
do