Fixed an issue with one short chunk and empty trailer
issue#81
This commit is contained in:
@@ -20,8 +20,9 @@ feature {NONE} -- Initialization
|
|||||||
res.set_post_commit_action (agent commit)
|
res.set_post_commit_action (agent commit)
|
||||||
end
|
end
|
||||||
|
|
||||||
wgi_response: WGI_RESPONSE
|
feature -- Access
|
||||||
|
|
||||||
|
wgi_response: WGI_RESPONSE
|
||||||
|
|
||||||
feature {WGI_FILTER_RESPONSE} -- Change
|
feature {WGI_FILTER_RESPONSE} -- Change
|
||||||
|
|
||||||
|
|||||||
@@ -9,6 +9,9 @@ class
|
|||||||
|
|
||||||
inherit
|
inherit
|
||||||
WGI_INPUT_STREAM
|
WGI_INPUT_STREAM
|
||||||
|
redefine
|
||||||
|
last_character_available
|
||||||
|
end
|
||||||
|
|
||||||
create
|
create
|
||||||
make
|
make
|
||||||
@@ -36,11 +39,17 @@ feature -- Input
|
|||||||
index := index + 1
|
index := index + 1
|
||||||
if index > chunk_upper then
|
if index > chunk_upper then
|
||||||
read_chunk_block
|
read_chunk_block
|
||||||
if last_chunk_data = Void then
|
if
|
||||||
|
last_chunk_size = 0
|
||||||
|
then
|
||||||
read_trailer_and_crlf
|
read_trailer_and_crlf
|
||||||
|
last_character := '%U'
|
||||||
|
else
|
||||||
|
last_character := last_chunk_data.item (index)
|
||||||
end
|
end
|
||||||
|
else
|
||||||
|
last_character := last_chunk_data.item (index)
|
||||||
end
|
end
|
||||||
last_character := last_chunk_data.item (index)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
read_string (nb: INTEGER)
|
read_string (nb: INTEGER)
|
||||||
@@ -54,7 +63,7 @@ feature -- Input
|
|||||||
i: like index
|
i: like index
|
||||||
do
|
do
|
||||||
last_string.wipe_out
|
last_string.wipe_out
|
||||||
if last_trailer /= Void then
|
if is_trailer_reached then
|
||||||
-- trailer already reached, no more data
|
-- trailer already reached, no more data
|
||||||
check input.end_of_input end
|
check input.end_of_input end
|
||||||
else
|
else
|
||||||
@@ -103,6 +112,12 @@ feature -- Access
|
|||||||
last_character: CHARACTER_8
|
last_character: CHARACTER_8
|
||||||
-- Last item read.
|
-- Last item read.
|
||||||
|
|
||||||
|
last_character_available: BOOLEAN
|
||||||
|
-- <Precursor>
|
||||||
|
do
|
||||||
|
Result := not is_trailer_reached
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Access: chunk
|
feature -- Access: chunk
|
||||||
|
|
||||||
last_chunk_size: INTEGER
|
last_chunk_size: INTEGER
|
||||||
@@ -142,7 +157,13 @@ feature -- Status report
|
|||||||
end_of_input: BOOLEAN
|
end_of_input: BOOLEAN
|
||||||
-- Has the end of input stream been reached?
|
-- Has the end of input stream been reached?
|
||||||
do
|
do
|
||||||
Result := input.end_of_input
|
Result := input.end_of_input or is_trailer_reached
|
||||||
|
end
|
||||||
|
|
||||||
|
is_trailer_reached: BOOLEAN
|
||||||
|
-- Trailer reached?
|
||||||
|
do
|
||||||
|
Result := last_trailer /= Void
|
||||||
end
|
end
|
||||||
|
|
||||||
feature {NONE} -- Parser
|
feature {NONE} -- Parser
|
||||||
@@ -320,11 +341,7 @@ feature {NONE} -- Parser
|
|||||||
check l_input.last_character = '%N' end
|
check l_input.last_character = '%N' end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if s.is_empty then
|
last_trailer := s
|
||||||
last_trailer := Void
|
|
||||||
else
|
|
||||||
last_trailer := s
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
feature {NONE} -- Implementation
|
feature {NONE} -- Implementation
|
||||||
@@ -333,7 +350,7 @@ feature {NONE} -- Implementation
|
|||||||
-- Input Stream
|
-- Input Stream
|
||||||
|
|
||||||
;note
|
;note
|
||||||
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||||
source: "[
|
source: "[
|
||||||
Eiffel Software
|
Eiffel Software
|
||||||
|
|||||||
@@ -62,14 +62,19 @@ feature -- Input
|
|||||||
i > end_pos
|
i > end_pos
|
||||||
loop
|
loop
|
||||||
read_character
|
read_character
|
||||||
a_string.put (last_character, i)
|
if last_character_available then
|
||||||
|
a_string.put (last_character, i)
|
||||||
if end_of_input then
|
if end_of_input then
|
||||||
Result := i
|
Result := i
|
||||||
|
-- Jump out of the loop.
|
||||||
|
i := end_pos + 1
|
||||||
|
else
|
||||||
|
i := i + 1
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- reached end of input
|
||||||
-- Jump out of the loop.
|
-- Jump out of the loop.
|
||||||
i := end_pos + 1
|
i := end_pos + 1
|
||||||
else
|
|
||||||
i := i + 1
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if not end_of_input then
|
if not end_of_input then
|
||||||
@@ -107,13 +112,20 @@ feature -- Input
|
|||||||
i > end_pos
|
i > end_pos
|
||||||
loop
|
loop
|
||||||
read_character
|
read_character
|
||||||
a_string.extend (last_character)
|
if last_character_available then
|
||||||
l_count := l_count + 1
|
a_string.extend (last_character)
|
||||||
if end_of_input then
|
l_count := l_count + 1
|
||||||
|
|
||||||
|
if end_of_input then
|
||||||
|
-- Jump out of the loop.
|
||||||
|
i := end_pos + 1
|
||||||
|
else
|
||||||
|
i := i + 1
|
||||||
|
end
|
||||||
|
else
|
||||||
|
-- reached end of input
|
||||||
-- Jump out of the loop.
|
-- Jump out of the loop.
|
||||||
i := end_pos + 1
|
i := end_pos + 1
|
||||||
else
|
|
||||||
i := i + 1
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
last_appended_count := l_count
|
last_appended_count := l_count
|
||||||
@@ -194,6 +206,15 @@ feature -- Access
|
|||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
|
last_character_available: BOOLEAN
|
||||||
|
-- Is `last_character' available? i.e read?
|
||||||
|
--| with chunked encoding, we may reach the end and the `last_character'
|
||||||
|
--| should not be used.
|
||||||
|
--| to redefine in descendant if needed
|
||||||
|
do
|
||||||
|
Result := True
|
||||||
|
end
|
||||||
|
|
||||||
last_appended_count: INTEGER
|
last_appended_count: INTEGER
|
||||||
-- Count of characters actually read by last `append_to_string' call.
|
-- Count of characters actually read by last `append_to_string' call.
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user