Added force_single_threaded option

Modified the interface of process request
default port is now 80
This commit is contained in:
Jocelyn Fiat
2011-05-27 19:08:35 +02:00
parent 720351871b
commit e5e9f9486e
5 changed files with 48 additions and 13 deletions

View File

@@ -15,6 +15,12 @@
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="net" location="$ISE_LIBRARY\library\net\net-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>
</system>

View File

@@ -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

View File

@@ -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)

View File

@@ -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

View File

@@ -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