Changed the WGI_INPUT_STREAM and WGI_OUTPUT_STREAM interfaces
main changes for existing code `read_stream' is renamed `read_string'
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
<?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="restbucks" uuid="7C9887BD-4AE4-47F2-A0AA-4BBB6736D433">
|
<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="restbucks" uuid="7C9887BD-4AE4-47F2-A0AA-4BBB6736D433">
|
||||||
<target name="restbucks">
|
<target name="restbucks">
|
||||||
<root class="RESTBUCKS_SERVER" feature="make"/>
|
<root class="RESTBUCKS_SERVER" feature="make"/>
|
||||||
<file_rule>
|
<file_rule>
|
||||||
@@ -7,20 +7,21 @@
|
|||||||
<exclude>/\.git$</exclude>
|
<exclude>/\.git$</exclude>
|
||||||
<exclude>/\.svn$</exclude>
|
<exclude>/\.svn$</exclude>
|
||||||
</file_rule>
|
</file_rule>
|
||||||
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="provisional">
|
<option debug="true" warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="provisional">
|
||||||
|
<debug name="nino" enabled="true"/>
|
||||||
<assertions precondition="true" postcondition="true" invariant="true" supplier_precondition="true"/>
|
<assertions precondition="true" postcondition="true" invariant="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="connector_nino" location="..\..\library\server\ewsgi\connectors\nino\nino-safe.ecf" readonly="false"/>
|
<library name="connector_nino" location="..\..\library\server\ewsgi\connectors\nino\nino-safe.ecf" readonly="false"/>
|
||||||
<library name="default_nino" location="..\..\library\server\wsf\default\nino-safe.ecf" readonly="false"/>
|
<library name="default_nino" location="..\..\library\server\wsf\default\nino-safe.ecf" readonly="false"/>
|
||||||
<library name="encoder" location="..\..\library\text\encoder\encoder-safe.ecf" readonly="false"/>
|
|
||||||
<library name="wsf" location="..\..\library\server\wsf\wsf-safe.ecf" readonly="false"/>
|
|
||||||
<library name="json" location="..\..\ext\text\json\library\json-safe.ecf" readonly="false"/>
|
|
||||||
<library name="http" location="..\..\library\protocol\http\http-safe.ecf" readonly="false"/>
|
|
||||||
<library name="eel" location="..\..\library\crypto\eel\eel-safe.ecf" readonly="false"/>
|
<library name="eel" location="..\..\library\crypto\eel\eel-safe.ecf" readonly="false"/>
|
||||||
|
<library name="encoder" location="..\..\library\text\encoder\encoder-safe.ecf" readonly="false"/>
|
||||||
|
<library name="http" location="..\..\library\protocol\http\http-safe.ecf" readonly="false"/>
|
||||||
|
<library name="json" location="..\..\ext\text\json\library\json-safe.ecf" readonly="false"/>
|
||||||
<library name="router" location="..\..\library\server\request\router\router-safe.ecf" readonly="false"/>
|
<library name="router" location="..\..\library\server\request\router\router-safe.ecf" readonly="false"/>
|
||||||
<library name="uri_template" location="..\..\library\protocol\uri_template\uri_template-safe.ecf" readonly="false"/>
|
<library name="uri_template" location="..\..\library\protocol\uri_template\uri_template-safe.ecf" readonly="false"/>
|
||||||
|
<library name="wsf" location="..\..\library\server\wsf\wsf-safe.ecf" readonly="false"/>
|
||||||
<cluster name="src" location="src\" recursive="true"/>
|
<cluster name="src" location="src\" recursive="true"/>
|
||||||
</target>
|
</target>
|
||||||
</system>
|
</system>
|
||||||
|
|||||||
@@ -111,7 +111,7 @@ feature -- HTTP Methods
|
|||||||
l_post: STRING
|
l_post: STRING
|
||||||
l_order : detachable ORDER
|
l_order : detachable ORDER
|
||||||
do
|
do
|
||||||
req.input.read_stream (req.content_length_value.as_integer_32)
|
req.input.read_string (req.content_length_value.as_integer_32)
|
||||||
l_post := req.input.last_string
|
l_post := req.input.last_string
|
||||||
l_order := extract_order_request(l_post)
|
l_order := extract_order_request(l_post)
|
||||||
if l_order /= Void and then db_access.orders.has_key (l_order.id) then
|
if l_order /= Void and then db_access.orders.has_key (l_order.id) then
|
||||||
@@ -229,7 +229,7 @@ feature -- HTTP Methods
|
|||||||
local
|
local
|
||||||
l_post: STRING
|
l_post: STRING
|
||||||
do
|
do
|
||||||
req.input.read_stream (req.content_length_value.as_integer_32)
|
req.input.read_string (req.content_length_value.as_integer_32)
|
||||||
l_post := req.input.last_string
|
l_post := req.input.last_string
|
||||||
if attached extract_order_request (l_post) as l_order then
|
if attached extract_order_request (l_post) as l_order then
|
||||||
save_order (l_order)
|
save_order (l_order)
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ feature -- Execution
|
|||||||
l_api_doc : STRING
|
l_api_doc : STRING
|
||||||
do
|
do
|
||||||
if req.content_length_value > 0 then
|
if req.content_length_value > 0 then
|
||||||
req.input.read_stream (req.content_length_value.as_integer_32)
|
req.input.read_string (req.content_length_value.as_integer_32)
|
||||||
end
|
end
|
||||||
create h.make
|
create h.make
|
||||||
h.put_status ({HTTP_STATUS_CODE}.method_not_allowed)
|
h.put_status ({HTTP_STATUS_CODE}.method_not_allowed)
|
||||||
|
|||||||
Submodule ext/server/nino updated: abd67c8caa...9f2abab670
@@ -10,10 +10,15 @@ class
|
|||||||
|
|
||||||
inherit
|
inherit
|
||||||
WGI_INPUT_STREAM
|
WGI_INPUT_STREAM
|
||||||
|
undefine
|
||||||
|
read_to_string
|
||||||
|
end
|
||||||
|
|
||||||
CONSOLE
|
CONSOLE
|
||||||
rename
|
rename
|
||||||
make as console_make
|
make as console_make,
|
||||||
|
read_stream as read_string,
|
||||||
|
end_of_file as end_of_input
|
||||||
end
|
end
|
||||||
|
|
||||||
create
|
create
|
||||||
|
|||||||
@@ -10,9 +10,6 @@ class
|
|||||||
|
|
||||||
inherit
|
inherit
|
||||||
WGI_OUTPUT_STREAM
|
WGI_OUTPUT_STREAM
|
||||||
undefine
|
|
||||||
flush
|
|
||||||
end
|
|
||||||
|
|
||||||
CONSOLE
|
CONSOLE
|
||||||
rename
|
rename
|
||||||
|
|||||||
@@ -10,8 +10,8 @@
|
|||||||
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all">
|
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all">
|
||||||
</option>
|
</option>
|
||||||
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
|
||||||
<library name="connector" location="..\connector-safe.ecf" readonly="false"/>
|
<library name="connector" location="..\connector-safe.ecf"/>
|
||||||
<library name="ewsgi" location="..\..\ewsgi-safe.ecf" readonly="false"/>
|
<library name="ewsgi" location="..\..\ewsgi-safe.ecf"/>
|
||||||
<library name="libfcgi" location="..\..\..\libfcgi\libfcgi-safe.ecf"/>
|
<library name="libfcgi" location="..\..\..\libfcgi\libfcgi-safe.ecf"/>
|
||||||
<library name="http" location="..\..\..\..\protocol\http\http-safe.ecf"/>
|
<library name="http" location="..\..\..\..\protocol\http\http-safe.ecf"/>
|
||||||
<cluster name="src" location=".\" recursive="true"/>
|
<cluster name="src" location=".\" recursive="true"/>
|
||||||
|
|||||||
@@ -32,9 +32,38 @@ feature {NONE} -- Initialization
|
|||||||
create last_string.make_empty
|
create last_string.make_empty
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Basic operation
|
feature -- Status report
|
||||||
|
|
||||||
read_stream (nb_char: INTEGER)
|
is_open_read: BOOLEAN
|
||||||
|
-- Can items be read from input stream?
|
||||||
|
do
|
||||||
|
Result := True
|
||||||
|
end
|
||||||
|
|
||||||
|
end_of_input: BOOLEAN
|
||||||
|
-- Has the end of input stream been reached?
|
||||||
|
do
|
||||||
|
Result := fcgi.fcgi_end_of_input
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Input
|
||||||
|
|
||||||
|
read_character
|
||||||
|
-- Read the next character in input stream.
|
||||||
|
-- Make the result available in `last_character'.
|
||||||
|
local
|
||||||
|
s: STRING
|
||||||
|
do
|
||||||
|
create s.make (1)
|
||||||
|
fcgi.fill_string_from_stdin (s, 1)
|
||||||
|
if s.count >= 1 then
|
||||||
|
last_character := s.item (1)
|
||||||
|
else
|
||||||
|
last_character := '%U'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
read_string (nb_char: INTEGER)
|
||||||
-- Read a string of at most `nb_char' bound characters
|
-- Read a string of at most `nb_char' bound characters
|
||||||
-- or until end of file.
|
-- or until end of file.
|
||||||
-- Make result available in `last_string'.
|
-- Make result available in `last_string'.
|
||||||
@@ -47,6 +76,9 @@ feature -- Access
|
|||||||
last_string: STRING
|
last_string: STRING
|
||||||
-- Last string read
|
-- Last string read
|
||||||
|
|
||||||
|
last_character: CHARACTER_8
|
||||||
|
-- Last item read
|
||||||
|
|
||||||
feature {NONE} -- Implementation
|
feature {NONE} -- Implementation
|
||||||
|
|
||||||
fcgi: FCGI;
|
fcgi: FCGI;
|
||||||
|
|||||||
@@ -28,6 +28,14 @@ feature {NONE} -- Initialization
|
|||||||
fcgi := a_fcgi
|
fcgi := a_fcgi
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature -- Status report
|
||||||
|
|
||||||
|
is_open_write: BOOLEAN
|
||||||
|
-- Can items be written to output stream?
|
||||||
|
do
|
||||||
|
Result := True
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Status writing
|
feature -- Status writing
|
||||||
|
|
||||||
put_status_line (a_code: INTEGER)
|
put_status_line (a_code: INTEGER)
|
||||||
@@ -56,6 +64,13 @@ feature -- Basic operation
|
|||||||
fcgi.put_string (s)
|
fcgi.put_string (s)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature -- Basic operations
|
||||||
|
|
||||||
|
flush
|
||||||
|
-- Flush buffered data to disk.
|
||||||
|
do
|
||||||
|
end
|
||||||
|
|
||||||
feature {NONE} -- Implementation
|
feature {NONE} -- Implementation
|
||||||
|
|
||||||
fcgi: FCGI
|
fcgi: FCGI
|
||||||
|
|||||||
@@ -104,15 +104,15 @@ feature -- Server
|
|||||||
server.setup (l_http_handler)
|
server.setup (l_http_handler)
|
||||||
end
|
end
|
||||||
|
|
||||||
process_request (env: HASH_TABLE [STRING, STRING]; a_headers_text: STRING; a_input: HTTP_INPUT_STREAM; a_output: HTTP_OUTPUT_STREAM)
|
process_request (env: HASH_TABLE [STRING, STRING]; a_headers_text: STRING; a_socket: TCP_STREAM_SOCKET)
|
||||||
local
|
local
|
||||||
req: WGI_REQUEST_FROM_TABLE
|
req: WGI_REQUEST_FROM_TABLE
|
||||||
res: detachable WGI_RESPONSE_STREAM_BUFFER
|
res: detachable WGI_RESPONSE_STREAM_BUFFER
|
||||||
rescued: BOOLEAN
|
rescued: BOOLEAN
|
||||||
do
|
do
|
||||||
if not rescued then
|
if not rescued then
|
||||||
create req.make (env, create {WGI_NINO_INPUT_STREAM}.make (a_input))
|
create req.make (env, create {WGI_NINO_INPUT_STREAM}.make (a_socket))
|
||||||
create res.make (create {WGI_NINO_OUTPUT_STREAM}.make (a_output))
|
create res.make (create {WGI_NINO_OUTPUT_STREAM}.make (a_socket))
|
||||||
req.set_meta_string_variable ("RAW_HEADER_DATA", a_headers_text)
|
req.set_meta_string_variable ("RAW_HEADER_DATA", a_headers_text)
|
||||||
application.execute (req, res)
|
application.execute (req, res)
|
||||||
else
|
else
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ feature -- Element change
|
|||||||
|
|
||||||
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
|
||||||
env, vars: HASH_TABLE [STRING, STRING]
|
env, vars: HASH_TABLE [STRING, STRING]
|
||||||
@@ -161,16 +161,22 @@ feature -- Request processing
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
callback.process_request (env, a_handler.request_header, a_input, a_output)
|
callback.process_request (env, a_handler.request_header, a_socket)
|
||||||
end
|
end
|
||||||
|
|
||||||
add_environment_variable (a_value: detachable STRING; a_var_name: STRING; env: HASH_TABLE [STRING, STRING])
|
add_environment_variable (a_value: detachable STRING; a_var_name: STRING; env: HASH_TABLE [STRING, STRING])
|
||||||
-- Add variable `a_var_name => a_value' to `env'
|
-- Add variable `a_var_name => a_value' to `env'
|
||||||
do
|
do
|
||||||
if a_value /= Void then
|
if a_value /= Void then
|
||||||
|
if env.has_key (a_var_name) and then attached env.found_item as l_existing_value then
|
||||||
|
--| Check http://www.ietf.org/rfc/rfc3875 4.1.18
|
||||||
|
check find_proper_rewrite_for_same_header: False end
|
||||||
|
env.force (l_existing_value + " " + a_value, a_var_name)
|
||||||
|
else
|
||||||
env.force (a_value, a_var_name)
|
env.force (a_value, a_var_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
note
|
note
|
||||||
copyright: "2011-2011, Eiffel Software and others"
|
copyright: "2011-2011, Eiffel Software and others"
|
||||||
|
|||||||
@@ -16,36 +16,71 @@ create
|
|||||||
|
|
||||||
feature {NONE} -- Initialization
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make (a_nino_input: like nino_input)
|
make (a_source: like source)
|
||||||
do
|
do
|
||||||
create last_string.make_empty
|
create last_string.make_empty
|
||||||
set_nino_input (a_nino_input)
|
set_source (a_source)
|
||||||
end
|
end
|
||||||
|
|
||||||
feature {WGI_NINO_CONNECTOR, WGI_APPLICATION} -- Nino
|
feature {WGI_NINO_CONNECTOR, WGI_APPLICATION} -- Nino
|
||||||
|
|
||||||
set_nino_input (i: like nino_input)
|
set_source (i: like source)
|
||||||
do
|
do
|
||||||
nino_input := i
|
source := i
|
||||||
end
|
end
|
||||||
|
|
||||||
nino_input: HTTP_INPUT_STREAM
|
source: TCP_STREAM_SOCKET
|
||||||
|
|
||||||
feature -- Basic operation
|
feature -- Input
|
||||||
|
|
||||||
read_stream (nb_char: INTEGER)
|
read_character
|
||||||
-- Read a string of at most `nb_char' bound characters
|
-- Read the next character in input stream.
|
||||||
-- or until end of file.
|
-- Make the result available in `last_character'.
|
||||||
-- Make result available in `last_string'.
|
local
|
||||||
|
s: detachable STRING
|
||||||
do
|
do
|
||||||
nino_input.read_stream (nb_char)
|
if source.socket_ok then
|
||||||
last_string := nino_input.last_string
|
source.read_character
|
||||||
|
last_character := source.last_character
|
||||||
|
else
|
||||||
|
last_character := '%U'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
read_string (nb: INTEGER)
|
||||||
|
do
|
||||||
|
last_string.wipe_out
|
||||||
|
if source.socket_ok then
|
||||||
|
source.read_stream_thread_aware (nb)
|
||||||
|
last_string.append_string (source.last_string)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Access
|
feature -- Access
|
||||||
|
|
||||||
last_string: STRING
|
last_string: STRING_8
|
||||||
-- Last string read
|
-- Last string read
|
||||||
|
-- (Note: this query always return the same object.
|
||||||
|
-- Therefore a clone should be used if the result
|
||||||
|
-- is to be kept beyond the next call to this feature.
|
||||||
|
-- However `last_string' is not shared between input objects.)
|
||||||
|
|
||||||
|
last_character: CHARACTER_8
|
||||||
|
-- Last item read
|
||||||
|
|
||||||
|
feature -- Status report
|
||||||
|
|
||||||
|
is_open_read: BOOLEAN
|
||||||
|
-- Can items be read from input stream?
|
||||||
|
do
|
||||||
|
Result := source.is_open_read
|
||||||
|
end
|
||||||
|
|
||||||
|
end_of_input: BOOLEAN
|
||||||
|
-- Has the end of input stream been reached?
|
||||||
|
do
|
||||||
|
Result := source.ready_for_reading
|
||||||
|
end
|
||||||
|
|
||||||
;note
|
;note
|
||||||
copyright: "2011-2011, Eiffel Software and others"
|
copyright: "2011-2011, Eiffel Software and others"
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ class
|
|||||||
|
|
||||||
inherit
|
inherit
|
||||||
WGI_OUTPUT_STREAM
|
WGI_OUTPUT_STREAM
|
||||||
|
redefine
|
||||||
|
put_character_8
|
||||||
|
end
|
||||||
|
|
||||||
HTTP_STATUS_CODE_MESSAGES
|
HTTP_STATUS_CODE_MESSAGES
|
||||||
export
|
export
|
||||||
@@ -21,19 +24,19 @@ create
|
|||||||
|
|
||||||
feature {NONE} -- Initialization
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
make (a_nino_output: like nino_output)
|
make (a_target: like target)
|
||||||
do
|
do
|
||||||
set_nino_output (a_nino_output)
|
set_target (a_target)
|
||||||
end
|
end
|
||||||
|
|
||||||
feature {WGI_NINO_CONNECTOR, WGI_APPLICATION} -- Nino
|
feature {WGI_NINO_CONNECTOR, WGI_APPLICATION} -- Nino
|
||||||
|
|
||||||
set_nino_output (o: like nino_output)
|
set_target (o: like target)
|
||||||
do
|
do
|
||||||
nino_output := o
|
target := o
|
||||||
end
|
end
|
||||||
|
|
||||||
nino_output: HTTP_OUTPUT_STREAM
|
target: TCP_STREAM_SOCKET
|
||||||
|
|
||||||
feature -- Status writing
|
feature -- Status writing
|
||||||
|
|
||||||
@@ -55,15 +58,31 @@ feature -- Status writing
|
|||||||
put_header_line (s)
|
put_header_line (s)
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Basic operation
|
feature -- Output
|
||||||
|
|
||||||
put_string (s: STRING_8)
|
put_string (s: STRING_8)
|
||||||
-- Send `s' to http client
|
-- Send `s' to http client
|
||||||
do
|
do
|
||||||
debug ("nino")
|
target.put_string (s)
|
||||||
print (s)
|
|
||||||
end
|
end
|
||||||
nino_output.put_string (s)
|
|
||||||
|
put_character_8 (c: CHARACTER_8)
|
||||||
|
do
|
||||||
|
target.put_character (c)
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Status report
|
||||||
|
|
||||||
|
is_open_write: BOOLEAN
|
||||||
|
-- Can items be written to output stream?
|
||||||
|
do
|
||||||
|
Result := target.is_open_write
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Basic operations
|
||||||
|
|
||||||
|
flush
|
||||||
|
do
|
||||||
end
|
end
|
||||||
|
|
||||||
note
|
note
|
||||||
|
|||||||
@@ -336,7 +336,7 @@ feature {NONE} -- I/O: implementation
|
|||||||
read_input (nb: INTEGER)
|
read_input (nb: INTEGER)
|
||||||
-- Read `nb' bytes from `input'
|
-- Read `nb' bytes from `input'
|
||||||
do
|
do
|
||||||
input.read_stream (nb)
|
input.read_string (nb)
|
||||||
end
|
end
|
||||||
|
|
||||||
last_input_string: STRING
|
last_input_string: STRING
|
||||||
|
|||||||
@@ -11,21 +11,108 @@ note
|
|||||||
deferred class
|
deferred class
|
||||||
WGI_INPUT_STREAM
|
WGI_INPUT_STREAM
|
||||||
|
|
||||||
|
feature -- Input
|
||||||
|
|
||||||
|
read_character
|
||||||
|
-- Read the next character in input stream.
|
||||||
|
-- Make the result available in `last_character'.
|
||||||
|
require
|
||||||
|
is_open_read: is_open_read
|
||||||
|
not_end_of_input: not end_of_input
|
||||||
|
deferred
|
||||||
|
ensure
|
||||||
|
same_last_string_reference: last_string = old last_string
|
||||||
|
end
|
||||||
|
|
||||||
|
read_string (nb: INTEGER)
|
||||||
|
require
|
||||||
|
is_open_read: is_open_read
|
||||||
|
not_end_of_input: not end_of_input
|
||||||
|
nb_large_enough: nb > 0
|
||||||
|
deferred
|
||||||
|
ensure
|
||||||
|
last_string_count_small_enough: not end_of_input implies last_string.count <= nb
|
||||||
|
character_read: not end_of_input implies last_string.count > 0
|
||||||
|
same_last_string_reference: last_string = old last_string
|
||||||
|
end
|
||||||
|
|
||||||
|
read_to_string (a_string: STRING; pos, nb: INTEGER): INTEGER
|
||||||
|
-- Fill `a_string', starting at position `pos', with
|
||||||
|
-- at most `nb' characters read from input stream.
|
||||||
|
-- Return the number of characters actually read.
|
||||||
|
-- (Note that even if at least `nb' characters are available
|
||||||
|
-- in the input stream, there is no guarantee that they
|
||||||
|
-- will all be read.)
|
||||||
|
require
|
||||||
|
is_open_read: is_open_read
|
||||||
|
not_end_of_input: not end_of_input
|
||||||
|
a_string_not_void: a_string /= Void
|
||||||
|
valid_position: a_string.valid_index (pos)
|
||||||
|
nb_large_enough: nb > 0
|
||||||
|
nb_small_enough: nb <= a_string.count - pos + 1
|
||||||
|
local
|
||||||
|
i, end_pos: INTEGER
|
||||||
|
do
|
||||||
|
end_pos := pos + nb - 1
|
||||||
|
from
|
||||||
|
i := pos
|
||||||
|
until
|
||||||
|
i > end_pos
|
||||||
|
loop
|
||||||
|
read_character
|
||||||
|
if not end_of_input then
|
||||||
|
a_string.put (last_character, i)
|
||||||
|
i := i + 1
|
||||||
|
else
|
||||||
|
Result := i - pos - nb
|
||||||
|
-- Jump out of the loop.
|
||||||
|
i := end_pos + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Result := Result + i - pos
|
||||||
|
ensure
|
||||||
|
nb_char_read_large_enough: Result >= 0
|
||||||
|
nb_char_read_small_enough: Result <= nb
|
||||||
|
character_read: not end_of_input implies Result > 0
|
||||||
|
same_last_string_reference: last_string = old last_string
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Access
|
feature -- Access
|
||||||
|
|
||||||
last_string: STRING_8
|
last_string: STRING_8
|
||||||
-- Last read string from stream
|
-- Last string read
|
||||||
|
-- (Note: this query always return the same object.
|
||||||
|
-- Therefore a clone should be used if the result
|
||||||
|
-- is to be kept beyond the next call to this feature.
|
||||||
|
-- However `last_string' is not shared between file objects.)
|
||||||
|
require
|
||||||
|
is_open_read: is_open_read
|
||||||
|
not_end_of_input: not end_of_input
|
||||||
|
deferred
|
||||||
|
ensure
|
||||||
|
last_string_not_void: Result /= Void
|
||||||
|
end
|
||||||
|
|
||||||
|
last_character: CHARACTER_8
|
||||||
|
-- Last item read
|
||||||
|
require
|
||||||
|
is_open_read: is_open_read
|
||||||
|
not_end_of_input: not end_of_input
|
||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Basic operation
|
feature -- Status report
|
||||||
|
|
||||||
read_stream (n: INTEGER)
|
is_open_read: BOOLEAN
|
||||||
require
|
-- Can items be read from input stream?
|
||||||
n_positive: n > 0
|
deferred
|
||||||
|
end
|
||||||
|
|
||||||
|
end_of_input: BOOLEAN
|
||||||
|
-- Has the end of input stream been reached?
|
||||||
|
require
|
||||||
|
is_open_read: is_open_read
|
||||||
deferred
|
deferred
|
||||||
ensure
|
|
||||||
at_max_n: last_string.count <= n
|
|
||||||
end
|
end
|
||||||
|
|
||||||
note
|
note
|
||||||
|
|||||||
@@ -11,18 +11,70 @@ note
|
|||||||
deferred class
|
deferred class
|
||||||
WGI_OUTPUT_STREAM
|
WGI_OUTPUT_STREAM
|
||||||
|
|
||||||
feature -- Core operation
|
feature -- Output
|
||||||
|
|
||||||
put_string (s: STRING_8)
|
put_string (a_string: STRING_8)
|
||||||
-- Write `s' into the output stream
|
-- Write `a_string' to output stream.
|
||||||
require
|
require
|
||||||
s_not_empty: s /= Void and then not s.is_empty
|
is_open_write: is_open_write
|
||||||
|
a_string_not_void: a_string /= Void
|
||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
flush
|
put_substring (a_string: STRING; s, e: INTEGER)
|
||||||
-- Flush the output stream
|
-- Write substring of `a_string' between indexes
|
||||||
|
-- `s' and `e' to output stream.
|
||||||
|
--| Could be redefined for optimization
|
||||||
|
require
|
||||||
|
is_open_write: is_open_write
|
||||||
|
a_string_not_void: a_string /= Void
|
||||||
|
s_large_enough: s >= 1
|
||||||
|
e_small_enough: e <= a_string.count
|
||||||
|
valid_interval: s <= e + 1
|
||||||
do
|
do
|
||||||
|
if s <= e then
|
||||||
|
put_string (a_string.substring (s, e))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
put_character_8 (c: CHARACTER_8)
|
||||||
|
-- Write `c' to output stream.
|
||||||
|
--| Could be redefined for optimization
|
||||||
|
require
|
||||||
|
is_open_write: is_open_write
|
||||||
|
do
|
||||||
|
put_string (c.out)
|
||||||
|
end
|
||||||
|
|
||||||
|
put_file_content (fn: STRING)
|
||||||
|
-- Send the content of file `fn'
|
||||||
|
require
|
||||||
|
string_not_empty: not fn.is_empty
|
||||||
|
is_readable: (create {RAW_FILE}.make (fn)).is_readable
|
||||||
|
local
|
||||||
|
f: RAW_FILE
|
||||||
|
do
|
||||||
|
create f.make (fn)
|
||||||
|
check f.exists and then f.is_readable end
|
||||||
|
|
||||||
|
f.open_read
|
||||||
|
from
|
||||||
|
until
|
||||||
|
f.exhausted
|
||||||
|
loop
|
||||||
|
f.read_stream (4096)
|
||||||
|
put_string (f.last_string)
|
||||||
|
end
|
||||||
|
f.close
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Specific output
|
||||||
|
|
||||||
|
put_header_line (s: STRING)
|
||||||
|
-- Send `s' to http client as header line
|
||||||
|
do
|
||||||
|
put_string (s)
|
||||||
|
put_string ("%R%N")
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Status writing
|
feature -- Status writing
|
||||||
@@ -34,41 +86,20 @@ feature -- Status writing
|
|||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Basic operation
|
feature -- Status report
|
||||||
|
|
||||||
put_substring (s: STRING; start_index, end_index: INTEGER)
|
is_open_write: BOOLEAN
|
||||||
-- Write `s[start_index:end_index]' into the output stream
|
-- Can items be written to output stream?
|
||||||
--| Could be redefined for optimization
|
deferred
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Basic operations
|
||||||
|
|
||||||
|
flush
|
||||||
|
-- Flush buffered data to disk.
|
||||||
require
|
require
|
||||||
s_not_empty: s /= Void and then not s.is_empty
|
is_open_write: is_open_write
|
||||||
do
|
deferred
|
||||||
put_string (s.substring (start_index, end_index))
|
|
||||||
end
|
|
||||||
|
|
||||||
put_file_content (fn: STRING)
|
|
||||||
-- Send the content of file `fn'
|
|
||||||
local
|
|
||||||
f: RAW_FILE
|
|
||||||
do
|
|
||||||
create f.make (fn)
|
|
||||||
if f.exists and then f.is_readable then
|
|
||||||
f.open_read
|
|
||||||
from
|
|
||||||
until
|
|
||||||
f.exhausted
|
|
||||||
loop
|
|
||||||
f.read_stream (4096)
|
|
||||||
put_string (f.last_string)
|
|
||||||
end
|
|
||||||
f.close
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
put_header_line (s: STRING)
|
|
||||||
-- Send `s' to http client as header line
|
|
||||||
do
|
|
||||||
put_string (s)
|
|
||||||
put_string ("%R%N")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
note
|
note
|
||||||
|
|||||||
@@ -28,6 +28,11 @@ feature -- Access
|
|||||||
Result := fcgi.environ
|
Result := fcgi.environ
|
||||||
end
|
end
|
||||||
|
|
||||||
|
fcgi_end_of_input: BOOLEAN
|
||||||
|
do
|
||||||
|
Result := fcgi.feof (fcgi.stdin) = 0
|
||||||
|
end
|
||||||
|
|
||||||
-- updated_environ_variables: HASH_TABLE [STRING, STRING]
|
-- updated_environ_variables: HASH_TABLE [STRING, STRING]
|
||||||
-- local
|
-- local
|
||||||
---- n, l_size,
|
---- n, l_size,
|
||||||
|
|||||||
@@ -1495,8 +1495,8 @@ feature {NONE} -- Internal value
|
|||||||
until
|
until
|
||||||
n <= 0
|
n <= 0
|
||||||
loop
|
loop
|
||||||
read_input (n)
|
input.read_string (n)
|
||||||
t := last_input_string
|
t := input.last_string
|
||||||
Result.append_string (t)
|
Result.append_string (t)
|
||||||
if t.count < n then
|
if t.count < n then
|
||||||
n := 0
|
n := 0
|
||||||
@@ -1514,20 +1514,6 @@ feature {NONE} -- Internal value
|
|||||||
internal_cookies_table: detachable like cookies_table
|
internal_cookies_table: detachable like cookies_table
|
||||||
-- cached value for `cookies'
|
-- cached value for `cookies'
|
||||||
|
|
||||||
feature {NONE} -- I/O: implementation
|
|
||||||
|
|
||||||
read_input (nb: INTEGER)
|
|
||||||
-- Read `nb' bytes from `input'
|
|
||||||
do
|
|
||||||
input.read_stream (nb)
|
|
||||||
end
|
|
||||||
|
|
||||||
last_input_string: STRING
|
|
||||||
-- Last string read from `input'
|
|
||||||
do
|
|
||||||
Result := input.last_string
|
|
||||||
end
|
|
||||||
|
|
||||||
feature {NONE} -- Implementation
|
feature {NONE} -- Implementation
|
||||||
|
|
||||||
report_bad_request_error (a_message: detachable STRING)
|
report_bad_request_error (a_message: detachable STRING)
|
||||||
|
|||||||
@@ -6,4 +6,6 @@
|
|||||||
[$COMPILE_ALL_BASEDIR/ext]
|
[$COMPILE_ALL_BASEDIR/ext]
|
||||||
[$COMPILE_ALL_BASEDIR\ext]
|
[$COMPILE_ALL_BASEDIR\ext]
|
||||||
|
|
||||||
|
[regexp=(\\|\/)crypto$]
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user