Fixed and improved {WSF_REQUEST}.read_input_data_into_file.
Now use the content length to get exactly what is expected from the request. Added check assertion
This commit is contained in:
@@ -270,7 +270,9 @@ feature -- Access: Input
|
|||||||
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
|
||||||
n: INTEGER
|
len: NATURAL_64
|
||||||
|
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_file.put_string (d)
|
||||||
@@ -279,22 +281,44 @@ feature -- Access: Input
|
|||||||
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
|
||||||
n := 8_192
|
l_size := 0
|
||||||
create s.make (n)
|
l_step := 8_192
|
||||||
|
create s.make (l_step)
|
||||||
until
|
until
|
||||||
n = 0 or l_input.end_of_input
|
l_step = 0 or l_input.end_of_input
|
||||||
loop
|
loop
|
||||||
l_input.append_to_string (s, n)
|
l_input.append_to_string (s, l_step)
|
||||||
|
nb := l_input.last_appended_count
|
||||||
|
l_size := l_size + nb.to_natural_64
|
||||||
|
len := len - nb.to_natural_64
|
||||||
|
|
||||||
|
debug ("wsf")
|
||||||
|
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)
|
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
|
||||||
s.wipe_out
|
s.wipe_out
|
||||||
if l_input.last_appended_count < n then
|
if nb < l_step then
|
||||||
n := 0
|
l_step := 0
|
||||||
|
elseif len < l_step.to_natural_64 then
|
||||||
|
l_step := len.to_integer_32
|
||||||
end
|
end
|
||||||
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