First step to extract the interface of the EWSGI specification into its own library
Applied the changes
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
</option>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
|
||||
<library name="ewsgi_spec" location="ewsgi_specification-safe.ecf"/>
|
||||
<library name="error" location="..\..\error\error-safe.ecf"/>
|
||||
<library name="http" location="..\..\protocol\http\http-safe.ecf"/>
|
||||
<library name="encoder" location="..\..\text\encoder\encoder-safe.ecf" readonly="false"/>
|
||||
|
||||
18
library/server/ewsgi/ewsgi_specification-safe.ecf
Normal file
18
library/server/ewsgi/ewsgi_specification-safe.ecf
Normal file
@@ -0,0 +1,18 @@
|
||||
<?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="ewsgi_spec" uuid="D6455232-E709-43B3-A2C7-D3E6F6A98288" library_target="ewsgi_spec">
|
||||
<target name="ewsgi_spec">
|
||||
<root all_classes="true"/>
|
||||
<file_rule>
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/\.git$</exclude>
|
||||
<exclude>/\.svn$</exclude>
|
||||
</file_rule>
|
||||
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="provisional">
|
||||
</option>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
|
||||
<library name="http" location="..\..\protocol\http\http-safe.ecf"/>
|
||||
<library name="encoder" location="..\..\text\encoder\encoder-safe.ecf" readonly="false"/>
|
||||
<cluster name="specification" location="specification\" recursive="true"/>
|
||||
</target>
|
||||
</system>
|
||||
@@ -36,8 +36,31 @@ feature {NONE} -- Status output
|
||||
body.append (s)
|
||||
end
|
||||
|
||||
feature -- Status setting
|
||||
|
||||
is_status_set: BOOLEAN
|
||||
do
|
||||
Result := status_code /= 0
|
||||
end
|
||||
|
||||
set_status_code (a_code: INTEGER)
|
||||
-- Set response status code
|
||||
-- Should be done before sending any data back to the client
|
||||
do
|
||||
status_code := a_code
|
||||
end
|
||||
|
||||
status_code: INTEGER
|
||||
-- Response status
|
||||
|
||||
feature -- Output operation
|
||||
|
||||
write_string (s: STRING)
|
||||
-- Send the string `s'
|
||||
do
|
||||
write (s)
|
||||
end
|
||||
|
||||
write_file_content (fn: STRING)
|
||||
-- Send the content of file `fn'
|
||||
local
|
||||
@@ -57,9 +80,27 @@ feature -- Output operation
|
||||
end
|
||||
end
|
||||
|
||||
write_header_object (h: GW_HEADER)
|
||||
-- Send `header' to `output'.
|
||||
feature -- Header output operation
|
||||
|
||||
write_header (a_status_code: INTEGER; a_headers: detachable ARRAY [TUPLE [key: STRING; value: STRING]])
|
||||
-- Send headers with status `a_status', and headers from `a_headers'
|
||||
local
|
||||
h: GW_HEADER
|
||||
i,n: INTEGER
|
||||
do
|
||||
set_status_code (a_status_code)
|
||||
create h.make
|
||||
if a_headers /= Void then
|
||||
from
|
||||
i := a_headers.lower
|
||||
n := a_headers.upper
|
||||
until
|
||||
i > n
|
||||
loop
|
||||
h.put_header_key_value (a_headers[i].key, a_headers[i].value)
|
||||
i := i + 1
|
||||
end
|
||||
end
|
||||
header := h
|
||||
end
|
||||
|
||||
@@ -67,10 +108,10 @@ feature {GW_APPLICATION} -- Commit
|
||||
|
||||
commit (a_output: GW_OUTPUT_STREAM)
|
||||
do
|
||||
a_output.put_status (status_code)
|
||||
header.send_to (a_output)
|
||||
write (body)
|
||||
Precursor (a_output)
|
||||
a_output.put_status_line (status_code)
|
||||
a_output.put_string (header.string)
|
||||
a_output.put_string (body)
|
||||
a_output.flush
|
||||
end
|
||||
|
||||
;note
|
||||
|
||||
@@ -35,7 +35,7 @@ feature -- Factory
|
||||
Result.execution_variables.set_variable (request_count.out, "REQUEST_COUNT")
|
||||
end
|
||||
|
||||
new_response (a_output: GW_OUTPUT_STREAM): GW_IN_MEMORY_RESPONSE
|
||||
new_response (req: GW_REQUEST; a_output: GW_OUTPUT_STREAM): GW_IN_MEMORY_RESPONSE
|
||||
do
|
||||
create {GW_IN_MEMORY_RESPONSE} Result.make
|
||||
end
|
||||
|
||||
@@ -9,9 +9,6 @@ class
|
||||
|
||||
inherit
|
||||
GW_RESPONSE
|
||||
redefine
|
||||
commit
|
||||
end
|
||||
|
||||
create {GW_APPLICATION}
|
||||
make
|
||||
@@ -33,15 +30,7 @@ feature {NONE} -- Initialization
|
||||
|
||||
buffer_count: INTEGER
|
||||
|
||||
feature -- Status setting
|
||||
|
||||
set_status_code (c: INTEGER)
|
||||
-- Set the status code of the response
|
||||
do
|
||||
header.put_status (c)
|
||||
end
|
||||
|
||||
feature -- Output operation
|
||||
feature {NONE} -- Core output operation
|
||||
|
||||
write (s: STRING)
|
||||
-- Send the content of `s'
|
||||
@@ -71,6 +60,33 @@ feature -- Output operation
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Status setting
|
||||
|
||||
is_status_set: BOOLEAN
|
||||
do
|
||||
Result := status_code /= 0
|
||||
end
|
||||
|
||||
set_status_code (a_code: INTEGER)
|
||||
-- Set response status code
|
||||
-- Should be done before sending any data back to the client
|
||||
do
|
||||
status_code := a_code
|
||||
output.put_status_line (status_code)
|
||||
--| We could also just append it to the `buffer'
|
||||
end
|
||||
|
||||
status_code: INTEGER
|
||||
-- Response status
|
||||
|
||||
feature -- Output operation
|
||||
|
||||
write_string (s: STRING)
|
||||
-- Send the string `s'
|
||||
do
|
||||
write (s)
|
||||
end
|
||||
|
||||
write_file_content (fn: STRING)
|
||||
-- Send the content of file `fn'
|
||||
local
|
||||
@@ -90,12 +106,31 @@ feature -- Output operation
|
||||
end
|
||||
end
|
||||
|
||||
write_header_object (h: GW_HEADER)
|
||||
-- Send `header' to `output'.
|
||||
feature -- Header output operation
|
||||
|
||||
write_header (a_status_code: INTEGER; a_headers: detachable ARRAY [TUPLE [key: STRING; value: STRING]])
|
||||
-- Send headers with status `a_status', and headers from `a_headers'
|
||||
local
|
||||
h: GW_HEADER
|
||||
i,n: INTEGER
|
||||
do
|
||||
header := h
|
||||
set_status_code (a_status_code)
|
||||
create h.make
|
||||
if a_headers /= Void then
|
||||
from
|
||||
i := a_headers.lower
|
||||
n := a_headers.upper
|
||||
until
|
||||
i > n
|
||||
loop
|
||||
h.put_header_key_value (a_headers[i].key, a_headers[i].value)
|
||||
i := i + 1
|
||||
end
|
||||
end
|
||||
write (h.string)
|
||||
end
|
||||
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
flush_buffer
|
||||
@@ -113,7 +148,7 @@ feature {GW_APPLICATION} -- Commit
|
||||
commit (a_output: GW_OUTPUT_STREAM)
|
||||
do
|
||||
flush_buffer
|
||||
Precursor (a_output)
|
||||
a_output.flush
|
||||
end
|
||||
|
||||
;note
|
||||
|
||||
@@ -35,13 +35,6 @@ feature -- Access
|
||||
headers: LIST [STRING]
|
||||
-- Header's lines
|
||||
|
||||
send_to (res: GW_RESPONSE)
|
||||
-- Send Current string representation to `a_output'
|
||||
do
|
||||
res.write_string (string)
|
||||
--| Could be optimized
|
||||
end
|
||||
|
||||
string: STRING
|
||||
-- String representation of the headers
|
||||
local
|
||||
|
||||
@@ -70,14 +70,6 @@ feature -- Output operation
|
||||
|
||||
feature -- Header output operation
|
||||
|
||||
write_header_object (h: GW_HEADER)
|
||||
-- Send `header' to `output'.
|
||||
require
|
||||
status_set: is_status_set
|
||||
do
|
||||
h.send_to (Current)
|
||||
end
|
||||
|
||||
write_header (a_status_code: INTEGER; a_headers: detachable ARRAY [TUPLE [key: STRING; value: STRING]])
|
||||
-- Send headers with status `a_status', and headers from `a_headers'
|
||||
local
|
||||
@@ -97,7 +89,7 @@ feature -- Header output operation
|
||||
i := i + 1
|
||||
end
|
||||
end
|
||||
write_header_object (h)
|
||||
write (h.string)
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation: Access
|
||||
|
||||
Reference in New Issue
Block a user