diff --git a/nino.ecf b/nino.ecf
index 4fa6a143..992aff1d 100644
--- a/nino.ecf
+++ b/nino.ecf
@@ -15,6 +15,12 @@
-
+
+
+ head_request_handler.e
+ shared_http_request_handlers.e
+ http_protocol_handler.e
+
+
diff --git a/src/configuration/http_server_configuration.e b/src/configuration/http_server_configuration.e
index 9c21ecf2..e7547db2 100644
--- a/src/configuration/http_server_configuration.e
+++ b/src/configuration/http_server_configuration.e
@@ -13,11 +13,12 @@ feature {NONE} -- Initialization
make
do
- http_server_port := 9_000
+ http_server_port := 80
max_tcp_clients := 100
socket_accept_timeout := 1_000
socket_connect_timeout := 5_000
document_root := "htdocs"
+ force_single_threaded := False
end
feature -- Access
@@ -29,6 +30,7 @@ feature -- Access
max_tcp_clients: INTEGER assign set_max_tcp_clients
socket_accept_timeout: INTEGER assign set_socket_accept_timeout
socket_connect_timeout: INTEGER assign set_socket_connect_timeout
+ force_single_threaded: BOOLEAN assign set_force_single_threaded
feature -- Element change
@@ -57,4 +59,10 @@ feature -- Element change
socket_connect_timeout := v
end
+ set_force_single_threaded (v: like force_single_threaded)
+ do
+ force_single_threaded := v
+ end
+
+
end
diff --git a/src/http_connection_handler.e b/src/http_connection_handler.e
index d8a0e2c5..86295545 100644
--- a/src/http_connection_handler.e
+++ b/src/http_connection_handler.e
@@ -34,28 +34,39 @@ feature -- Execution
local
l_input: HTTP_INPUT_STREAM
l_output: HTTP_OUTPUT_STREAM
+ l_remote_info: detachable like remote_info
do
create l_input.make (client_socket)
create l_output.make (client_socket)
+ create l_remote_info
+ if attached client_socket.address as l_addr then
+ l_remote_info.addr := l_addr.host_address.host_address
+ l_remote_info.hostname := l_addr.host_address.host_name
+ l_remote_info.port := l_addr.port
+ end
+ remote_info := l_remote_info
+
analyze_request_message (l_input)
- process_request (uri, method, request_header_map, request_header, l_input, l_output)
+ process_request (Current, l_input, l_output)
end
feature -- Request processing
- process_request (a_uri: STRING; a_method: STRING; a_headers_map: HASH_TABLE [STRING, STRING]; a_headers_text: STRING; a_input: HTTP_INPUT_STREAM; a_output: HTTP_OUTPUT_STREAM)
+ process_request (a_handler: HTTP_CONNECTION_HANDLER; a_input: HTTP_INPUT_STREAM; a_output: HTTP_OUTPUT_STREAM)
-- Process request ...
require
- a_uri_attached: a_uri /= Void
- a_method_attached: a_method /= Void
- a_headers_text_attached: a_headers_text /= Void
+ a_handler_attached: a_handler /= Void
+ a_uri_attached: a_handler.uri /= Void
+ a_method_attached: a_handler.method /= Void
+ a_header_map_attached: a_handler.request_header_map /= Void
+ a_header_text_attached: a_handler.request_header /= Void
a_input_attached: a_input /= Void
a_output_attached: a_output /= Void
deferred
end
-feature {NONE} -- Access
+feature -- Access
request_header: STRING
-- Header' source
@@ -73,6 +84,8 @@ feature {NONE} -- Access
-- http_version
--| unused for now
+ remote_info: detachable TUPLE [addr: STRING; hostname: STRING; port: INTEGER]
+
feature -- Parsing
parse_http_request_line (line: STRING)
diff --git a/src/http_server.e b/src/http_server.e
index 3ef61c09..e3652845 100644
--- a/src/http_server.e
+++ b/src/http_server.e
@@ -28,8 +28,12 @@ feature -- Initialization
print ("Starting Web Application Server:%N")
stop_requested := False
set_server_configuration (configuration)
- a_http_handler.launch
- a_http_handler.join
+ if configuration.force_single_threaded then
+ a_http_handler.execute
+ else
+ a_http_handler.launch
+ a_http_handler.join
+ end
end
shutdown_server
diff --git a/web_server/application_handler.e b/web_server/application_handler.e
index 9a63a82a..78277160 100644
--- a/web_server/application_handler.e
+++ b/web_server/application_handler.e
@@ -15,13 +15,17 @@ create
feature -- Request processing
- process_request (a_uri: STRING; a_method: STRING; a_headers_map: HASH_TABLE [STRING, STRING]; a_headers_text: STRING; a_input: HTTP_INPUT_STREAM; a_output: HTTP_OUTPUT_STREAM)
+ process_request (a_handler: HTTP_CONNECTION_HANDLER; a_input: HTTP_INPUT_STREAM; a_output: HTTP_OUTPUT_STREAM)
-- Process request ...
+ local
+ a_method: STRING
do
+ a_method := a_handler.method
+
if a_method.is_equal (Get) then
- execute_get_request (a_uri, a_headers_map, a_headers_text, a_input, a_output)
+ execute_get_request (a_handler.uri, a_handler.request_header_map, a_handler.request_header, a_input, a_output)
elseif a_method.is_equal (Post) then
- execute_post_request (a_uri, a_headers_map, a_headers_text, a_input, a_output)
+ execute_post_request (a_handler.uri, a_handler.request_header_map, a_handler.request_header, a_input, a_output)
elseif a_method.is_equal (Put) then
elseif a_method.is_equal (Options) then
elseif a_method.is_equal (Head) then