From ca3a520bb97fc47703f7fdd8a6cd1999e921378a Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Wed, 8 Feb 2012 16:36:54 +0100 Subject: [PATCH 01/17] fixed http_client tests --- library/client/http_client/tests/test_http_client.e | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/client/http_client/tests/test_http_client.e b/library/client/http_client/tests/test_http_client.e index 5e687dd9..655a3966 100644 --- a/library/client/http_client/tests/test_http_client.e +++ b/library/client/http_client/tests/test_http_client.e @@ -79,7 +79,7 @@ feature -- Test routines value3: VALUE value4: VALUE foo: BAR - + ]")) end From 497fe03d38f651a9a9b98d1a1bdfdc129d883981 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 8 Feb 2012 21:32:25 +0100 Subject: [PATCH 02/17] libcurl: Applied a workaround to avoid issue on Win32 (see LIBCURL_HTTP_CLIENT_REQUEST.apply_workaround) Separated the http_client-safe.ecf and test-safe.ecf Added HTTP_CLIENT_SESSION.set_max_redirects Fixed broken test due to formatting trouble. --- .../client/http_client/http_client-safe.ecf | 14 +----- library/client/http_client/http_client.ecf | 1 + .../http_client/src/http_client_session.e | 44 ++++++++++------ .../libcurl/libcurl_http_client_request.e | 9 ++++ .../client/http_client/tests/test-safe.ecf | 18 +++++++ library/client/http_client/tests/test.e | 50 +++++++++++++++++++ .../http_client/tests/test_http_client.e | 34 +++++++------ 7 files changed, 128 insertions(+), 42 deletions(-) create mode 100644 library/client/http_client/tests/test-safe.ecf create mode 100644 library/client/http_client/tests/test.e diff --git a/library/client/http_client/http_client-safe.ecf b/library/client/http_client/http_client-safe.ecf index 8ff790a5..de757e10 100644 --- a/library/client/http_client/http_client-safe.ecf +++ b/library/client/http_client/http_client-safe.ecf @@ -10,6 +10,7 @@ + @@ -23,17 +24,4 @@ - - - - /.git$ - /EIFGENs$ - /.svn$ - - - - - diff --git a/library/client/http_client/http_client.ecf b/library/client/http_client/http_client.ecf index ee034729..a4ec1415 100644 --- a/library/client/http_client/http_client.ecf +++ b/library/client/http_client/http_client.ecf @@ -10,6 +10,7 @@ + diff --git a/library/client/http_client/src/http_client_session.e b/library/client/http_client/src/http_client_session.e index d4c02ef1..d8245b9d 100644 --- a/library/client/http_client/src/http_client_session.e +++ b/library/client/http_client/src/http_client_session.e @@ -1,12 +1,29 @@ note - description : "Objects that ..." - author : "$Author$" - date : "$Date$" - revision : "$Revision$" + description : "[ + HTTP_CLIENT_SESSION represent a session + and is used to call get, post, .... request + with predefined settings such as + base_url + specific common headers + timeout and so on ... + ]" + author: "$Author$" + date: "$Date$" + revision: "$Revision$" deferred class HTTP_CLIENT_SESSION +inherit + ANY + + HTTP_CLIENT_CONSTANTS + rename + auth_type_id as auth_type_id_from_string + export + {NONE} all + end + feature {NONE} -- Initialization make (a_base_url: READABLE_STRING_8) @@ -154,37 +171,36 @@ feature -- Change set_auth_type (s: READABLE_STRING_8) do auth_type := s - auth_type_id := http_client_constants.auth_type_id (s) + auth_type_id := auth_type_id_from_string (s) end set_basic_auth_type do auth_type := "basic" - auth_type_id := {HTTP_CLIENT_CONSTANTS}.auth_type_basic + auth_type_id := Auth_type_basic end set_digest_auth_type do auth_type := "digest" - auth_type_id := {HTTP_CLIENT_CONSTANTS}.auth_type_digest + auth_type_id := Auth_type_digest end set_any_auth_type do auth_type := "any" - auth_type_id := {HTTP_CLIENT_CONSTANTS}.auth_type_any + auth_type_id := Auth_type_any end set_anysafe_auth_type do auth_type := "anysafe" - auth_type_id := {HTTP_CLIENT_CONSTANTS}.auth_type_anysafe + auth_type_id := Auth_type_anysafe end -feature {NONE} -- Implementation - - http_client_constants: HTTP_CLIENT_CONSTANTS - once - create Result + set_max_redirects (n: like max_redirects) + do + max_redirects := n end + end diff --git a/library/client/http_client/src/spec/libcurl/libcurl_http_client_request.e b/library/client/http_client/src/spec/libcurl/libcurl_http_client_request.e index fb3c7c90..520f9fc4 100644 --- a/library/client/http_client/src/spec/libcurl/libcurl_http_client_request.e +++ b/library/client/http_client/src/spec/libcurl/libcurl_http_client_request.e @@ -24,6 +24,15 @@ feature {NONE} -- Initialization do make_request (a_url, a_session, ctx) request_method := a_request_method + apply_workaround + end + + apply_workaround + -- Due to issue with Eiffel cURL on Windows 32bits + -- we need to do the following workaround + once + if attached (create {INET_ADDRESS_FACTORY}).create_localhost then + end end session: LIBCURL_HTTP_CLIENT_SESSION diff --git a/library/client/http_client/tests/test-safe.ecf b/library/client/http_client/tests/test-safe.ecf new file mode 100644 index 00000000..6c32920a --- /dev/null +++ b/library/client/http_client/tests/test-safe.ecf @@ -0,0 +1,18 @@ + + + + + + /.git$ + /EIFGENs$ + /.svn$ + + + + + + + + diff --git a/library/client/http_client/tests/test.e b/library/client/http_client/tests/test.e new file mode 100644 index 00000000..0073561a --- /dev/null +++ b/library/client/http_client/tests/test.e @@ -0,0 +1,50 @@ +class TEST + +create + make + +feature -- Init + + make + do + test_http_client + end + + test_http_client + -- New test routine + local + sess: LIBCURL_HTTP_CLIENT_SESSION + h: STRING_8 + do + create sess.make ("http://www.google.com") + if attached sess.get ("/search?q=eiffel", Void) as res then + assert ("Get returned without error", not res.error_occurred) + create h.make_empty + if attached res.headers as hds then + across + hds as c + loop + h.append (c.item.name + ": " + c.item.value + "%R%N") + end + end + if attached res.body as l_body then + assert ("body not empty", not l_body.is_empty) + end + assert ("same headers", h.same_string (res.raw_header)) + else + assert ("Not found", False) + end + end + + assert (m: READABLE_STRING_8; b: BOOLEAN) + local + e: DEVELOPER_EXCEPTION + do + if not b then + create e + e.set_message (m) + e.raise + end + end + +end diff --git a/library/client/http_client/tests/test_http_client.e b/library/client/http_client/tests/test_http_client.e index 655a3966..a5cf2228 100644 --- a/library/client/http_client/tests/test_http_client.e +++ b/library/client/http_client/tests/test_http_client.e @@ -23,6 +23,7 @@ feature -- Test routines do create sess.make ("http://www.google.com") if attached sess.get ("/search?q=eiffel", Void) as res then + assert ("Get returned without error", not res.error_occurred) create h.make_empty if attached res.headers as hds then across @@ -32,7 +33,9 @@ feature -- Test routines end end if attached res.body as l_body then - + assert ("body not empty", not l_body.is_empty) + else + assert ("missing body", False) end assert ("same headers", h.same_string (res.raw_header)) else @@ -67,20 +70,21 @@ feature -- Test routines h.append (c.item.name + ": " + c.item.value + "%N") end end - assert ("Expected headers map", h.same_string ("[ - normal: NORMAL - concat: ABC - concat: DEF - key1: KEY - key2: KEY - key3: KEY - value1: VALUE - value2: VALUE - value3: VALUE - value4: VALUE - foo: BAR - - ]")) + assert ("Expected headers map", h.same_string ( +"[ +normal: NORMAL +concat: ABC +concat: DEF +key1: KEY +key2: KEY +key3: KEY +value1: VALUE +value2: VALUE +value3: VALUE +value4: VALUE +foo: BAR + +]")) end end From 6cf35e90c6b72417a1f32ab92e379340befc5350 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Wed, 8 Feb 2012 21:36:49 +0100 Subject: [PATCH 03/17] added a case in test_json_encoder --- library/text/encoder/tests/test_json_encoder.e | 1 + 1 file changed, 1 insertion(+) diff --git a/library/text/encoder/tests/test_json_encoder.e b/library/text/encoder/tests/test_json_encoder.e index df9e02f3..b8e37b3d 100644 --- a/library/text/encoder/tests/test_json_encoder.e +++ b/library/text/encoder/tests/test_json_encoder.e @@ -20,6 +20,7 @@ feature -- Test routines testing: "json-encoded" do test_json_encoded_encoding ({STRING_32}"il était une fois %"Ni & Hao%" (你好) \a\b\c") + test_json_encoded_encoding ({STRING_32}" `abc’ ") end test_json_encoded_encoding (s: STRING_32) From f3c779cf6e338d0a0241a0f2b0b63c3717f6e761 Mon Sep 17 00:00:00 2001 From: Olivier Ligot Date: Fri, 10 Feb 2012 14:01:04 +0100 Subject: [PATCH 04/17] [FIX] libfcgi.so location On Ubuntu 10.04 LTS, libfcgi.so is in /usr/lib instead of /usr/local/lib --- library/server/libfcgi/libfcgi.ecf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/server/libfcgi/libfcgi.ecf b/library/server/libfcgi/libfcgi.ecf index d69396be..f03336d3 100644 --- a/library/server/libfcgi/libfcgi.ecf +++ b/library/server/libfcgi/libfcgi.ecf @@ -25,7 +25,7 @@ - + From 537bd8241f4d75afc1f2bd60e6c98a29900621c2 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Mon, 13 Feb 2012 14:38:13 +0100 Subject: [PATCH 05/17] added a JSON encoder test case --- library/text/encoder/tests/test_json_encoder.e | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/text/encoder/tests/test_json_encoder.e b/library/text/encoder/tests/test_json_encoder.e index b8e37b3d..6c54c974 100644 --- a/library/text/encoder/tests/test_json_encoder.e +++ b/library/text/encoder/tests/test_json_encoder.e @@ -20,7 +20,7 @@ feature -- Test routines testing: "json-encoded" do test_json_encoded_encoding ({STRING_32}"il était une fois %"Ni & Hao%" (你好) \a\b\c") - test_json_encoded_encoding ({STRING_32}" `abc’ ") + test_json_encoded_encoding ({STRING_32}" it's `abc’ ") end test_json_encoded_encoding (s: STRING_32) From e52cd6b352f12a9399e76fa2b3ffe3385fcb4a77 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Tue, 14 Feb 2012 10:20:15 +0100 Subject: [PATCH 06/17] use WSF_PAGE_RESPONSE, instead of reimplementing it ourself --- .../request/rest/src/response/rest_response.e | 132 +++--------------- 1 file changed, 16 insertions(+), 116 deletions(-) diff --git a/draft/library/server/request/rest/src/response/rest_response.e b/draft/library/server/request/rest/src/response/rest_response.e index d098867d..405eeaf9 100644 --- a/draft/library/server/request/rest/src/response/rest_response.e +++ b/draft/library/server/request/rest/src/response/rest_response.e @@ -7,6 +7,17 @@ note class REST_RESPONSE +inherit + WSF_PAGE_RESPONSE + rename + header as headers, + body as message, + set_body as set_message, + put_string as append_message, + make as page_make, + send_to as send + end + create make @@ -15,12 +26,7 @@ feature {NONE} -- Initialization make (a_api: like api) do api := a_api - initialize - end - - initialize - do - create headers.make + page_make end feature -- Recycle @@ -28,123 +34,17 @@ feature -- Recycle recycle do headers.recycle + message := Void end feature -- Access - headers: HTTP_HEADER - api: STRING -- Associated api query string. - message: detachable STRING_8 - -- Associated message to send with the response. - -feature -- Element change - - set_message (m: like message) - -- Set `message' to `m' - do - message := m - end - - append_message (m: attached like message) - -- Append message `m' to current `message' value - -- create `message' is Void - require - m_not_empty: m /= Void and then not m.is_empty - do - if attached message as msg then - msg.append (m) - else - set_message (m.string) - end - end - - append_message_file_content (fn: STRING) - -- Append file content from `fn' to the response - --| To use with care. - --| You should avoid using this for big or binary content ... - local - f: RAW_FILE - do - create f.make (fn) - if f.exists and then f.is_readable then - f.open_read - from - until - f.exhausted - loop - f.read_stream (1024) - append_message (f.last_string) - end - f.close - end - end - -feature -- Output - - update_content_length (a_overwrite: BOOLEAN) - -- Update content length - -- if the header already exists it won't change it, - -- unless `a_overwrite' is set to True - local - hds: like headers - len: INTEGER - do - hds := headers - if a_overwrite or else not hds.has_content_length then - if attached message as m then - len := m.count --- if {PLATFORM}.is_windows then --- len := len + m.occurrences ('%N') --| FIXME: find better solution --- end - else - len := 0 - end - hds.put_content_length (len) - end - end - - compute - -- Compute the string output - do - update_content_length (False) - internal_headers_string := headers.string - end - - headers_string: STRING - local - o: like internal_headers_string - do - o := internal_headers_string - if o = Void then - compute - o := internal_headers_string - if o = Void then - check output_computed: False end - create o.make_empty - end - end - Result := o - end - - send (res: WSF_RESPONSE) - do - compute - res.set_status_code (200) - res.put_header_text (headers_string) - if attached message as m then - res.put_string (m) - end - end - -feature {NONE} -- Implementation: output - - internal_headers_string: detachable like headers_string - -;note - copyright: "Copyright (c) 1984-2011, Eiffel Software and others" +invariant +note + copyright: "Copyright (c) 1984-2012, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software From dd6b74326ee32aa16c0c6734ed031083f2d1bfea Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Tue, 14 Feb 2012 12:57:01 +0100 Subject: [PATCH 07/17] Added notion of synchronization between error handler this is convenient to integrate two components using their own ERROR_HANDLER (not sharing the same object) --- library/error/src/error_handler.e | 151 +++++++++++++++++++++++++++-- library/error/tests/test_error.e | 124 +++++++++++++++++++++++ library/error/tests/tests-safe.ecf | 18 ++++ 3 files changed, 287 insertions(+), 6 deletions(-) create mode 100644 library/error/tests/test_error.e create mode 100644 library/error/tests/tests-safe.ecf diff --git a/library/error/src/error_handler.e b/library/error/src/error_handler.e index c6e72c8b..347585f8 100644 --- a/library/error/src/error_handler.e +++ b/library/error/src/error_handler.e @@ -21,7 +21,7 @@ feature {NONE} -- Initialization make -- Initialize `Current'. do - create {ARRAYED_LIST [ERROR]} errors.make (3) + create {ARRAYED_LIST [like errors.item]} errors.make (3) create error_added_actions end @@ -60,12 +60,139 @@ feature -- Events error_added_actions: ACTION_SEQUENCE [TUPLE [ERROR]] -- Actions triggered when a new error is added +feature -- Synchronization + + add_synchronized_handler (h: ERROR_HANDLER) + --| the same handler can be added more than once + --| it will be synchronized only once + require + no_cycle: not has_synchronized_handler_in_cycle (h) + local + lst: like synchronized_handlers + do + lst := synchronized_handlers + if lst = Void then + create {ARRAYED_LIST [like synchronized_handlers.item]} lst.make (0) + lst.compare_references + synchronized_handlers := lst + end + if lst.has (h) then + check attached h.synchronized_handlers as h_lst and then h_lst.has (Current) end + else + lst.extend (h) + h.add_synchronized_handler (Current) + end + end + + has_synchronized_handler_in_cycle (h: ERROR_HANDLER): BOOLEAN + do + Result := False + end + +feature {ERROR_HANDLER} -- Synchronization implementation + + synchronized_handlers: detachable LIST [ERROR_HANDLER] + -- Synchronized handlers + + synchronize_error_from (e: ERROR; h_lst: LIST [ERROR_HANDLER]) + -- Called by error_handler during synchronization process + -- if `synchronized_handlers' is Void, this means Current is synchronizing + -- this is to prevent infinite cycle iteration + require + not h_lst.has (Current) + do + h_lst.extend (Current) + + if attached synchronized_handlers as lst then + synchronized_handlers := Void + add_error (e) + across + lst as c + loop + if not h_lst.has (c.item) then + c.item.synchronize_error_from (e, h_lst) + end + end + synchronized_handlers := lst + else + -- In synchronization + end + end + + synchronize_reset_from (h_lst: LIST [ERROR_HANDLER]) + -- Called by error_handler during synchronization process + -- if `synchronized_handlers' is Void, this means Current is synchronizing + -- this is to prevent infinite cycle iteration + require + not h_lst.has (Current) + do + h_lst.extend (Current) + if attached synchronized_handlers as lst then + synchronized_handlers := Void + reset + across + lst as c + loop + if not h_lst.has (c.item) then + c.item.synchronize_reset_from (h_lst) + end + end + synchronized_handlers := lst + else + -- In synchronization + end + end + + remove_synchronized_handler (h: ERROR_HANDLER) + do + if attached synchronized_handlers as lst then + lst.prune_all (h) + if lst.is_empty then + synchronized_handlers := Void + end + end + end + feature {NONE} -- Event: implementation on_error_added (e: ERROR) -- Error `e' was just added + local + sync_list: LINKED_LIST [ERROR_HANDLER] do error_added_actions.call ([e]) + if attached synchronized_handlers as lst then + synchronized_handlers := Void + create sync_list.make + sync_list.extend (Current) + across + lst as c + loop + if not sync_list.has (c.item) then + c.item.synchronize_error_from (e, sync_list) + end + end + synchronized_handlers := lst + end + end + + on_reset + local + sync_list: LINKED_LIST [ERROR_HANDLER] + do + if attached synchronized_handlers as lst then + synchronized_handlers := Void + create sync_list.make + sync_list.extend (Current) + across + lst as c + loop + if not sync_list.has (c.item) then + c.item.synchronize_reset_from (sync_list) + end + end + synchronized_handlers := lst + end end feature -- Basic operation @@ -138,18 +265,30 @@ feature -- Element changes -- Concatenate into a single error if any do if count > 1 and then attached as_single_error as e then - wipe_out - errors.force (e) + reset + add_error (e) end end - reset, wipe_out + reset do - errors.wipe_out + if errors.count > 0 then + errors.wipe_out + on_reset + end + end + + destroy + do + error_added_actions.wipe_out + if attached synchronized_handlers as lst then + lst.item.remove_synchronized_handler (Current) + end + synchronized_handlers := Void end note - copyright: "Copyright (c) 1984-2011, Eiffel Software and others" + copyright: "2011-2012, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/error/tests/test_error.e b/library/error/tests/test_error.e new file mode 100644 index 00000000..f0e1badf --- /dev/null +++ b/library/error/tests/test_error.e @@ -0,0 +1,124 @@ +note + description: "[ + Eiffel tests that can be executed by testing tool. + ]" + author: "EiffelStudio test wizard" + date: "$Date$" + revision: "$Revision$" + testing: "type/manual" + +class + TEST_ERROR + +inherit + EQA_TEST_SET + +feature -- Test routines + + test_error + note + testing: "error" + local + h: ERROR_HANDLER + cl: CELL [INTEGER] + do + create h.make + h.add_custom_error (123, "abc", "abc error occurred") + h.add_custom_error (456, "abc", "abc error occurred") + assert ("has 2 errors", h.count = 2) + h.reset + assert ("reset then no error", h.count = 0) + + -- error_added_actions + create cl.put (0) + h.error_added_actions.extend (agent (i_e: ERROR; i_cl: CELL [INTEGER]) do i_cl.replace (i_cl.item + 1) end(?, cl)) + h.add_custom_error (123, "abc", "abc error occurred") + h.add_custom_error (456, "abc", "abc error occurred") + assert ("has 2 errors, same as counted", h.count = 2 and h.count = cl.item) + + end + + test_sync_2 + note + testing: "error" + local + h1, h2: ERROR_HANDLER +-- cl: CELL [INTEGER] + do + create h1.make + create h2.make + h1.add_synchronized_handler (h2) + + h1.add_custom_error (123, "abc", "abc error occurred") + h1.add_custom_error (456, "abc", "abc error occurred") + + assert ("has 2 errors", h1.count = 2 and h2.count = h1.count) + + h1.reset + assert ("reset then no error", h1.count = 0 and h2.count = h1.count) + + end + + test_sync_3 + note + testing: "error" + local + h1, h2, h3: ERROR_HANDLER +-- cl: CELL [INTEGER] + do + create h1.make + create h2.make + create h3.make + + h1.add_synchronized_handler (h2) + h2.add_synchronized_handler (h3) + + h1.add_custom_error (123, "abc", "abc error occurred") + h1.add_custom_error (456, "abc", "abc error occurred") + + assert ("has 2 errors", h1.count = 2 and h2.count = h1.count and h3.count = h2.count) + + h1.reset + assert ("reset then no error", h1.count = 0 and h2.count = h1.count and h3.count = h2.count) + + end + + test_sync_3_with_cycle + note + testing: "error" + local + h1, h2, h3: ERROR_HANDLER +-- cl: CELL [INTEGER] + do + create h1.make + create h2.make + create h3.make + + h1.add_synchronized_handler (h2) + h2.add_synchronized_handler (h3) + h3.add_synchronized_handler (h1) + + h1.add_custom_error (123, "abc", "abc error occurred") + h1.add_custom_error (456, "abc", "abc error occurred") + + assert ("has 2 errors", h1.count = 2 and h2.count = h1.count and h3.count = h2.count) + + h1.reset + assert ("reset then no error", h1.count = 0 and h2.count = h1.count and h3.count = h2.count) + + end + + +note + copyright: "Copyright (c) 1984-2011, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" +end + + diff --git a/library/error/tests/tests-safe.ecf b/library/error/tests/tests-safe.ecf new file mode 100644 index 00000000..46989ec4 --- /dev/null +++ b/library/error/tests/tests-safe.ecf @@ -0,0 +1,18 @@ + + + + + + /.git$ + /EIFGENs$ + /.svn$ + + + + + + + + From 4bb8a71c1b00a863bf1a3236e7bd0ad317840978 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Tue, 14 Feb 2012 18:01:17 +0100 Subject: [PATCH 08/17] Added DEBUG_OUTPUT to ERROR, since this is convenient during debugging --- library/error/src/error.e | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/library/error/src/error.e b/library/error/src/error.e index 5687ecac..8ab78c85 100644 --- a/library/error/src/error.e +++ b/library/error/src/error.e @@ -8,6 +8,11 @@ note deferred class ERROR +inherit + ANY + + DEBUG_OUTPUT + feature -- Access code: INTEGER @@ -47,6 +52,13 @@ feature -- String representation end end +feature -- Status report + + debug_output: STRING + do + Result := string_representation.as_string_8 + end + feature -- Change set_parent (a_parent: like parent) From f59d5cac328b7eaab7a4b250360479dd591c20c6 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Tue, 14 Feb 2012 18:02:14 +0100 Subject: [PATCH 09/17] added postcondition to ensure the body string set to the response, is the same reference this is important, since sometime we just do rep.set_body (s) s.append_string ("..") --- library/server/wsf/src/response/wsf_page_response.e | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/server/wsf/src/response/wsf_page_response.e b/library/server/wsf/src/response/wsf_page_response.e index 4806b74b..efd8cbe6 100644 --- a/library/server/wsf/src/response/wsf_page_response.e +++ b/library/server/wsf/src/response/wsf_page_response.e @@ -60,6 +60,8 @@ feature -- Element change set_body (a_body: like body) do body := a_body + ensure + body_set: a_body /= Void implies body = a_body end put_string (a_string: READABLE_STRING_8) From fbec89f354f0255399a5a0bfa6652f3c57313831 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Tue, 14 Feb 2012 18:03:42 +0100 Subject: [PATCH 10/17] Better signature for encoders Split library .ecf and the autotest .ecf --- library/text/encoder/src/html_encoder.e | 8 ++--- library/text/encoder/src/json_encoder.e | 8 ++--- library/text/encoder/src/url_encoder.e | 30 ++++++++----------- library/text/encoder/src/utf8_encoder.e | 8 ++--- library/text/encoder/src/utf8_url_encoder.e | 6 ++-- library/text/encoder/src/xml_encoder.e | 8 ++--- library/text/encoder/tests/test_url_encoder.e | 19 +++++++++--- .../text/encoder/tests/test_utf8_encoder.e | 3 +- library/text/encoder/tests/tests-safe.ecf | 18 +++++++++++ 9 files changed, 66 insertions(+), 42 deletions(-) create mode 100644 library/text/encoder/tests/tests-safe.ecf diff --git a/library/text/encoder/src/html_encoder.e b/library/text/encoder/src/html_encoder.e index efd76425..9bb0fc08 100644 --- a/library/text/encoder/src/html_encoder.e +++ b/library/text/encoder/src/html_encoder.e @@ -13,7 +13,7 @@ class HTML_ENCODER inherit - ENCODER [STRING_32, STRING_8] + ENCODER [READABLE_STRING_32, READABLE_STRING_8] PLATFORM export @@ -33,7 +33,7 @@ feature -- Status report feature -- Encoder - encoded_string (s: STRING_32): STRING_8 + encoded_string (s: READABLE_STRING_32): STRING_8 -- HTML-encoded value of `s'. local i, n: INTEGER @@ -67,7 +67,7 @@ feature -- Encoder feature -- Decoder - decoded_string (v: STRING_8): STRING_32 + decoded_string (v: READABLE_STRING_8): STRING_32 -- The HTML-encoded equivalent of the given string local i, n: INTEGER @@ -259,7 +259,7 @@ feature {NONE} -- Implementation: decoder end note - copyright: "2011-2011, Eiffel Software and others" + copyright: "2011-2012, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/text/encoder/src/json_encoder.e b/library/text/encoder/src/json_encoder.e index 94075cbe..333c7e34 100644 --- a/library/text/encoder/src/json_encoder.e +++ b/library/text/encoder/src/json_encoder.e @@ -1,7 +1,7 @@ note description: "[ Summary description for {JSON_ENCODER}. - + ]" legal: "See notice at end of class." status: "See notice at end of class." @@ -12,7 +12,7 @@ class JSON_ENCODER inherit - ENCODER [STRING_32, STRING_8] + ENCODER [READABLE_STRING_32, READABLE_STRING_8] PLATFORM export @@ -32,7 +32,7 @@ feature -- Status report feature -- Encoder - encoded_string (s: STRING_32): STRING_8 + encoded_string (s: READABLE_STRING_32): STRING_8 -- JSON-encoded value of `s'. local i, j, n: INTEGER @@ -82,7 +82,7 @@ feature -- Encoder feature -- Decoder - decoded_string (v: STRING_8): STRING_32 + decoded_string (v: READABLE_STRING_8): STRING_32 -- The JSON-encoded equivalent of the given string local i, n: INTEGER diff --git a/library/text/encoder/src/url_encoder.e b/library/text/encoder/src/url_encoder.e index 386b64da..9720150b 100644 --- a/library/text/encoder/src/url_encoder.e +++ b/library/text/encoder/src/url_encoder.e @@ -33,17 +33,15 @@ feature -- Status report feature -- Encoder - encoded_string (s: READABLE_STRING_32): READABLE_STRING_8 + encoded_string (s: READABLE_STRING_32): STRING_8 -- URL-encoded value of `s'. local i, n: INTEGER uc: CHARACTER_32 c: CHARACTER_8 - s8: STRING_8 do has_error := False - create s8.make (s.count + s.count // 10) - Result := s8 + create Result.make (s.count + s.count // 10) n := s.count from i := 1 until i > n loop uc := s.item (i) @@ -55,14 +53,14 @@ feature -- Encoder 'a' .. 'z', '0' .. '9', '.', '-', '~', '_' then - s8.extend (c) + Result.extend (c) when ' ' then - s8.extend ('+') + Result.extend ('+') else - s8.append (url_encoded_char (uc)) + Result.append (url_encoded_char (uc)) end else - s8.append (url_encoded_char (uc)) + Result.append (url_encoded_char (uc)) end i := i + 1 end @@ -134,19 +132,17 @@ feature {NONE} -- encoder character feature -- Decoder - decoded_string (v: READABLE_STRING_8): READABLE_STRING_32 + decoded_string (v: READABLE_STRING_8): STRING_32 -- The URL-encoded equivalent of the given string local i, n: INTEGER c: CHARACTER pr: CELL [INTEGER] - s32: STRING_32 changed: BOOLEAN do has_error := False n := v.count - create s32.make (n) - Result := s32 + create Result.make (n) from i := 1 until i > n loop @@ -154,19 +150,19 @@ feature -- Decoder inspect c when '+' then changed := True - s32.append_character ({CHARACTER_32}' ') + Result.append_character ({CHARACTER_32}' ') when '%%' then -- An escaped character ? if i = n then - s32.append_character (c.to_character_32) + Result.append_character (c.to_character_32) else changed := True create pr.put (i) - s32.append (url_decoded_char (v, pr)) + Result.append (url_decoded_char (v, pr)) i := pr.item end else - s32.append_character (c.to_character_32) + Result.append_character (c.to_character_32) end i := i + 1 end @@ -367,7 +363,7 @@ feature {NONE} -- Hexadecimal and strings end note - copyright: "2011-2011, Eiffel Software and others" + copyright: "2011-2012, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/text/encoder/src/utf8_encoder.e b/library/text/encoder/src/utf8_encoder.e index 451cb5e3..778ee000 100644 --- a/library/text/encoder/src/utf8_encoder.e +++ b/library/text/encoder/src/utf8_encoder.e @@ -13,7 +13,7 @@ class UTF8_ENCODER inherit - ENCODER [STRING_32, STRING_8] + ENCODER [READABLE_STRING_32, READABLE_STRING_8] UTF8_ENCODER_HELPER @@ -35,7 +35,7 @@ feature -- Status report feature -- Encoder - encoded_string (s: STRING_32): STRING_8 + encoded_string (s: READABLE_STRING_32): STRING_8 -- UTF8-encoded value of `s'. do Result := utf32_to_utf8 (s) @@ -44,7 +44,7 @@ feature -- Encoder feature -- Decoder - decoded_string (v: STRING_8): STRING_32 + decoded_string (v: READABLE_STRING_8): STRING_32 -- The UTF8-encoded equivalent of the given string do Result := utf8_to_utf32 (v) @@ -52,7 +52,7 @@ feature -- Decoder end note - copyright: "2011-2011, Eiffel Software and others" + copyright: "2011-2012, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/text/encoder/src/utf8_url_encoder.e b/library/text/encoder/src/utf8_url_encoder.e index 3648f111..8fca01d2 100644 --- a/library/text/encoder/src/utf8_url_encoder.e +++ b/library/text/encoder/src/utf8_url_encoder.e @@ -42,7 +42,7 @@ feature -- Access feature -- Encoder - encoded_string (s: READABLE_STRING_32): READABLE_STRING_8 + encoded_string (s: READABLE_STRING_32): STRING_8 -- URL-encoded value of `s'. do Result := Precursor (s) @@ -64,7 +64,7 @@ feature -- Encoder feature -- Decoder - decoded_string (v: READABLE_STRING_8): READABLE_STRING_32 + decoded_string (v: READABLE_STRING_8): STRING_32 -- The URL-encoded equivalent of the given string do Result := Precursor (v) @@ -77,7 +77,7 @@ feature -- Decoder end note - copyright: "2011-2011, Eiffel Software and others" + copyright: "2011-2012, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/text/encoder/src/xml_encoder.e b/library/text/encoder/src/xml_encoder.e index 4fd33f94..8c8fd7a9 100644 --- a/library/text/encoder/src/xml_encoder.e +++ b/library/text/encoder/src/xml_encoder.e @@ -13,7 +13,7 @@ class XML_ENCODER inherit - ENCODER [STRING_32, STRING_8] + ENCODER [READABLE_STRING_32, READABLE_STRING_8] PLATFORM export @@ -33,7 +33,7 @@ feature -- Status report feature -- Encoder - encoded_string (s: STRING_32): STRING_8 + encoded_string (s: READABLE_STRING_32): STRING_8 -- XML-encoded value of `s'. local i, n: INTEGER @@ -67,7 +67,7 @@ feature -- Encoder feature -- Decoder - decoded_string (v: STRING_8): STRING_32 + decoded_string (v: READABLE_STRING_8): STRING_32 -- The XML-encoded equivalent of the given string local i, n: INTEGER @@ -259,7 +259,7 @@ feature {NONE} -- Implementation: decoder end note - copyright: "2011-2011, Eiffel Software and others" + copyright: "2011-2012, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/text/encoder/tests/test_url_encoder.e b/library/text/encoder/tests/test_url_encoder.e index e55fe18f..25cff7b7 100644 --- a/library/text/encoder/tests/test_url_encoder.e +++ b/library/text/encoder/tests/test_url_encoder.e @@ -19,10 +19,11 @@ feature -- Test routines note testing: "url-encoded" do - test_url_encoded_encoding ("http://domain.tld/foo/bar/script.php?test='toto'&foo=bar&title=il était une fois") - test_url_encoded_encoding ("été") - test_url_encoded_decoding ("%%E9t%%E9", "été") - test_url_encoded_decoding ("%%C3%%A9t%%C3%%A9", "été") + test_url_encoded_encoding ({STRING_32}"http://domain.tld/foo/bar/script.php?test='toto'&foo=bar&title=il était une fois") + test_url_encoded_encoding ({STRING_32}"été") + test_url_encoded_decoding ({STRING_8}"%%E9t%%E9", {STRING_32}"été") + + test_utf8_url_encoded_decoding ({STRING_8}"%%C3%%A9t%%C3%%A9", {STRING_32}"été") end test_url_encoded_encoding (s: STRING_32) @@ -47,6 +48,16 @@ feature -- Test routines assert ("decoded encoded string is same for %"" + s + "%"", u ~ e) end + test_utf8_url_encoded_decoding (s: STRING_8; e: STRING_32) + local + u: STRING_32 + b: UTF8_URL_ENCODER + do + create b + u := b.decoded_string (s) + assert ("decoded encoded string is same for %"" + s + "%"", u ~ e) + end + note copyright: "2011-2011, Eiffel Software and others" diff --git a/library/text/encoder/tests/test_utf8_encoder.e b/library/text/encoder/tests/test_utf8_encoder.e index f87bdac1..e1f29c61 100644 --- a/library/text/encoder/tests/test_utf8_encoder.e +++ b/library/text/encoder/tests/test_utf8_encoder.e @@ -19,8 +19,7 @@ feature -- Test routines note testing: "url-encoded" do --- test_utf8_decoding ("summer=été&weird=à", "summer=été&weird=à") - test_utf8_decoding ("%%C3%%A9t%%C3%%A9", "été") + test_utf8_decoding ("%%C3%%A9t%%C3%%A9", {STRING_32}"été") end test_utf8_decoding (s: STRING_8; e: STRING_32) diff --git a/library/text/encoder/tests/tests-safe.ecf b/library/text/encoder/tests/tests-safe.ecf new file mode 100644 index 00000000..be446169 --- /dev/null +++ b/library/text/encoder/tests/tests-safe.ecf @@ -0,0 +1,18 @@ + + + + + + /.git$ + /EIFGENs$ + /.svn$ + + + + + + + + From 145b129b28089c9507372eb0fd4745a3c7c9ea81 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Wed, 15 Feb 2012 11:03:30 +0100 Subject: [PATCH 11/17] Fixed ERROR_HANDLER.destroy Fixed and export ERROR_HANDLER.remove_synchronized_handler Added comments Added associated autotests --- library/error/src/error.e | 6 ++-- library/error/src/error_custom.e | 10 +++--- library/error/src/error_handler.e | 44 +++++++++++++++-------- library/error/tests/test_error.e | 58 +++++++++++++++++++++++++++++++ 4 files changed, 95 insertions(+), 23 deletions(-) diff --git a/library/error/src/error.e b/library/error/src/error.e index 8ab78c85..e4c266b0 100644 --- a/library/error/src/error.e +++ b/library/error/src/error.e @@ -21,13 +21,13 @@ feature -- Access result_not_zero: Result /= 0 end - name: STRING + name: READABLE_STRING_8 deferred ensure result_attached: Result /= Void end - message: detachable STRING_32 + message: detachable READABLE_STRING_32 -- Potential error message deferred end @@ -80,7 +80,7 @@ invariant name_attached: name /= Void note - copyright: "Copyright (c) 1984-2011, Eiffel Software and others" + copyright: "2011-2012, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/error/src/error_custom.e b/library/error/src/error_custom.e index 7b139fab..cd339662 100644 --- a/library/error/src/error_custom.e +++ b/library/error/src/error_custom.e @@ -16,12 +16,12 @@ create feature {NONE} -- Initialization - make (a_code: INTEGER; a_name: STRING; a_message: detachable like message) + make (a_code: INTEGER; a_name: like name; a_message: detachable like message) -- Initialize `Current'. do code := a_code name := a_name - if attached a_message then + if a_message /= Void then message := a_message else message := "Error: " + a_name + " (code=" + a_code.out + ")" @@ -32,9 +32,9 @@ feature -- Access code: INTEGER - name: STRING + name: READABLE_STRING_8 - message: STRING_32 + message: detachable READABLE_STRING_32 feature -- Visitor @@ -45,7 +45,7 @@ feature -- Visitor end note - copyright: "Copyright (c) 1984-2011, Eiffel Software and others" + copyright: "2011-2012, Eiffel Software and others" license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" source: "[ Eiffel Software diff --git a/library/error/src/error_handler.e b/library/error/src/error_handler.e index 347585f8..8ee91cdd 100644 --- a/library/error/src/error_handler.e +++ b/library/error/src/error_handler.e @@ -34,6 +34,7 @@ feature -- Status end count: INTEGER + -- Number of error do Result := errors.count end @@ -63,10 +64,9 @@ feature -- Events feature -- Synchronization add_synchronized_handler (h: ERROR_HANDLER) + -- Add synchronization between `h' and `Current' --| the same handler can be added more than once --| it will be synchronized only once - require - no_cycle: not has_synchronized_handler_in_cycle (h) local lst: like synchronized_handlers do @@ -84,9 +84,20 @@ feature -- Synchronization end end - has_synchronized_handler_in_cycle (h: ERROR_HANDLER): BOOLEAN + remove_synchronized_handler (h: ERROR_HANDLER) + -- Remove synchronization between `h' and `Current' do - Result := False + if attached synchronized_handlers as lst and then not lst.is_empty then + synchronized_handlers := Void + lst.prune_all (h) + + h.remove_synchronized_handler (Current) + + synchronized_handlers := lst + if lst.is_empty then + synchronized_handlers := Void + end + end end feature {ERROR_HANDLER} -- Synchronization implementation @@ -143,16 +154,6 @@ feature {ERROR_HANDLER} -- Synchronization implementation end end - remove_synchronized_handler (h: ERROR_HANDLER) - do - if attached synchronized_handlers as lst then - lst.prune_all (h) - if lst.is_empty then - synchronized_handlers := Void - end - end - end - feature {NONE} -- Event: implementation on_error_added (e: ERROR) @@ -177,6 +178,7 @@ feature {NONE} -- Event: implementation end on_reset + -- `reset' was just called local sync_list: LINKED_LIST [ERROR_HANDLER] do @@ -237,6 +239,7 @@ feature -- Basic operation feature -- Access as_single_error: detachable ERROR + -- All error(s) concatenated into one single error. do if count > 1 then create {ERROR_GROUP} Result.make (errors) @@ -248,6 +251,7 @@ feature -- Access end as_string_representation: STRING + -- String representation of all error(s). require has_error do @@ -271,20 +275,30 @@ feature -- Element changes end reset + -- Reset error handler do if errors.count > 0 then errors.wipe_out on_reset end + ensure + has_no_error: not has_error + count = 0 end destroy + -- Destroy Current, and remove any synchronization do error_added_actions.wipe_out if attached synchronized_handlers as lst then - lst.item.remove_synchronized_handler (Current) + across + lst as c + loop + c.item.remove_synchronized_handler (Current) + end end synchronized_handlers := Void + reset end note diff --git a/library/error/tests/test_error.e b/library/error/tests/test_error.e index f0e1badf..b8bab0ff 100644 --- a/library/error/tests/test_error.e +++ b/library/error/tests/test_error.e @@ -108,6 +108,64 @@ feature -- Test routines end + test_remove_sync + note + testing: "error" + local + h1, h2, h3: ERROR_HANDLER +-- cl: CELL [INTEGER] + do + create h1.make + create h2.make + create h3.make + + h1.add_synchronized_handler (h2) + h2.add_synchronized_handler (h3) + h3.add_synchronized_handler (h1) + + h1.add_custom_error (123, "abc", "abc error occurred") + h1.add_custom_error (456, "def", "def error occurred") + + assert ("has 2 errors", h1.count = 2 and h2.count = h1.count and h3.count = h2.count) + + h2.remove_synchronized_handler (h3) + h2.remove_synchronized_handler (h1) + + h1.add_custom_error (789, "ghi", "ghi error occurred") + assert ("correct count of errors", h1.count = 3 and h2.count = 2 and h3.count = h1.count) + + h1.reset + assert ("reset then no error", h1.count = 0 and h2.count = 2 and h3.count = h1.count) + end + + test_destroy + note + testing: "error" + local + h1, h2, h3: ERROR_HANDLER +-- cl: CELL [INTEGER] + do + create h1.make + create h2.make + create h3.make + + h1.add_synchronized_handler (h2) + h2.add_synchronized_handler (h3) + h3.add_synchronized_handler (h1) + + h1.add_custom_error (123, "abc", "abc error occurred") + h1.add_custom_error (456, "def", "def error occurred") + + assert ("has 2 errors", h1.count = 2 and h2.count = h1.count and h3.count = h2.count) + + h2.destroy + + h1.add_custom_error (789, "ghi", "ghi error occurred") + assert ("correct count of errors", h1.count = 3 and h2.count = 0 and h3.count = h1.count) + + h1.reset + assert ("reset then no error", h1.count = 0 and h2.count = h1.count and h3.count = h1.count) + end note copyright: "Copyright (c) 1984-2011, Eiffel Software and others" From 72cc05532cf2bb301ad7765b1362a8d59301b017 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Wed, 15 Feb 2012 11:04:42 +0100 Subject: [PATCH 12/17] Removed tests target from encoder(-safe).ecf (now there is a tests-safe.ecf in folder tests) --- library/text/encoder/encoder-safe.ecf | 13 ------------- library/text/encoder/encoder.ecf | 15 --------------- 2 files changed, 28 deletions(-) diff --git a/library/text/encoder/encoder-safe.ecf b/library/text/encoder/encoder-safe.ecf index bff977f0..7db8d66c 100644 --- a/library/text/encoder/encoder-safe.ecf +++ b/library/text/encoder/encoder-safe.ecf @@ -29,17 +29,4 @@ - - - - /.git$ - /EIFGENs$ - /.svn$ - - - - - diff --git a/library/text/encoder/encoder.ecf b/library/text/encoder/encoder.ecf index 0905930b..5c3184fc 100644 --- a/library/text/encoder/encoder.ecf +++ b/library/text/encoder/encoder.ecf @@ -29,19 +29,4 @@ - - - - - /.git$ - /EIFGENs$ - /.svn$ - - - - - - From 9138ffedfb1acfbc441c3e5a3d2ce64616bc761b Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Wed, 15 Feb 2012 11:07:12 +0100 Subject: [PATCH 13/17] renamed (add|remove)_synchronized_handler as (add|remove)_synchronization --- library/error/src/error_handler.e | 10 +++++----- library/error/tests/test_error.e | 28 ++++++++++++++-------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/library/error/src/error_handler.e b/library/error/src/error_handler.e index 8ee91cdd..e6ff72fa 100644 --- a/library/error/src/error_handler.e +++ b/library/error/src/error_handler.e @@ -63,7 +63,7 @@ feature -- Events feature -- Synchronization - add_synchronized_handler (h: ERROR_HANDLER) + add_synchronization (h: ERROR_HANDLER) -- Add synchronization between `h' and `Current' --| the same handler can be added more than once --| it will be synchronized only once @@ -80,18 +80,18 @@ feature -- Synchronization check attached h.synchronized_handlers as h_lst and then h_lst.has (Current) end else lst.extend (h) - h.add_synchronized_handler (Current) + h.add_synchronization (Current) end end - remove_synchronized_handler (h: ERROR_HANDLER) + remove_synchronization (h: ERROR_HANDLER) -- Remove synchronization between `h' and `Current' do if attached synchronized_handlers as lst and then not lst.is_empty then synchronized_handlers := Void lst.prune_all (h) - h.remove_synchronized_handler (Current) + h.remove_synchronization (Current) synchronized_handlers := lst if lst.is_empty then @@ -294,7 +294,7 @@ feature -- Element changes across lst as c loop - c.item.remove_synchronized_handler (Current) + c.item.remove_synchronization (Current) end end synchronized_handlers := Void diff --git a/library/error/tests/test_error.e b/library/error/tests/test_error.e index b8bab0ff..af7fdec8 100644 --- a/library/error/tests/test_error.e +++ b/library/error/tests/test_error.e @@ -47,7 +47,7 @@ feature -- Test routines do create h1.make create h2.make - h1.add_synchronized_handler (h2) + h1.add_synchronization (h2) h1.add_custom_error (123, "abc", "abc error occurred") h1.add_custom_error (456, "abc", "abc error occurred") @@ -70,8 +70,8 @@ feature -- Test routines create h2.make create h3.make - h1.add_synchronized_handler (h2) - h2.add_synchronized_handler (h3) + h1.add_synchronization (h2) + h2.add_synchronization (h3) h1.add_custom_error (123, "abc", "abc error occurred") h1.add_custom_error (456, "abc", "abc error occurred") @@ -94,9 +94,9 @@ feature -- Test routines create h2.make create h3.make - h1.add_synchronized_handler (h2) - h2.add_synchronized_handler (h3) - h3.add_synchronized_handler (h1) + h1.add_synchronization (h2) + h2.add_synchronization (h3) + h3.add_synchronization (h1) h1.add_custom_error (123, "abc", "abc error occurred") h1.add_custom_error (456, "abc", "abc error occurred") @@ -119,17 +119,17 @@ feature -- Test routines create h2.make create h3.make - h1.add_synchronized_handler (h2) - h2.add_synchronized_handler (h3) - h3.add_synchronized_handler (h1) + h1.add_synchronization (h2) + h2.add_synchronization (h3) + h3.add_synchronization (h1) h1.add_custom_error (123, "abc", "abc error occurred") h1.add_custom_error (456, "def", "def error occurred") assert ("has 2 errors", h1.count = 2 and h2.count = h1.count and h3.count = h2.count) - h2.remove_synchronized_handler (h3) - h2.remove_synchronized_handler (h1) + h2.remove_synchronization (h3) + h2.remove_synchronization (h1) h1.add_custom_error (789, "ghi", "ghi error occurred") assert ("correct count of errors", h1.count = 3 and h2.count = 2 and h3.count = h1.count) @@ -149,9 +149,9 @@ feature -- Test routines create h2.make create h3.make - h1.add_synchronized_handler (h2) - h2.add_synchronized_handler (h3) - h3.add_synchronized_handler (h1) + h1.add_synchronization (h2) + h2.add_synchronization (h3) + h3.add_synchronization (h1) h1.add_custom_error (123, "abc", "abc error occurred") h1.add_custom_error (456, "def", "def error occurred") From 413fdaf6cdab43f0f7b333908365c853e7ecd500 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Wed, 15 Feb 2012 11:33:39 +0100 Subject: [PATCH 14/17] Fixed error visitor due to recent signature changes --- .../error/src/visitor/file_output_error_visitor.e | 12 +++++++++++- library/error/src/visitor/output_error_visitor.e | 4 ++-- .../error/src/visitor/text_output_error_visitor.e | 12 +++++++++++- 3 files changed, 24 insertions(+), 4 deletions(-) diff --git a/library/error/src/visitor/file_output_error_visitor.e b/library/error/src/visitor/file_output_error_visitor.e index 588c4250..49e9493f 100644 --- a/library/error/src/visitor/file_output_error_visitor.e +++ b/library/error/src/visitor/file_output_error_visitor.e @@ -31,7 +31,7 @@ feature -- Access feature -- Output - output_string (a_str: detachable STRING_GENERAL) + output_string (a_str: detachable READABLE_STRING_GENERAL) -- Output Unicode string do if a_str /= Void then @@ -50,4 +50,14 @@ feature -- Output file.put_new_line end +note + copyright: "2011-2012, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" end diff --git a/library/error/src/visitor/output_error_visitor.e b/library/error/src/visitor/output_error_visitor.e index 22d1128d..50b05b3d 100644 --- a/library/error/src/visitor/output_error_visitor.e +++ b/library/error/src/visitor/output_error_visitor.e @@ -13,7 +13,7 @@ inherit feature -- Output - output_string (a_str: detachable STRING_GENERAL) + output_string (a_str: detachable READABLE_STRING_GENERAL) -- Output Unicode string deferred end @@ -21,7 +21,7 @@ feature -- Output output_any (obj: detachable ANY) -- Output Unicode string do - if attached {STRING_GENERAL} obj as l_str then + if attached {READABLE_STRING_GENERAL} obj as l_str then to_implement ("Convert into UTF-8 or console encoding before output") output_string (l_str) elseif obj /= Void then diff --git a/library/error/src/visitor/text_output_error_visitor.e b/library/error/src/visitor/text_output_error_visitor.e index bff7f86f..b79b1b75 100644 --- a/library/error/src/visitor/text_output_error_visitor.e +++ b/library/error/src/visitor/text_output_error_visitor.e @@ -31,7 +31,7 @@ feature -- Access feature -- Output - output_string (a_str: detachable STRING_GENERAL) + output_string (a_str: detachable READABLE_STRING_GENERAL) -- Output Unicode string do if a_str /= Void then @@ -50,4 +50,14 @@ feature -- Output buffer.append_character ('%N') end +note + copyright: "2011-2012, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" end From 5950d768c9a36951314ee1d7ce528efb21b237b6 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Wed, 15 Feb 2012 11:58:32 +0100 Subject: [PATCH 15/17] sync with cURL library --- contrib/ise_library/cURL | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/ise_library/cURL b/contrib/ise_library/cURL index 2b7043f6..ad2a498f 160000 --- a/contrib/ise_library/cURL +++ b/contrib/ise_library/cURL @@ -1 +1 @@ -Subproject commit 2b7043f670f6efc70ebed5fbf62d83a22c095ffe +Subproject commit ad2a498fc067926713ffdc0a9db99358f142fada From e541fdcb0ca2a09750bd9c32e1dc1e4eb2ad14c7 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Wed, 15 Feb 2012 12:36:57 +0100 Subject: [PATCH 16/17] fixed compilation --- .../stream/wgi_chunked_input_stream.e | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 library/server/ewsgi/specification/stream/wgi_chunked_input_stream.e diff --git a/library/server/ewsgi/specification/stream/wgi_chunked_input_stream.e b/library/server/ewsgi/specification/stream/wgi_chunked_input_stream.e new file mode 100644 index 00000000..84c129cd --- /dev/null +++ b/library/server/ewsgi/specification/stream/wgi_chunked_input_stream.e @@ -0,0 +1,21 @@ +note + description: "Summary description for {WGI_CHUNKED_INPUT_STREAM}." + author: "" + date: "$Date$" + revision: "$Revision$" + +deferred +class + WGI_CHUNKED_INPUT_STREAM + +note + copyright: "2011-2012, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" + source: "[ + Eiffel Software + 5949 Hollister Ave., Goleta, CA 93117 USA + Telephone 805-685-1006, Fax 805-685-6869 + Website http://www.eiffel.com + Customer support http://support.eiffel.com + ]" +end From d62198702023f3fc708c7ee86372c9c92ec163f2 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Thu, 16 Feb 2012 10:32:24 +0100 Subject: [PATCH 17/17] Minor correction, to avoid returning 200 as status code, when the client can not connect --- .../libcurl/libcurl_http_client_request.e | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/library/client/http_client/src/spec/libcurl/libcurl_http_client_request.e b/library/client/http_client/src/spec/libcurl/libcurl_http_client_request.e index 520f9fc4..a990914e 100644 --- a/library/client/http_client/src/spec/libcurl/libcurl_http_client_request.e +++ b/library/client/http_client/src/spec/libcurl/libcurl_http_client_request.e @@ -49,7 +49,6 @@ feature -- Execution l_curl_string: CURL_STRING l_url: READABLE_STRING_8 p: POINTER - a_data: CELL [detachable ANY] l_form, l_last: CURL_FORM curl: CURL_EXTERNALS curl_easy: CURL_EASY_EXTERNALS @@ -203,22 +202,32 @@ feature -- Execution l_result := curl_easy.perform (curl_handle) if l_result = {CURL_CODES}.curle_ok then - create a_data.put (Void) - l_result := curl_easy.getinfo (curl_handle, {CURL_INFO_CONSTANTS}.curlinfo_response_code, a_data) - if l_result = 0 and then attached {INTEGER} a_data.item as l_http_status then - Result.status := l_http_status - else - Result.status := 0 - end - + Result.status := response_status_code (curl_easy, curl_handle) set_header_and_body_to (l_curl_string.string, Result) else Result.set_error_occurred (True) + Result.status := response_status_code (curl_easy, curl_handle) end curl_easy.cleanup (curl_handle) end +feature {NONE} -- Implementation + + response_status_code (curl_easy: CURL_EASY_EXTERNALS; curl_handle: POINTER): INTEGER + local + l_result: INTEGER + a_data: CELL [detachable ANY] + do + create a_data.put (Void) + l_result := curl_easy.getinfo (curl_handle, {CURL_INFO_CONSTANTS}.curlinfo_response_code, a_data) + if l_result = 0 and then attached {INTEGER} a_data.item as l_http_status then + Result := l_http_status + else + Result := 0 + end + end + set_header_and_body_to (a_source: READABLE_STRING_8; res: HTTP_CLIENT_RESPONSE) -- Parse `a_source' response