From a8a3f3cb8bca827f03a6b01b6e09d77b139788e1 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Fri, 29 Mar 2013 17:50:34 +0100 Subject: [PATCH] reuse implementation from WSF_REQUEST to get input data for MIME handlers. --- .../mime/wsf_multipart_form_data_handler.e | 2 +- .../wsf/src/support/wsf_mime_handler_helper.e | 38 ++----------------- library/server/wsf/src/wsf_request.e | 14 ++----- 3 files changed, 8 insertions(+), 46 deletions(-) diff --git a/library/server/wsf/src/mime/wsf_multipart_form_data_handler.e b/library/server/wsf/src/mime/wsf_multipart_form_data_handler.e index 68c568f3..361ada48 100644 --- a/library/server/wsf/src/mime/wsf_multipart_form_data_handler.e +++ b/library/server/wsf/src/mime/wsf_multipart_form_data_handler.e @@ -52,7 +52,7 @@ feature {NONE} -- Implementation: Form analyzer require a_content_type_valid: a_content_type /= Void and not a_content_type.has_error s_attached: s /= Void - same_content_length: req.content_length_value > 0 implies req.content_length_value.as_integer_32 = s.count + same_content_length: req.content_length_value > 0 implies req.content_length_value.as_integer_32 <= s.count vars_attached: vars /= Void local p,i,next_b: INTEGER diff --git a/library/server/wsf/src/support/wsf_mime_handler_helper.e b/library/server/wsf/src/support/wsf_mime_handler_helper.e index b544045a..2f64720b 100644 --- a/library/server/wsf/src/support/wsf_mime_handler_helper.e +++ b/library/server/wsf/src/support/wsf_mime_handler_helper.e @@ -9,42 +9,10 @@ deferred class feature {NONE} -- Implementation - full_input_data (req: WSF_REQUEST): READABLE_STRING_8 + full_input_data (req: WSF_REQUEST): STRING_8 do - Result := read_input_data (req.input, req.content_length_value) - end - - read_input_data (a_input: WGI_INPUT_STREAM; a_content_length: NATURAL_64): STRING_8 - -- All data from input form - local - n: INTEGER - t: STRING - do - if a_content_length > 0 then - create Result.make (a_content_length.as_integer_32) - n := a_input.read_to_string (Result, 1, Result.capacity) - check n = a_content_length end - else - from - n := 8_192 - create Result.make (n) - until - n = 0 - loop - a_input.read_string (n) - t := a_input.last_string - if t.count = 0 then - n := 0 - else - if t.count < n then - n := 0 - end - Result.append_string (t) - end - end - end - ensure - same_content_length: a_content_length > 0 implies Result.count = a_content_length.as_integer_32 + create Result.make (0) + req.read_input_data_into (Result) end add_string_value_to_table (a_name: READABLE_STRING_8; a_value: READABLE_STRING_8; a_table: HASH_TABLE [WSF_VALUE, READABLE_STRING_GENERAL]) diff --git a/library/server/wsf/src/wsf_request.e b/library/server/wsf/src/wsf_request.e index bc755715..eeea1a54 100644 --- a/library/server/wsf/src/wsf_request.e +++ b/library/server/wsf/src/wsf_request.e @@ -211,22 +211,16 @@ feature -- Access: Input until n = 0 loop - l_input.read_string (n) - s := l_input.last_string - if s.count = 0 then + l_input.append_to_string (buf, n) + if l_input.last_appended_count < n then n := 0 - else - if s.count < n then - n := 0 - end - buf.append (s) end end else n := content_length_value.as_integer_32 if n > 0 then - buf.resize (buf.count + n) - n := l_input.read_to_string (buf, buf.count + 1, n) + l_input.append_to_string (buf, n) + n := l_input.last_appended_count check n = content_length_value.as_integer_32 end end end