Applied the removal of HTTP_INPUT_STREAM and HTTP_OUTPUT_STREAM to the example.
This commit is contained in:
@@ -24,6 +24,9 @@ feature {NONE} -- Initialization
|
||||
create l_cfg.make
|
||||
l_cfg.http_server_port := 9_000
|
||||
l_cfg.document_root := default_document_root
|
||||
debug ("nino")
|
||||
l_cfg.set_is_verbose (True)
|
||||
end
|
||||
|
||||
create l_server.make (l_cfg)
|
||||
create {APPLICATION_CONNECTION_HANDLER} l_http_handler.make (l_server)
|
||||
|
||||
@@ -15,7 +15,7 @@ create
|
||||
|
||||
feature -- Request processing
|
||||
|
||||
process_request (a_handler: HTTP_CONNECTION_HANDLER; a_input: HTTP_INPUT_STREAM; a_output: HTTP_OUTPUT_STREAM)
|
||||
process_request (a_handler: HTTP_CONNECTION_HANDLER; a_socket: TCP_STREAM_SOCKET)
|
||||
-- Process request ...
|
||||
local
|
||||
a_method: STRING
|
||||
@@ -23,9 +23,9 @@ feature -- Request processing
|
||||
a_method := a_handler.method
|
||||
|
||||
if a_method.is_equal (Get) then
|
||||
execute_get_request (a_handler.uri, a_handler.request_header_map, a_handler.request_header, a_input, a_output)
|
||||
execute_get_request (a_handler.uri, a_handler.request_header_map, a_handler.request_header, a_socket)
|
||||
elseif a_method.is_equal (Post) then
|
||||
execute_post_request (a_handler.uri, a_handler.request_header_map, a_handler.request_header, a_input, a_output)
|
||||
execute_post_request (a_handler.uri, a_handler.request_header_map, a_handler.request_header, a_socket)
|
||||
elseif a_method.is_equal (Put) then
|
||||
elseif a_method.is_equal (Options) then
|
||||
elseif a_method.is_equal (Head) then
|
||||
@@ -39,21 +39,21 @@ feature -- Request processing
|
||||
end
|
||||
end
|
||||
|
||||
execute_get_request (a_uri: STRING; a_headers_map: HASH_TABLE [STRING, STRING]; a_headers_text: STRING; a_input: HTTP_INPUT_STREAM; a_output: HTTP_OUTPUT_STREAM)
|
||||
execute_get_request (a_uri: STRING; a_headers_map: HASH_TABLE [STRING, STRING]; a_headers_text: STRING; a_socket: TCP_STREAM_SOCKET)
|
||||
local
|
||||
l_http_request : HTTP_REQUEST_HANDLER
|
||||
do
|
||||
create {GET_REQUEST_HANDLER} l_http_request.make (a_input, a_output)
|
||||
create {GET_REQUEST_HANDLER} l_http_request.make (a_socket)
|
||||
l_http_request.set_uri (a_uri)
|
||||
l_http_request.process
|
||||
end
|
||||
|
||||
execute_post_request (a_uri: STRING; a_headers_map: HASH_TABLE [STRING, STRING]; a_headers_text: STRING; a_input: HTTP_INPUT_STREAM; a_output: HTTP_OUTPUT_STREAM)
|
||||
execute_post_request (a_uri: STRING; a_headers_map: HASH_TABLE [STRING, STRING]; a_headers_text: STRING; a_socket: TCP_STREAM_SOCKET)
|
||||
local
|
||||
l_http_request : HTTP_REQUEST_HANDLER
|
||||
do
|
||||
check not_yet_implemented: False end
|
||||
create {POST_REQUEST_HANDLER} l_http_request.make (a_input, a_output)
|
||||
create {POST_REQUEST_HANDLER} l_http_request.make (a_socket)
|
||||
l_http_request.set_uri (a_uri)
|
||||
l_http_request.process
|
||||
end
|
||||
|
||||
@@ -24,18 +24,15 @@ create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_input: like input; a_output: like output)
|
||||
make (a_socket: TCP_STREAM_SOCKET)
|
||||
do
|
||||
default_create
|
||||
input := a_input
|
||||
output := a_output
|
||||
socket := a_socket
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
input: HTTP_INPUT_STREAM
|
||||
|
||||
output: HTTP_OUTPUT_STREAM
|
||||
socket: TCP_STREAM_SOCKET
|
||||
|
||||
feature -- Execution
|
||||
|
||||
@@ -88,7 +85,7 @@ feature -- Execution
|
||||
end
|
||||
|
||||
--| Output the result
|
||||
output.put_string (answer.reply_header + answer.reply_text)
|
||||
socket.put_string (answer.reply_header + answer.reply_text)
|
||||
end
|
||||
|
||||
process_default
|
||||
|
||||
@@ -22,19 +22,30 @@ feature -- Execution
|
||||
-- process the request and create an answer
|
||||
local
|
||||
l_data: STRING
|
||||
s: STRING
|
||||
s: detachable STRING
|
||||
n: INTEGER
|
||||
sock: like socket
|
||||
do
|
||||
from
|
||||
n := 1_024
|
||||
input.read_stream (n)
|
||||
s := input.last_string
|
||||
sock := socket
|
||||
if sock.socket_ok then
|
||||
sock.read_stream_thread_aware (n)
|
||||
s := sock.last_string
|
||||
else
|
||||
s := Void
|
||||
end
|
||||
create l_data.make_empty
|
||||
until
|
||||
s.count < n
|
||||
s = Void or else s.count < n
|
||||
loop
|
||||
l_data.append_string (s)
|
||||
input.read_stream (n)
|
||||
if sock.socket_ok then
|
||||
sock.read_stream_thread_aware (n)
|
||||
s := sock.last_string
|
||||
else
|
||||
s := Void
|
||||
end
|
||||
end
|
||||
Precursor
|
||||
end
|
||||
|
||||
@@ -1,21 +1,22 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-8-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-8-0 http://www.eiffel.com/developers/xml/configuration-1-8-0.xsd" name="web_server" uuid="B1D3254D-A58E-4259-9796-8A2843A511A9">
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-9-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-9-0 http://www.eiffel.com/developers/xml/configuration-1-9-0.xsd" name="web_server" uuid="B1D3254D-A58E-4259-9796-8A2843A511A9">
|
||||
<target name="web_server">
|
||||
<root class="APPLICATION" feature="make"/>
|
||||
<file_rule>
|
||||
<exclude>/.git$</exclude>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/CVS$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
<exclude>/.git$</exclude>
|
||||
</file_rule>
|
||||
<option warning="true" is_attached_by_default="true" void_safety="all">
|
||||
<option debug="true" warning="true" is_attached_by_default="true" void_safety="all" syntax="transitional">
|
||||
<debug name="nino" enabled="true"/>
|
||||
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||
</option>
|
||||
<setting name="concurrency" value="thread"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="net" location="$ISE_LIBRARY\library\net\net-safe.ecf"/>
|
||||
<library name="nino" location="..\..\nino-safe.ecf"/>
|
||||
<library name="thread" location="$ISE_LIBRARY\library\thread\thread-safe.ecf"/>
|
||||
<library name="nino" location="../../nino-safe.ecf"/>
|
||||
<cluster name="src" location=".\" recursive="true"/>
|
||||
</target>
|
||||
</system>
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
<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=".\library\" recursive="true">
|
||||
</cluster>
|
||||
<cluster name="nino" location=".\library\" recursive="true"/>
|
||||
</target>
|
||||
</system>
|
||||
|
||||
Reference in New Issue
Block a user