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
|
create l_cfg.make
|
||||||
l_cfg.http_server_port := 9_000
|
l_cfg.http_server_port := 9_000
|
||||||
l_cfg.document_root := default_document_root
|
l_cfg.document_root := default_document_root
|
||||||
|
debug ("nino")
|
||||||
|
l_cfg.set_is_verbose (True)
|
||||||
|
end
|
||||||
|
|
||||||
create l_server.make (l_cfg)
|
create l_server.make (l_cfg)
|
||||||
create {APPLICATION_CONNECTION_HANDLER} l_http_handler.make (l_server)
|
create {APPLICATION_CONNECTION_HANDLER} l_http_handler.make (l_server)
|
||||||
|
|||||||
@@ -15,17 +15,17 @@ create
|
|||||||
|
|
||||||
feature -- Request processing
|
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 ...
|
-- Process request ...
|
||||||
local
|
local
|
||||||
a_method: STRING
|
a_method: STRING
|
||||||
do
|
do
|
||||||
a_method := a_handler.method
|
a_method := a_handler.method
|
||||||
|
|
||||||
if a_method.is_equal (Get) then
|
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
|
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 (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
|
||||||
@@ -39,21 +39,21 @@ feature -- Request processing
|
|||||||
end
|
end
|
||||||
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
|
local
|
||||||
l_http_request : HTTP_REQUEST_HANDLER
|
l_http_request : HTTP_REQUEST_HANDLER
|
||||||
do
|
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.set_uri (a_uri)
|
||||||
l_http_request.process
|
l_http_request.process
|
||||||
end
|
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
|
local
|
||||||
l_http_request : HTTP_REQUEST_HANDLER
|
l_http_request : HTTP_REQUEST_HANDLER
|
||||||
do
|
do
|
||||||
check not_yet_implemented: False end
|
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.set_uri (a_uri)
|
||||||
l_http_request.process
|
l_http_request.process
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -24,18 +24,15 @@ create
|
|||||||
|
|
||||||
feature {NONE} -- Initialization
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make (a_input: like input; a_output: like output)
|
make (a_socket: TCP_STREAM_SOCKET)
|
||||||
do
|
do
|
||||||
default_create
|
default_create
|
||||||
input := a_input
|
socket := a_socket
|
||||||
output := a_output
|
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Access
|
feature -- Access
|
||||||
|
|
||||||
input: HTTP_INPUT_STREAM
|
socket: TCP_STREAM_SOCKET
|
||||||
|
|
||||||
output: HTTP_OUTPUT_STREAM
|
|
||||||
|
|
||||||
feature -- Execution
|
feature -- Execution
|
||||||
|
|
||||||
@@ -88,7 +85,7 @@ feature -- Execution
|
|||||||
end
|
end
|
||||||
|
|
||||||
--| Output the result
|
--| Output the result
|
||||||
output.put_string (answer.reply_header + answer.reply_text)
|
socket.put_string (answer.reply_header + answer.reply_text)
|
||||||
end
|
end
|
||||||
|
|
||||||
process_default
|
process_default
|
||||||
|
|||||||
@@ -22,19 +22,30 @@ feature -- Execution
|
|||||||
-- process the request and create an answer
|
-- process the request and create an answer
|
||||||
local
|
local
|
||||||
l_data: STRING
|
l_data: STRING
|
||||||
s: STRING
|
s: detachable STRING
|
||||||
n: INTEGER
|
n: INTEGER
|
||||||
|
sock: like socket
|
||||||
do
|
do
|
||||||
from
|
from
|
||||||
n := 1_024
|
n := 1_024
|
||||||
input.read_stream (n)
|
sock := socket
|
||||||
s := input.last_string
|
if sock.socket_ok then
|
||||||
|
sock.read_stream_thread_aware (n)
|
||||||
|
s := sock.last_string
|
||||||
|
else
|
||||||
|
s := Void
|
||||||
|
end
|
||||||
create l_data.make_empty
|
create l_data.make_empty
|
||||||
until
|
until
|
||||||
s.count < n
|
s = Void or else s.count < n
|
||||||
loop
|
loop
|
||||||
l_data.append_string (s)
|
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
|
end
|
||||||
Precursor
|
Precursor
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,21 +1,22 @@
|
|||||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
<?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">
|
<target name="web_server">
|
||||||
<root class="APPLICATION" feature="make"/>
|
<root class="APPLICATION" feature="make"/>
|
||||||
<file_rule>
|
<file_rule>
|
||||||
|
<exclude>/.git$</exclude>
|
||||||
<exclude>/EIFGENs$</exclude>
|
<exclude>/EIFGENs$</exclude>
|
||||||
<exclude>/CVS$</exclude>
|
<exclude>/CVS$</exclude>
|
||||||
<exclude>/.svn$</exclude>
|
<exclude>/.svn$</exclude>
|
||||||
<exclude>/.git$</exclude>
|
|
||||||
</file_rule>
|
</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"/>
|
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
|
||||||
</option>
|
</option>
|
||||||
<setting name="concurrency" value="thread"/>
|
<setting name="concurrency" value="thread"/>
|
||||||
<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="nino" location="..\..\nino-safe.ecf"/>
|
||||||
<library name="thread" location="$ISE_LIBRARY\library\thread\thread-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"/>
|
<cluster name="src" location=".\" recursive="true"/>
|
||||||
</target>
|
</target>
|
||||||
</system>
|
</system>
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
<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=".\library\" recursive="true">
|
<cluster name="nino" location=".\library\" recursive="true"/>
|
||||||
</cluster>
|
|
||||||
</target>
|
</target>
|
||||||
</system>
|
</system>
|
||||||
|
|||||||
Reference in New Issue
Block a user