diff --git a/library/server/ewsgi/specification/response/wgi_filter_response.e b/library/server/ewsgi/specification/response/wgi_filter_response.e index 7cd9226c..02485387 100644 --- a/library/server/ewsgi/specification/response/wgi_filter_response.e +++ b/library/server/ewsgi/specification/response/wgi_filter_response.e @@ -20,8 +20,9 @@ feature {NONE} -- Initialization res.set_post_commit_action (agent commit) end - wgi_response: WGI_RESPONSE +feature -- Access + wgi_response: WGI_RESPONSE feature {WGI_FILTER_RESPONSE} -- Change diff --git a/library/server/ewsgi/specification/stream/wgi_chunked_input_stream.e b/library/server/ewsgi/specification/stream/wgi_chunked_input_stream.e index 9068ba46..4722591d 100644 --- a/library/server/ewsgi/specification/stream/wgi_chunked_input_stream.e +++ b/library/server/ewsgi/specification/stream/wgi_chunked_input_stream.e @@ -9,6 +9,9 @@ class inherit WGI_INPUT_STREAM + redefine + last_character_available + end create make @@ -36,11 +39,17 @@ feature -- Input index := index + 1 if index > chunk_upper then read_chunk_block - if last_chunk_data = Void then + if + last_chunk_size = 0 + then read_trailer_and_crlf + last_character := '%U' + else + last_character := last_chunk_data.item (index) end + else + last_character := last_chunk_data.item (index) end - last_character := last_chunk_data.item (index) end read_string (nb: INTEGER) @@ -54,7 +63,7 @@ feature -- Input i: like index do last_string.wipe_out - if last_trailer /= Void then + if is_trailer_reached then -- trailer already reached, no more data check input.end_of_input end else @@ -103,6 +112,12 @@ feature -- Access last_character: CHARACTER_8 -- Last item read. + last_character_available: BOOLEAN + -- + do + Result := not is_trailer_reached + end + feature -- Access: chunk last_chunk_size: INTEGER @@ -142,7 +157,13 @@ feature -- Status report end_of_input: BOOLEAN -- Has the end of input stream been reached? 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 feature {NONE} -- Parser @@ -320,11 +341,7 @@ feature {NONE} -- Parser check l_input.last_character = '%N' end end end - if s.is_empty then - last_trailer := Void - else - last_trailer := s - end + last_trailer := s end feature {NONE} -- Implementation @@ -333,7 +350,7 @@ feature {NONE} -- Implementation -- Input Stream ;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)" source: "[ Eiffel Software diff --git a/library/server/ewsgi/specification/stream/wgi_input_stream.e b/library/server/ewsgi/specification/stream/wgi_input_stream.e index 63f1cb66..4fb778d8 100644 --- a/library/server/ewsgi/specification/stream/wgi_input_stream.e +++ b/library/server/ewsgi/specification/stream/wgi_input_stream.e @@ -62,14 +62,19 @@ feature -- Input i > end_pos loop read_character - a_string.put (last_character, i) - - if end_of_input then - Result := i + if last_character_available then + a_string.put (last_character, i) + if end_of_input then + 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. i := end_pos + 1 - else - i := i + 1 end end if not end_of_input then @@ -107,13 +112,20 @@ feature -- Input i > end_pos loop read_character - a_string.extend (last_character) - l_count := l_count + 1 - if end_of_input then + if last_character_available then + a_string.extend (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 + else + -- reached end of input -- Jump out of the loop. i := end_pos + 1 - else - i := i + 1 end end last_appended_count := l_count @@ -194,6 +206,15 @@ feature -- Access deferred 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 -- Count of characters actually read by last `append_to_string' call.