Added force_single_threaded option
Modified the interface of process request default port is now 80
This commit is contained in:
8
nino.ecf
8
nino.ecf
@@ -15,6 +15,12 @@
|
|||||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||||
<library name="net" location="$ISE_LIBRARY\library\net\net-safe.ecf"/>
|
<library name="net" location="$ISE_LIBRARY\library\net\net-safe.ecf"/>
|
||||||
<library name="thread" location="$ISE_LIBRARY\library\thread\thread-safe.ecf"/>
|
<library name="thread" location="$ISE_LIBRARY\library\thread\thread-safe.ecf"/>
|
||||||
<cluster name="nino" location=".\src" recursive="true"/>
|
<cluster name="nino" location=".\src" recursive="true">
|
||||||
|
<file_rule>
|
||||||
|
<exclude>head_request_handler.e</exclude>
|
||||||
|
<exclude>shared_http_request_handlers.e</exclude>
|
||||||
|
<exclude>http_protocol_handler.e</exclude>
|
||||||
|
</file_rule>
|
||||||
|
</cluster>
|
||||||
</target>
|
</target>
|
||||||
</system>
|
</system>
|
||||||
|
|||||||
@@ -13,11 +13,12 @@ feature {NONE} -- Initialization
|
|||||||
|
|
||||||
make
|
make
|
||||||
do
|
do
|
||||||
http_server_port := 9_000
|
http_server_port := 80
|
||||||
max_tcp_clients := 100
|
max_tcp_clients := 100
|
||||||
socket_accept_timeout := 1_000
|
socket_accept_timeout := 1_000
|
||||||
socket_connect_timeout := 5_000
|
socket_connect_timeout := 5_000
|
||||||
document_root := "htdocs"
|
document_root := "htdocs"
|
||||||
|
force_single_threaded := False
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Access
|
feature -- Access
|
||||||
@@ -29,6 +30,7 @@ feature -- Access
|
|||||||
max_tcp_clients: INTEGER assign set_max_tcp_clients
|
max_tcp_clients: INTEGER assign set_max_tcp_clients
|
||||||
socket_accept_timeout: INTEGER assign set_socket_accept_timeout
|
socket_accept_timeout: INTEGER assign set_socket_accept_timeout
|
||||||
socket_connect_timeout: INTEGER assign set_socket_connect_timeout
|
socket_connect_timeout: INTEGER assign set_socket_connect_timeout
|
||||||
|
force_single_threaded: BOOLEAN assign set_force_single_threaded
|
||||||
|
|
||||||
feature -- Element change
|
feature -- Element change
|
||||||
|
|
||||||
@@ -57,4 +59,10 @@ feature -- Element change
|
|||||||
socket_connect_timeout := v
|
socket_connect_timeout := v
|
||||||
end
|
end
|
||||||
|
|
||||||
|
set_force_single_threaded (v: like force_single_threaded)
|
||||||
|
do
|
||||||
|
force_single_threaded := v
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -34,28 +34,39 @@ feature -- Execution
|
|||||||
local
|
local
|
||||||
l_input: HTTP_INPUT_STREAM
|
l_input: HTTP_INPUT_STREAM
|
||||||
l_output: HTTP_OUTPUT_STREAM
|
l_output: HTTP_OUTPUT_STREAM
|
||||||
|
l_remote_info: detachable like remote_info
|
||||||
do
|
do
|
||||||
create l_input.make (client_socket)
|
create l_input.make (client_socket)
|
||||||
create l_output.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)
|
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
|
end
|
||||||
|
|
||||||
feature -- Request processing
|
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 ...
|
-- Process request ...
|
||||||
require
|
require
|
||||||
a_uri_attached: a_uri /= Void
|
a_handler_attached: a_handler /= Void
|
||||||
a_method_attached: a_method /= Void
|
a_uri_attached: a_handler.uri /= Void
|
||||||
a_headers_text_attached: a_headers_text /= 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_input_attached: a_input /= Void
|
||||||
a_output_attached: a_output /= Void
|
a_output_attached: a_output /= Void
|
||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
feature {NONE} -- Access
|
feature -- Access
|
||||||
|
|
||||||
request_header: STRING
|
request_header: STRING
|
||||||
-- Header' source
|
-- Header' source
|
||||||
@@ -73,6 +84,8 @@ feature {NONE} -- Access
|
|||||||
-- http_version
|
-- http_version
|
||||||
--| unused for now
|
--| unused for now
|
||||||
|
|
||||||
|
remote_info: detachable TUPLE [addr: STRING; hostname: STRING; port: INTEGER]
|
||||||
|
|
||||||
feature -- Parsing
|
feature -- Parsing
|
||||||
|
|
||||||
parse_http_request_line (line: STRING)
|
parse_http_request_line (line: STRING)
|
||||||
|
|||||||
@@ -28,8 +28,12 @@ feature -- Initialization
|
|||||||
print ("Starting Web Application Server:%N")
|
print ("Starting Web Application Server:%N")
|
||||||
stop_requested := False
|
stop_requested := False
|
||||||
set_server_configuration (configuration)
|
set_server_configuration (configuration)
|
||||||
a_http_handler.launch
|
if configuration.force_single_threaded then
|
||||||
a_http_handler.join
|
a_http_handler.execute
|
||||||
|
else
|
||||||
|
a_http_handler.launch
|
||||||
|
a_http_handler.join
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
shutdown_server
|
shutdown_server
|
||||||
|
|||||||
@@ -15,13 +15,17 @@ create
|
|||||||
|
|
||||||
feature -- Request processing
|
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 ...
|
-- Process request ...
|
||||||
|
local
|
||||||
|
a_method: STRING
|
||||||
do
|
do
|
||||||
|
a_method := a_handler.method
|
||||||
|
|
||||||
if a_method.is_equal (Get) then
|
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
|
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 (Put) then
|
||||||
elseif a_method.is_equal (Options) then
|
elseif a_method.is_equal (Options) then
|
||||||
elseif a_method.is_equal (Head) then
|
elseif a_method.is_equal (Head) then
|
||||||
|
|||||||
Reference in New Issue
Block a user