Merged DbC and cosmetic related changes from remote-tracking branch 'javier/concurrent_httpd'.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
note
|
||||
description: "Summary description for {APPLICATION_EXECUTION}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
note
|
||||
description: "Summary description for {CONTACT_AUTOCOMPLETION}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
note
|
||||
description: "Summary description for {FLAG_AUTOCOMPLETION}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
note
|
||||
description: "Summary description for {GOOGLE_AUTOCOMPLETION}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
note
|
||||
description: "Summary description for {BASE_PAGE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
note
|
||||
description: "Summary description for {CODEVIEW_PAGE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
note
|
||||
description: "Summary description for {GOOGLE_NEWS}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
note
|
||||
description: "Summary description for {GOOGLE_NEWS_DATASOURCE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
note
|
||||
description: "Summary description for {GOOGLE_NEWS_REPEATER}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
note
|
||||
description: "Summary description for {GRID_PAGE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
note
|
||||
description: "Summary description for {OWN_VALIDATOR}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
note
|
||||
description: "Summary description for {INCREASING_PROGRESSSOURCE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
note
|
||||
description: "Summary description for {REPEATER_PAGE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
note
|
||||
description: "Summary description for {SAMPLE_PAGE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
note
|
||||
description: "Summary description for {SLIDER_PAGE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
note
|
||||
description: "Summary description for {UPLOAD_PAGE}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
|
||||
@@ -31,6 +31,7 @@ feature {NONE} -- Initialization
|
||||
end
|
||||
|
||||
initialize_pool (p: like pool; n: INTEGER)
|
||||
-- Initialize Concurrent pool of `n' potential separate connection handlers.
|
||||
do
|
||||
p.set_count (n)
|
||||
end
|
||||
@@ -49,6 +50,7 @@ feature -- Access
|
||||
feature {HTTPD_SERVER_I} -- Execution
|
||||
|
||||
shutdown
|
||||
-- <Precursor>
|
||||
do
|
||||
if not is_shutdown_requested then
|
||||
is_shutdown_requested := True
|
||||
@@ -57,11 +59,13 @@ feature {HTTPD_SERVER_I} -- Execution
|
||||
end
|
||||
|
||||
pool_gracefull_stop (p: like pool)
|
||||
-- Graceful stop concurrent pool of separate connection handlers.
|
||||
do
|
||||
p.gracefull_stop
|
||||
end
|
||||
|
||||
accept_incoming_connection (a_listening_socket: HTTPD_STREAM_SOCKET)
|
||||
-- <Precursor>
|
||||
do
|
||||
accept_connection_on_pool (pool, a_listening_socket) -- Wait on not pool.is_full or is_stop_requested
|
||||
end
|
||||
@@ -92,7 +96,7 @@ feature {HTTPD_SERVER_I} -- Execution
|
||||
end
|
||||
|
||||
process_handler (hdl: separate HTTPD_REQUEST_HANDLER)
|
||||
-- Process request handler `hdl' concurrently.
|
||||
-- Process request handler `hdl' as soon as `hdl' is connected to accepted socket.
|
||||
require
|
||||
hdl.is_connected
|
||||
do
|
||||
@@ -118,7 +122,7 @@ feature {HTTPD_SERVER_I} -- Status report
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
separate_client_socket (hdl: separate HTTPD_REQUEST_HANDLER): separate HTTPD_STREAM_SOCKET
|
||||
-- Client socket for handler `hdl'.
|
||||
-- Client socket for request handler `hdl'.
|
||||
do
|
||||
Result := hdl.client_socket
|
||||
end
|
||||
|
||||
@@ -57,11 +57,13 @@ feature -- Access: SSL
|
||||
-- Is SSL/TLS session?.
|
||||
|
||||
ca_crt: STRING
|
||||
-- the signed certificate.
|
||||
|
||||
ca_key: STRING
|
||||
-- private key to the certificate.
|
||||
|
||||
ssl_protocol: NATURAL
|
||||
-- By default protocol is tls 1.2.
|
||||
-- By default protocol is tls 1.2.
|
||||
|
||||
feature -- Element change
|
||||
|
||||
@@ -69,40 +71,58 @@ feature -- Element change
|
||||
do
|
||||
if v = Void then
|
||||
unset_http_server_name
|
||||
-- http_server_name := Void
|
||||
else
|
||||
create {IMMUTABLE_STRING_8} http_server_name.make_from_separate (v)
|
||||
end
|
||||
--| Missing postcondition.
|
||||
end
|
||||
|
||||
unset_http_server_name
|
||||
-- Unset `http_server_name' value.
|
||||
do
|
||||
http_server_name := Void
|
||||
ensure
|
||||
unset_http_server_name: http_server_name = Void.
|
||||
end
|
||||
|
||||
set_http_server_port (v: like http_server_port)
|
||||
-- Set `http_server_port' with `v'.
|
||||
do
|
||||
http_server_port := v
|
||||
ensure
|
||||
http_server_port_set: http_server_port = v
|
||||
end
|
||||
|
||||
set_max_tcp_clients (v: like max_tcp_clients)
|
||||
-- Set `max_tcp_clients' with `v'.
|
||||
do
|
||||
max_tcp_clients := v
|
||||
ensure
|
||||
max_tcp_clients_set: max_tcp_clients = v
|
||||
end
|
||||
|
||||
set_max_concurrent_connections (v: like max_concurrent_connections)
|
||||
-- Set `max_concurrent_connections' with `v'.
|
||||
do
|
||||
max_concurrent_connections := v
|
||||
ensure
|
||||
max_concurrent_connections_set : max_concurrent_connections = v
|
||||
end
|
||||
|
||||
set_socket_accept_timeout (v: like socket_accept_timeout)
|
||||
-- Set `socket_accept_timeout' with `v'
|
||||
do
|
||||
socket_accept_timeout := v
|
||||
ensure
|
||||
socket_accept_timeout_set: socket_accept_timeout = v
|
||||
end
|
||||
|
||||
set_socket_connect_timeout (v: like socket_connect_timeout)
|
||||
-- Set `socket_connect_timeout' with `v'
|
||||
do
|
||||
socket_connect_timeout := v
|
||||
ensure
|
||||
socket_connect_timeout_set: socket_connect_timeout = v
|
||||
end
|
||||
|
||||
set_force_single_threaded (v: like force_single_threaded)
|
||||
@@ -110,12 +130,17 @@ feature -- Element change
|
||||
if v then
|
||||
set_max_concurrent_connections (0)
|
||||
end
|
||||
--|Missing postcondition
|
||||
--| force_single_thread_set: v implies max_concurrent_connections = 0
|
||||
--| not_single_thread: not v implies max_concurrent_connections > 0
|
||||
end
|
||||
|
||||
set_is_verbose (b: BOOLEAN)
|
||||
-- Set `is_verbose' to `b'
|
||||
do
|
||||
is_verbose := b
|
||||
ensure
|
||||
is_verbose_set: is_verbose = b
|
||||
end
|
||||
|
||||
set_keep_alive_timeout (a_seconds: like keep_alive_timeout)
|
||||
@@ -137,6 +162,12 @@ feature -- Element change
|
||||
else
|
||||
is_secure := False
|
||||
end
|
||||
--| Missing postcondition
|
||||
ensure
|
||||
is_secure_set: has_ssl_support implies is_secure
|
||||
-- http_server_port_set: has_ssl_support implies http_server_port = 443
|
||||
is_not_secure: not has_ssl_support implies not is_secure
|
||||
-- default_port: not has_ssl_support implies http_server_port = 80
|
||||
end
|
||||
|
||||
feature -- Element change
|
||||
@@ -170,31 +201,43 @@ feature -- SSL Helpers
|
||||
set_ssl_protocol_to_ssl_2_or_3
|
||||
-- Set `ssl_protocol' with `Ssl_23'.
|
||||
deferred
|
||||
ensure
|
||||
ssl_protocol_set: ssl_protocol = {SSL_PROTOCOL}.Ssl_23
|
||||
end
|
||||
|
||||
set_ssl_protocol_to_ssl_3
|
||||
-- Set `ssl_protocol' with `Ssl_3'.
|
||||
deferred
|
||||
ensure
|
||||
ssl_protocol_set: ssl_protocol = {SSL_PROTOCOL}.Ssl_3
|
||||
end
|
||||
|
||||
set_ssl_protocol_to_tls_1_0
|
||||
-- Set `ssl_protocol' with `Tls_1_0'.
|
||||
deferred
|
||||
ensure
|
||||
ssl_protocol_set: ssl_protocol = {SSL_PROTOCOL}.Tls_1_0
|
||||
end
|
||||
|
||||
set_ssl_protocol_to_tls_1_1
|
||||
-- Set `ssl_protocol' with `Tls_1_1'.
|
||||
deferred
|
||||
ensure
|
||||
ssl_protocol_set: ssl_protocol = {SSL_PROTOCOL}.Tls_1_1
|
||||
end
|
||||
|
||||
set_ssl_protocol_to_tls_1_2
|
||||
-- Set `ssl_protocol' with `Tls_1_2'.
|
||||
deferred
|
||||
ensure
|
||||
ssl_protocol_set: ssl_protocol = {SSL_PROTOCOL}.Tls_1_2
|
||||
end
|
||||
|
||||
set_ssl_protocol_to_dtls_1_0
|
||||
-- Set `ssl_protocol' with `Dtls_1_0'.
|
||||
deferred
|
||||
ensure
|
||||
ssl_protocol_set: ssl_protocol = {SSL_PROTOCOL}.Dtls_1_0
|
||||
end
|
||||
|
||||
note
|
||||
|
||||
@@ -79,6 +79,7 @@ feature {NONE} -- Implementation
|
||||
end
|
||||
|
||||
separate_server_log (a_server: like server; a_message: separate READABLE_STRING_8)
|
||||
-- Concurrent call to `a_server.log (a_message)'.
|
||||
do
|
||||
a_server.log (a_message)
|
||||
end
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
note
|
||||
description: "Summary description for {HTTPD_REQUEST_HANDLER_I}."
|
||||
author: ""
|
||||
description: "HTTPD handler interface processing request."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
@@ -117,13 +116,17 @@ feature -- Status report
|
||||
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 -- Execution
|
||||
|
||||
safe_execute
|
||||
-- Execute accepted incoming connection as request.
|
||||
local
|
||||
retried: BOOLEAN
|
||||
do
|
||||
@@ -194,6 +197,8 @@ feature -- Execution
|
||||
dbglog (generator + ".execute_request socket=" + l_socket.descriptor.out + " ENTER")
|
||||
end
|
||||
l_socket.set_timeout (5) -- 5 seconds!
|
||||
--| TODO: add configuration options for socket timeout.
|
||||
--| set by default 5 seconds.
|
||||
l_ready_for_reading := l_socket.ready_for_reading
|
||||
if l_ready_for_reading then
|
||||
create l_remote_info
|
||||
@@ -214,7 +219,6 @@ feature -- Execution
|
||||
if has_error then
|
||||
-- check catch_bad_incoming_connection: False end
|
||||
if is_verbose then
|
||||
-- check invalid_incoming_request: False end
|
||||
log ("ERROR: invalid HTTP incoming request")
|
||||
end
|
||||
else
|
||||
@@ -364,11 +368,15 @@ feature -- Output
|
||||
logger: detachable HTTPD_LOGGER
|
||||
|
||||
set_logger (a_logger: like logger)
|
||||
-- Set `logger' with `a_logger'.
|
||||
do
|
||||
logger := a_logger
|
||||
ensure
|
||||
logger_set: logger = a_logger
|
||||
end
|
||||
|
||||
log (m: STRING)
|
||||
-- Log message `m'.
|
||||
do
|
||||
if attached logger as l_logger then
|
||||
l_logger.log (m)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
note
|
||||
description: "Summary description for {HTTPD_SERVER_I}."
|
||||
description: "HTTPD server interface"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
@@ -14,10 +14,10 @@ inherit
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_factory: like factory)
|
||||
-- `a_cfg': server configuration
|
||||
-- Create current httpd server with `a_factory' of connection handlers.
|
||||
-- `a_factory': connection handler builder
|
||||
require
|
||||
fac_is_separated: {PLATFORM}.is_scoop_capable implies not attached {HTTPD_REQUEST_HANDLER_FACTORY} a_factory
|
||||
a_factory_is_separated: {PLATFORM}.is_scoop_capable implies not attached {HTTPD_REQUEST_HANDLER_FACTORY} a_factory
|
||||
do
|
||||
make_configured (create {like configuration}.make, a_factory)
|
||||
end
|
||||
@@ -67,6 +67,7 @@ feature -- Callbacks
|
||||
observer: detachable separate HTTPD_SERVER_OBSERVER
|
||||
|
||||
set_observer (obs: like observer)
|
||||
-- Set `observer' to `obs'.
|
||||
do
|
||||
observer := obs
|
||||
end
|
||||
@@ -252,7 +253,6 @@ feature -- Event
|
||||
require
|
||||
not_launched: not is_launched
|
||||
do
|
||||
-- print ("port=" + a_port.out + "%N")
|
||||
is_launched := True
|
||||
port := a_port
|
||||
if attached observer as obs then
|
||||
@@ -320,12 +320,15 @@ feature -- Output
|
||||
output: detachable FILE
|
||||
|
||||
set_log_output (f: FILE)
|
||||
-- Set `output' to `f'.
|
||||
do
|
||||
output := f
|
||||
ensure
|
||||
output_set: output = f
|
||||
end
|
||||
|
||||
log (a_message: separate READABLE_STRING_8)
|
||||
-- Log `a_message'
|
||||
-- Log `a_message'.
|
||||
local
|
||||
m: STRING
|
||||
do
|
||||
|
||||
@@ -18,9 +18,12 @@ create
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make
|
||||
-- Create a new instance and set ssl protocol to tls_1_2.
|
||||
do
|
||||
Precursor
|
||||
ssl_protocol := {SSL_PROTOCOL}.tls_1_2
|
||||
set_ssl_protocol_to_tls_1_2
|
||||
ensure then
|
||||
ssl_protocol_set: ssl_protocol = {SSL_PROTOCOL}.tls_1_2
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
note
|
||||
description: "Summary description for {WGI_HTTPD_REQUEST_HANDLER}."
|
||||
author: ""
|
||||
description: "[
|
||||
WGI implementation of HTTPD_REQUEST_HANDLER, will process the incoming connection
|
||||
and extract information on the request and the server
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
@@ -34,8 +36,10 @@ feature {NONE} -- Initialization
|
||||
feature -- Access
|
||||
|
||||
connector: detachable separate WGI_STANDALONE_CONNECTOR [G]
|
||||
-- httpd solution.
|
||||
|
||||
base: detachable IMMUTABLE_STRING_8
|
||||
-- Root url base.
|
||||
do
|
||||
if attached connector as conn then
|
||||
if attached connector_base (conn) as l_base then
|
||||
@@ -47,6 +51,7 @@ feature -- Access
|
||||
feature -- SCOOP helpers
|
||||
|
||||
connector_base (conn: separate WGI_STANDALONE_CONNECTOR [G]): detachable separate READABLE_STRING_8
|
||||
-- Rool url based from a connector `conn'.
|
||||
do
|
||||
Result := conn.base
|
||||
end
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
note
|
||||
description: "Summary description for {WGI_HTTPD_REQUEST_HANDLER_FACTORY}."
|
||||
author: ""
|
||||
description: "Implementation of WGI request handler factory for WGI_STANDALOE_CONNECTOR."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
@@ -13,10 +12,12 @@ inherit
|
||||
feature -- Access
|
||||
|
||||
connector: detachable separate WGI_STANDALONE_CONNECTOR [G]
|
||||
-- httpd solution.
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_connector (conn: like connector)
|
||||
-- Set `connector' with `conn'.
|
||||
do
|
||||
connector := conn
|
||||
end
|
||||
|
||||
@@ -16,12 +16,16 @@ inherit
|
||||
feature -- Access
|
||||
|
||||
started: BOOLEAN
|
||||
-- is the server started?
|
||||
|
||||
stopped: BOOLEAN
|
||||
-- is the server stoped?
|
||||
|
||||
terminated: BOOLEAN
|
||||
-- is the server terminated?
|
||||
|
||||
port: INTEGER
|
||||
-- Server listening on port.
|
||||
|
||||
feature -- Event
|
||||
|
||||
@@ -29,17 +33,24 @@ feature -- Event
|
||||
do
|
||||
started := True
|
||||
port := a_port
|
||||
ensure then
|
||||
started_set: started = True
|
||||
port_set: port = a_port
|
||||
end
|
||||
|
||||
on_stopped
|
||||
do
|
||||
stopped := True
|
||||
ensure then
|
||||
stopped_set: stopped = True
|
||||
end
|
||||
|
||||
on_terminated
|
||||
do
|
||||
port := 0
|
||||
terminated := True
|
||||
ensure then
|
||||
terminated_set: terminated = True
|
||||
end
|
||||
|
||||
note
|
||||
|
||||
@@ -10,8 +10,12 @@
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="connector_standalone" location="standalone-safe.ecf" readonly="false"/>
|
||||
<library name="ewsgi" location="..\..\ewsgi-safe.ecf" readonly="false"/>
|
||||
<library name="httpd_EDIT" location="src\httpd\httpd-safe.ecf" readonly="false"/>
|
||||
<library name="net_ssl_EDIT" location="$ISE_LIBRARY\unstable\library\network\socket\netssl\net_ssl-safe.ecf" readonly="false"/>
|
||||
<library name="httpd_edit" location="src\httpd\httpd-safe.ecf" readonly="false">
|
||||
<option debug="true">
|
||||
<debug name="dbglog" enabled="true"/>
|
||||
</option>
|
||||
</library>
|
||||
<library name="net_ssl_edit" location="$ISE_LIBRARY\unstable\library\network\socket\netssl\net_ssl-safe.ecf" readonly="false"/>
|
||||
<library name="wsf" location="..\..\..\wsf\wsf-safe.ecf" readonly="false"/>
|
||||
<cluster name="tests" location="tests\" recursive="true"/>
|
||||
</target>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
note
|
||||
description: "Summary description for {WSF_EXECUTION}."
|
||||
author: ""
|
||||
description: "Request execution based on attributes `request' and `response'. "
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
@@ -52,7 +51,7 @@ feature -- Access
|
||||
feature -- Execution
|
||||
|
||||
execute
|
||||
-- Execute Current `request',
|
||||
-- Execute Current request,
|
||||
-- getting data from `request'
|
||||
-- and response to client via `response'.
|
||||
deferred
|
||||
@@ -75,6 +74,7 @@ feature -- Status report
|
||||
feature -- Helpers
|
||||
|
||||
put_character (c: CHARACTER_8)
|
||||
-- Send the character `c'.
|
||||
require
|
||||
message_writable: message_writable
|
||||
do
|
||||
@@ -82,6 +82,7 @@ feature -- Helpers
|
||||
end
|
||||
|
||||
put_string (s: READABLE_STRING_8)
|
||||
-- Send the string `s'.
|
||||
require
|
||||
message_writable: message_writable
|
||||
do
|
||||
@@ -89,13 +90,13 @@ feature -- Helpers
|
||||
end
|
||||
|
||||
put_error (err: READABLE_STRING_8)
|
||||
-- Report error message `err' on the error output of the associated connector.
|
||||
require
|
||||
message_writable: message_writable
|
||||
do
|
||||
response.put_error (err)
|
||||
end
|
||||
|
||||
|
||||
feature -- Cleaning
|
||||
|
||||
clean
|
||||
|
||||
Reference in New Issue
Block a user