From 4d7660a9e3962b93f6fc428946009ce4d6f1577f Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Mon, 18 Mar 2013 22:05:34 +0100 Subject: [PATCH] Added deferred WSF_AGENT_HANDLER Added WSF_NOT_IMPLEMENTED_RESPONSE --- .../uri/helpers/wsf_uri_agent_handler.e | 23 ++---- .../helpers/wsf_uri_template_agent_handler.e | 23 ++---- library/server/wsf/router/wsf_agent_handler.e | 41 ++++++++++ .../response/wsf_not_implemented_response.e | 80 +++++++++++++++++++ 4 files changed, 133 insertions(+), 34 deletions(-) create mode 100644 library/server/wsf/router/wsf_agent_handler.e create mode 100644 library/server/wsf/src/response/wsf_not_implemented_response.e diff --git a/library/server/wsf/router/support/uri/helpers/wsf_uri_agent_handler.e b/library/server/wsf/router/support/uri/helpers/wsf_uri_agent_handler.e index 9750cc81..b2a5089c 100644 --- a/library/server/wsf/router/support/uri/helpers/wsf_uri_agent_handler.e +++ b/library/server/wsf/router/support/uri/helpers/wsf_uri_agent_handler.e @@ -10,27 +10,16 @@ class inherit WSF_URI_HANDLER + WSF_AGENT_HANDLER + rename + set_action as make + end + create make -feature {NONE} -- Initialization - - make (a_action: like action) - do - action := a_action - end - - action: PROCEDURE [ANY, TUPLE [request: WSF_REQUEST; response: WSF_RESPONSE]] - -feature -- Execution - - execute (req: WSF_REQUEST; res: WSF_RESPONSE) - do - action.call ([req, res]) - end - note - copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" + 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 diff --git a/library/server/wsf/router/support/uri_template/helpers/wsf_uri_template_agent_handler.e b/library/server/wsf/router/support/uri_template/helpers/wsf_uri_template_agent_handler.e index 477e0545..c8e83fc0 100644 --- a/library/server/wsf/router/support/uri_template/helpers/wsf_uri_template_agent_handler.e +++ b/library/server/wsf/router/support/uri_template/helpers/wsf_uri_template_agent_handler.e @@ -10,27 +10,16 @@ class inherit WSF_URI_TEMPLATE_HANDLER + WSF_AGENT_HANDLER + rename + set_action as make + end + create make -feature {NONE} -- Initialization - - make (a_action: like action) - do - action := a_action - end - - action: PROCEDURE [ANY, TUPLE [request: WSF_REQUEST; response: WSF_RESPONSE]] - -feature -- Execution - - execute (req: WSF_REQUEST; res: WSF_RESPONSE) - do - action.call ([req, res]) - end - note - copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others" + 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 diff --git a/library/server/wsf/router/wsf_agent_handler.e b/library/server/wsf/router/wsf_agent_handler.e new file mode 100644 index 00000000..3a25afef --- /dev/null +++ b/library/server/wsf/router/wsf_agent_handler.e @@ -0,0 +1,41 @@ +note + description: "Summary description for {WSF_AGENT_HANDLER}." + author: "" + date: "$Date$" + revision: "$Revision$" + +deferred class + WSF_AGENT_HANDLER + +inherit + WSF_HANDLER + +feature -- Change + + set_action (a_action: like action) + do + action := a_action + end + +feature -- Access + + action: PROCEDURE [ANY, TUPLE [request: WSF_REQUEST; response: WSF_RESPONSE]] + +feature -- Execution + + execute (req: WSF_REQUEST; res: WSF_RESPONSE) + do + action.call ([req, res]) + end + +note + copyright: "2011-2012, 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 diff --git a/library/server/wsf/src/response/wsf_not_implemented_response.e b/library/server/wsf/src/response/wsf_not_implemented_response.e new file mode 100644 index 00000000..297dafc3 --- /dev/null +++ b/library/server/wsf/src/response/wsf_not_implemented_response.e @@ -0,0 +1,80 @@ +note + description: "[ + This class is used to report a 501 not implemented + ]" + date: "$Date$" + revision: "$Revision$" + +class + WSF_NOT_IMPLEMENTED_RESPONSE + +inherit + WSF_RESPONSE_MESSAGE + + SHARED_HTML_ENCODER + +create + make + +feature {NONE} -- Initialization + + make (req: WSF_REQUEST) + do + create header.make + request := req + end + +feature -- Header + + header: HTTP_HEADER + -- Response' header + + request: WSF_REQUEST + -- Associated request. + + body: detachable READABLE_STRING_8 + -- Optional body + -- Displayed as extra content + +feature -- Element change + + set_body (b: like body) + -- Set `body' to `b' + do + body := b + end + +feature {WSF_RESPONSE} -- Output + + send_to (res: WSF_RESPONSE) + local + s: STRING + h: like header + do + h := header + res.set_status_code ({HTTP_STATUS_CODE}.not_implemented) + + s := "Error 501 Not Implemented !" + if attached body as b then + s.append ("%N") + s.append (b) + s.append ("%N") + end + h.put_content_type_text_plain + h.put_content_length (s.count) + res.put_header_text (h.string) + res.put_string (s) + res.flush + end + +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