From a7e1be115af6e06b0581b2775cf471a2d81f9be0 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Fri, 29 Mar 2013 23:01:37 +0100 Subject: [PATCH] Added a maintenance filter --- .../wsf/router/filter/wsf_maintenant_filter.e | 85 +++++++++++++++++++ 1 file changed, 85 insertions(+) create mode 100644 library/server/wsf/router/filter/wsf_maintenant_filter.e diff --git a/library/server/wsf/router/filter/wsf_maintenant_filter.e b/library/server/wsf/router/filter/wsf_maintenant_filter.e new file mode 100644 index 00000000..e88ac3b7 --- /dev/null +++ b/library/server/wsf/router/filter/wsf_maintenant_filter.e @@ -0,0 +1,85 @@ +note + description: "Maintenance filter." + date: "$Date$" + revision: "$Revision$" + +class + WSF_MAINTENANCE_FILTER + +inherit + WSF_FILTER + redefine + default_create + end + +create + default_create, + make_with_name + +feature {NONE} -- Initialization + + default_create + do + Precursor + make_with_name (".maintenance_fn") + end + + make_with_name (fn: like maintenance_fn) + do + maintenance_fn := fn + end + + maintenance_fn: READABLE_STRING_GENERAL + +feature -- Basic operations + + execute (req: WSF_REQUEST; res: WSF_RESPONSE) + -- Execute the filter + local + s: STRING + h: HTTP_HEADER + f: PLAIN_TEXT_FILE + do + create f.make_with_name (maintenance_fn) + if f.exists then + create s.make (64) + if f.is_access_readable then + f.open_read + from + until + f.exhausted + loop + f.read_line + s.append (f.last_string) + s.append_character ('%N') + end + f.close + end + if s.is_empty then + s.append ("In maintenance, please come back later ...") + end + create h.make_with_count (1) + h.put_content_length (s.count) + h.put_content_type_text_plain + res.put_header_lines (h) + res.put_string (s) + else + execute_next (req, res) + end + end + +feature -- Constants + + Date_time_format: STRING = "[0]dd/[0]mm/yyyy [0]hh:[0]mi:[0]ss" + +note + copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, 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