various renaming and preparation to merge Thread and SCOOP implementation of Eiffel Web Nino
This commit is contained in:
@@ -15,12 +15,12 @@ inherit
|
|||||||
|
|
||||||
feature {NONE} -- Initialization
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make (a_main_server: like main_server)
|
make (a_server: like server)
|
||||||
-- Creates a {HTTP_CONNECTION_HANDLER}, assigns the main_server and sets the current_request_message to empty.
|
-- Creates a {HTTP_CONNECTION_HANDLER}, assigns the main_server and sets the current_request_message to empty.
|
||||||
--
|
--
|
||||||
-- `a_main_server': The main server object
|
-- `a_server': The main server object
|
||||||
do
|
do
|
||||||
Precursor (a_main_server)
|
Precursor (a_server)
|
||||||
reset
|
reset
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
note
|
note
|
||||||
description: "Summary description for {HTTP_CONNECTION_HANDLER}."
|
description: "Summary description for {HTTP_CONNECTION_HANDLER}."
|
||||||
author: ""
|
|
||||||
date: "$Date$"
|
date: "$Date$"
|
||||||
revision: "$Revision$"
|
revision: "$Revision$"
|
||||||
|
|
||||||
@@ -14,22 +13,23 @@ inherit
|
|||||||
|
|
||||||
feature {NONE} -- Initialization
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make (a_main_server: like main_server)
|
make (a_server: like server)
|
||||||
-- Creates a {HTTP_HANDLER}, assigns the main_server and initialize various values
|
-- Creates a {HTTP_HANDLER}, assigns the server and initialize various values
|
||||||
--
|
--
|
||||||
-- `a_main_server': The main server object
|
-- `a_server': The main server object
|
||||||
require
|
require
|
||||||
a_main_server_attached: a_main_server /= Void
|
a_server_attached: a_server /= Void
|
||||||
do
|
do
|
||||||
main_server := a_main_server
|
server := a_server
|
||||||
is_stop_requested := False
|
is_stop_requested := False
|
||||||
ensure
|
ensure
|
||||||
main_server_set: a_main_server ~ main_server
|
server_set: a_server ~ server
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Output
|
feature -- Output
|
||||||
|
|
||||||
log (a_message: READABLE_STRING_8)
|
log (a_message: READABLE_STRING_8)
|
||||||
|
-- Log `a_message'
|
||||||
do
|
do
|
||||||
io.put_string (a_message)
|
io.put_string (a_message)
|
||||||
end
|
end
|
||||||
@@ -40,22 +40,22 @@ feature -- Inherited Features
|
|||||||
-- <Precursor>
|
-- <Precursor>
|
||||||
-- Creates a socket and connects to the http server.
|
-- Creates a socket and connects to the http server.
|
||||||
local
|
local
|
||||||
l_http_socket: detachable TCP_STREAM_SOCKET
|
l_listening_socket: detachable TCP_STREAM_SOCKET
|
||||||
l_http_port: INTEGER
|
l_http_port: INTEGER
|
||||||
do
|
do
|
||||||
launched := False
|
launched := False
|
||||||
port := 0
|
port := 0
|
||||||
is_stop_requested := False
|
is_stop_requested := False
|
||||||
l_http_port := main_server_configuration.http_server_port
|
l_http_port := http_server_port
|
||||||
create l_http_socket.make_server_by_port (l_http_port)
|
create l_listening_socket.make_server_by_port (l_http_port)
|
||||||
if not l_http_socket.is_bound then
|
if not l_listening_socket.is_bound then
|
||||||
if is_verbose then
|
if is_verbose then
|
||||||
log ("Socket could not be bound on port " + l_http_port.out )
|
log ("Socket could not be bound on port " + l_http_port.out )
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
l_http_port := l_http_socket.port
|
l_http_port := l_listening_socket.port
|
||||||
from
|
from
|
||||||
l_http_socket.listen (main_server_configuration.max_tcp_clients)
|
l_listening_socket.listen (max_tcp_clients)
|
||||||
if is_verbose then
|
if is_verbose then
|
||||||
log ("%NHTTP Connection Server ready on port " + l_http_port.out +" : http://localhost:" + l_http_port.out + "/%N")
|
log ("%NHTTP Connection Server ready on port " + l_http_port.out +" : http://localhost:" + l_http_port.out + "/%N")
|
||||||
end
|
end
|
||||||
@@ -63,17 +63,17 @@ feature -- Inherited Features
|
|||||||
until
|
until
|
||||||
is_stop_requested
|
is_stop_requested
|
||||||
loop
|
loop
|
||||||
l_http_socket.accept
|
l_listening_socket.accept
|
||||||
if not is_stop_requested then
|
if not is_stop_requested then
|
||||||
if attached l_http_socket.accepted as l_thread_http_socket then
|
if attached l_listening_socket.accepted as l_thread_http_socket then
|
||||||
process_connection (l_thread_http_socket)
|
process_connection (l_thread_http_socket)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
is_stop_requested := main_server.stop_requested
|
is_stop_requested := stop_requested_on_server
|
||||||
end
|
end
|
||||||
l_http_socket.cleanup
|
l_listening_socket.cleanup
|
||||||
check
|
check
|
||||||
socket_is_closed: l_http_socket.is_closed
|
socket_is_closed: l_listening_socket.is_closed
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if launched then
|
if launched then
|
||||||
@@ -85,10 +85,10 @@ feature -- Inherited Features
|
|||||||
rescue
|
rescue
|
||||||
log ("HTTP Connection Server shutdown due to exception. Please relaunch manually.")
|
log ("HTTP Connection Server shutdown due to exception. Please relaunch manually.")
|
||||||
|
|
||||||
if attached l_http_socket as ll_http_socket then
|
if l_listening_socket /= Void then
|
||||||
ll_http_socket.cleanup
|
l_listening_socket.cleanup
|
||||||
check
|
check
|
||||||
socket_is_closed: ll_http_socket.is_closed
|
socket_is_closed: l_listening_socket.is_closed
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if launched then
|
if launched then
|
||||||
@@ -101,7 +101,9 @@ feature -- Inherited Features
|
|||||||
process_connection (a_socket: TCP_STREAM_SOCKET)
|
process_connection (a_socket: TCP_STREAM_SOCKET)
|
||||||
-- Process incoming connection
|
-- Process incoming connection
|
||||||
do
|
do
|
||||||
|
if is_verbose then
|
||||||
log ("Incoming connection...%N")
|
log ("Incoming connection...%N")
|
||||||
|
end
|
||||||
--| FIXME jfiat [2011/11/03] : should use a Pool of Threads/Handler to process this connection
|
--| FIXME jfiat [2011/11/03] : should use a Pool of Threads/Handler to process this connection
|
||||||
--| also handle permanent connection...?
|
--| also handle permanent connection...?
|
||||||
receive_message_and_send_reply (a_socket)
|
receive_message_and_send_reply (a_socket)
|
||||||
@@ -135,12 +137,6 @@ feature -- Event
|
|||||||
|
|
||||||
feature -- Access
|
feature -- Access
|
||||||
|
|
||||||
is_verbose: BOOLEAN
|
|
||||||
-- Is verbose for output messages.
|
|
||||||
do
|
|
||||||
Result := main_server_configuration.is_verbose
|
|
||||||
end
|
|
||||||
|
|
||||||
is_stop_requested: BOOLEAN
|
is_stop_requested: BOOLEAN
|
||||||
-- Set true to stop accept loop
|
-- Set true to stop accept loop
|
||||||
|
|
||||||
@@ -151,15 +147,46 @@ feature -- Access
|
|||||||
-- Listening port.
|
-- Listening port.
|
||||||
--| 0: not launched
|
--| 0: not launched
|
||||||
|
|
||||||
feature {NONE} -- Access
|
feature -- Access: configuration
|
||||||
|
|
||||||
main_server: HTTP_SERVER
|
is_verbose: BOOLEAN
|
||||||
|
-- Is verbose for output messages.
|
||||||
|
do
|
||||||
|
Result := server_configuration.is_verbose
|
||||||
|
end
|
||||||
|
|
||||||
|
force_single_threaded: BOOLEAN
|
||||||
|
do
|
||||||
|
Result := server_configuration.force_single_threaded
|
||||||
|
end
|
||||||
|
|
||||||
|
http_server_port: INTEGER
|
||||||
|
do
|
||||||
|
Result := server_configuration.http_server_port
|
||||||
|
end
|
||||||
|
|
||||||
|
max_tcp_clients: INTEGER
|
||||||
|
do
|
||||||
|
Result := server_configuration.max_tcp_clients
|
||||||
|
end
|
||||||
|
|
||||||
|
feature {NONE} -- Access: server
|
||||||
|
|
||||||
|
server: HTTP_SERVER
|
||||||
-- The main server object
|
-- The main server object
|
||||||
|
|
||||||
main_server_configuration: HTTP_SERVER_CONFIGURATION
|
stop_requested_on_server: BOOLEAN
|
||||||
|
-- Stop requested on `server' object
|
||||||
|
do
|
||||||
|
Result := server.stop_requested
|
||||||
|
end
|
||||||
|
|
||||||
|
feature {NONE} -- Access: configuration
|
||||||
|
|
||||||
|
server_configuration: HTTP_SERVER_CONFIGURATION
|
||||||
-- The main server's configuration
|
-- The main server's configuration
|
||||||
do
|
do
|
||||||
Result := main_server.configuration
|
Result := server.configuration
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Status setting
|
feature -- Status setting
|
||||||
@@ -181,7 +208,7 @@ feature -- Execution
|
|||||||
end
|
end
|
||||||
|
|
||||||
invariant
|
invariant
|
||||||
main_server_attached: main_server /= Void
|
server_attached: server /= Void
|
||||||
|
|
||||||
note
|
note
|
||||||
copyright: "2011-2011, Javier Velilla and others"
|
copyright: "2011-2011, Javier Velilla and others"
|
||||||
|
|||||||
Reference in New Issue
Block a user