Added WSF_REQUEST.read_input_data_into_file (FILE)
This commit is contained in:
@@ -151,14 +151,14 @@ feature -- Element change
|
|||||||
|
|
||||||
set_upload_data (a_data: like upload_data)
|
set_upload_data (a_data: like upload_data)
|
||||||
require
|
require
|
||||||
has_no_upload_data: not has_upload_data
|
has_no_upload_data: a_data /= Void implies not has_upload_data
|
||||||
do
|
do
|
||||||
upload_data := a_data
|
upload_data := a_data
|
||||||
end
|
end
|
||||||
|
|
||||||
set_upload_filename (a_fn: like upload_filename)
|
set_upload_filename (a_fn: like upload_filename)
|
||||||
require
|
require
|
||||||
has_no_upload_filename: not has_upload_filename
|
has_no_upload_filename: a_fn /= Void implies not has_upload_filename
|
||||||
do
|
do
|
||||||
upload_filename := a_fn
|
upload_filename := a_fn
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -123,6 +123,46 @@ feature -- Input
|
|||||||
character_read: not end_of_input implies last_appended_count > 0
|
character_read: not end_of_input implies last_appended_count > 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
append_to_file (a_file: FILE; nb: INTEGER)
|
||||||
|
-- Append at most `nb' characters read from input stream
|
||||||
|
-- to `a_file'
|
||||||
|
-- Set `last_appended_count' to 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_file_attached: a_file /= Void
|
||||||
|
a_file_is_open_write: a_file.is_open_write
|
||||||
|
nb_large_enough: nb > 0
|
||||||
|
local
|
||||||
|
i, end_pos: INTEGER
|
||||||
|
l_count: INTEGER
|
||||||
|
do
|
||||||
|
from
|
||||||
|
i := a_string.count + 1
|
||||||
|
end_pos := i + nb - 1
|
||||||
|
until
|
||||||
|
i > end_pos
|
||||||
|
loop
|
||||||
|
read_character
|
||||||
|
a_file.put_character (last_character)
|
||||||
|
l_count := l_count + 1
|
||||||
|
if end_of_input then
|
||||||
|
-- Jump out of the loop.
|
||||||
|
i := end_pos + 1
|
||||||
|
else
|
||||||
|
i := i + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
last_appended_count := l_count
|
||||||
|
ensure
|
||||||
|
nb_char_read_large_enough: last_appended_count >= 0
|
||||||
|
nb_char_read_small_enough: last_appended_count <= nb
|
||||||
|
character_read: not end_of_input implies last_appended_count > 0
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Access
|
feature -- Access
|
||||||
|
|
||||||
last_string: STRING_8
|
last_string: STRING_8
|
||||||
|
|||||||
@@ -208,7 +208,7 @@ feature -- Access: Input
|
|||||||
from
|
from
|
||||||
n := 8_192
|
n := 8_192
|
||||||
until
|
until
|
||||||
n = 0
|
n = 0 or l_input.end_of_input
|
||||||
loop
|
loop
|
||||||
l_input.append_to_string (buf, n)
|
l_input.append_to_string (buf, n)
|
||||||
if l_input.last_appended_count < n then
|
if l_input.last_appended_count < n then
|
||||||
@@ -229,6 +229,47 @@ feature -- Access: Input
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
read_input_data_into_file (a_file: FILE)
|
||||||
|
-- retrieve the content from the `input' stream into `s'
|
||||||
|
-- warning: if the input data has already been retrieved
|
||||||
|
-- you might not get anything
|
||||||
|
require
|
||||||
|
a_file_is_open_write: a_file.is_open_write
|
||||||
|
local
|
||||||
|
s: STRING
|
||||||
|
l_input: WGI_INPUT_STREAM
|
||||||
|
l_raw_data: detachable STRING_8
|
||||||
|
n: INTEGER
|
||||||
|
do
|
||||||
|
if raw_input_data_recorded and then attached raw_input_data as d then
|
||||||
|
a_file.put_string (d)
|
||||||
|
else
|
||||||
|
if raw_input_data_recorded then
|
||||||
|
create l_raw_data.make_empty
|
||||||
|
end
|
||||||
|
l_input := input
|
||||||
|
from
|
||||||
|
n := 8_192
|
||||||
|
create s.make (n)
|
||||||
|
until
|
||||||
|
n = 0 or l_input.end_of_input
|
||||||
|
loop
|
||||||
|
l_input.append_to_string (s, n)
|
||||||
|
a_file.put_string (s)
|
||||||
|
if l_raw_data /= Void then
|
||||||
|
l_raw_data.append (s)
|
||||||
|
end
|
||||||
|
s.wipe_out
|
||||||
|
if l_input.last_appended_count < n then
|
||||||
|
n := 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if l_raw_data /= Void then
|
||||||
|
set_raw_input_data (l_raw_data)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Helper
|
feature -- Helper
|
||||||
|
|
||||||
is_request_method (m: READABLE_STRING_GENERAL): BOOLEAN
|
is_request_method (m: READABLE_STRING_GENERAL): BOOLEAN
|
||||||
|
|||||||
Reference in New Issue
Block a user