Revisited WSF_REQUEST.read_input_data* functions:
- read_input_data_into_file now accepts a IO_MEDIUM argument instead of just FILE. - cleaned the implementation, and make sure that eventual `raw_input_data` is containing only the raw input data.
This commit is contained in:
@@ -261,10 +261,12 @@ feature -- Access: Input
|
|||||||
local
|
local
|
||||||
l_input: WGI_INPUT_STREAM
|
l_input: WGI_INPUT_STREAM
|
||||||
n: INTEGER
|
n: INTEGER
|
||||||
|
buf_initial_size: INTEGER
|
||||||
do
|
do
|
||||||
if raw_input_data_recorded and then attached raw_input_data as d then
|
if raw_input_data_recorded and then attached raw_input_data as d then
|
||||||
buf.append (d)
|
buf.append (d)
|
||||||
else
|
else
|
||||||
|
buf_initial_size := buf.count
|
||||||
l_input := input
|
l_input := input
|
||||||
if is_chunked_input then
|
if is_chunked_input then
|
||||||
from
|
from
|
||||||
@@ -286,59 +288,42 @@ feature -- Access: Input
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
if raw_input_data_recorded then
|
if raw_input_data_recorded then
|
||||||
set_raw_input_data (buf)
|
set_raw_input_data (buf.substring (buf_initial_size + 1, buf.count))
|
||||||
|
-- Only the input data! And differente reference.
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
read_input_data_into_file (a_file: FILE)
|
read_input_data_into_file (a_medium: IO_MEDIUM)
|
||||||
-- retrieve the content from the `input' stream into `s'
|
-- retrieve the content from the `input' stream into `s'
|
||||||
-- warning: if the input data has already been retrieved
|
-- warning: if the input data has already been retrieved
|
||||||
-- you might not get anything
|
-- you might not get anything
|
||||||
require
|
require
|
||||||
a_file_is_open_write: a_file.is_open_write
|
a_medium_is_open_write: a_medium.is_open_write
|
||||||
local
|
local
|
||||||
s: STRING
|
s: STRING
|
||||||
l_input: WGI_INPUT_STREAM
|
l_input: WGI_INPUT_STREAM
|
||||||
l_raw_data: detachable STRING_8
|
l_raw_data: detachable STRING_8
|
||||||
len: NATURAL_64
|
|
||||||
nb, l_step: INTEGER
|
nb, l_step: INTEGER
|
||||||
l_size: NATURAL_64
|
|
||||||
do
|
do
|
||||||
if raw_input_data_recorded and then attached raw_input_data as d then
|
if raw_input_data_recorded and then attached raw_input_data as d then
|
||||||
a_file.put_string (d)
|
a_medium.put_string (d)
|
||||||
else
|
else
|
||||||
if raw_input_data_recorded then
|
if raw_input_data_recorded then
|
||||||
create l_raw_data.make_empty
|
create l_raw_data.make_empty
|
||||||
end
|
end
|
||||||
l_input := input
|
l_input := input
|
||||||
len := content_length_value
|
|
||||||
|
|
||||||
debug ("wsf")
|
|
||||||
io.error.put_string (generator + ".read_input_data_into_file (a_file) content_length=" + len.out + "%N")
|
|
||||||
end
|
|
||||||
|
|
||||||
from
|
from
|
||||||
l_size := 0
|
|
||||||
l_step := 8_192
|
l_step := 8_192
|
||||||
create s.make (l_step)
|
create s.make (l_step)
|
||||||
until
|
until
|
||||||
l_step = 0 or l_input.end_of_input
|
l_step = 0 or l_input.end_of_input
|
||||||
loop
|
loop
|
||||||
if len < l_step.to_natural_64 then
|
|
||||||
l_step := len.to_integer_32
|
|
||||||
end
|
|
||||||
if l_step > 0 then
|
|
||||||
l_input.append_to_string (s, l_step)
|
l_input.append_to_string (s, l_step)
|
||||||
nb := l_input.last_appended_count
|
nb := l_input.last_appended_count
|
||||||
l_size := l_size + nb.to_natural_64
|
|
||||||
len := len - nb.to_natural_64
|
|
||||||
|
|
||||||
debug ("wsf")
|
a_medium.put_string (s)
|
||||||
io.error.put_string (" append (s, " + l_step.out + ") -> " + nb.out + " (" + l_size.out + " / "+ content_length_value.out + ")%N")
|
|
||||||
end
|
|
||||||
|
|
||||||
a_file.put_string (s)
|
|
||||||
if l_raw_data /= Void then
|
if l_raw_data /= Void then
|
||||||
l_raw_data.append (s)
|
l_raw_data.append (s)
|
||||||
end
|
end
|
||||||
@@ -347,12 +332,9 @@ feature -- Access: Input
|
|||||||
l_step := 0
|
l_step := 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
if attached {FILE} a_medium as f then
|
||||||
|
f.flush
|
||||||
end
|
end
|
||||||
a_file.flush
|
|
||||||
debug ("wsf")
|
|
||||||
io.error.put_string ("offset =" + len.out + "%N")
|
|
||||||
end
|
|
||||||
check got_all_data: len = 0 end
|
|
||||||
if l_raw_data /= Void then
|
if l_raw_data /= Void then
|
||||||
set_raw_input_data (l_raw_data)
|
set_raw_input_data (l_raw_data)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user