diff --git a/library/server/wsf/router/wsf_routed_service.e b/library/server/wsf/router/wsf_routed_service.e index 9f201eed..e6445e60 100644 --- a/library/server/wsf/router/wsf_routed_service.e +++ b/library/server/wsf/router/wsf_routed_service.e @@ -48,22 +48,9 @@ feature -- Execution execute_default (req: WSF_REQUEST; res: WSF_RESPONSE) -- Default procedure local - msg: WSF_RESPONSE_MESSAGE - not_found: WSF_NOT_FOUND_RESPONSE - not_allowed: WSF_METHOD_NOT_ALLOWED_RESPONSE - trace: WSF_TRACE_RESPONSE + msg: WSF_DEFAULT_ROUTER_RESPONSE do - if req.is_request_method ({HTTP_REQUEST_METHODS}.method_trace) then - create trace.make (req) - msg := trace - elseif attached router.allowed_methods_for_request (req) as mtds and then not mtds.is_empty then - create not_allowed.make (req) - not_allowed.set_suggested_methods (mtds) - msg := not_allowed - else - create not_found.make (req) - msg := not_found - end + create msg.make_with_router (req, router) res.send (msg) end diff --git a/library/server/wsf/src/response/wsf_default_response.e b/library/server/wsf/src/response/wsf_default_response.e new file mode 100644 index 00000000..f1ae9d32 --- /dev/null +++ b/library/server/wsf/src/response/wsf_default_response.e @@ -0,0 +1,53 @@ +note + description: "Summary description for {WSF_DEFAULT_RESPONSE}." + author: "" + date: "$Date$" + revision: "$Revision$" + +class + WSF_DEFAULT_RESPONSE + +inherit + WSF_RESPONSE_MESSAGE + +create + make + +feature {NONE} -- Initialization + + make (req: WSF_REQUEST) + -- Initialize Current with request `req' + do + request := req + end + +feature -- Access + + request: WSF_REQUEST + -- Associated request. + +feature {WSF_RESPONSE} -- Output + + send_to (res: WSF_RESPONSE) + -- Send Current message to `res' + -- + -- This feature should be called via `{WSF_RESPONSE}.send (obj)' + -- where `obj' is the current object + local + msg: WSF_RESPONSE_MESSAGE + req: like request + not_found: WSF_NOT_FOUND_RESPONSE + trace: WSF_TRACE_RESPONSE + do + req := request + if req.is_request_method ({HTTP_REQUEST_METHODS}.method_trace) then + create trace.make (req) + msg := trace + else + create not_found.make (req) + msg := not_found + end + res.send (msg) + end + +end diff --git a/library/server/wsf/src/response/wsf_default_router_response.e b/library/server/wsf/src/response/wsf_default_router_response.e new file mode 100644 index 00000000..22d4a329 --- /dev/null +++ b/library/server/wsf/src/response/wsf_default_router_response.e @@ -0,0 +1,63 @@ +note + description: "Summary description for {WSF_DEFAULT_ROUTER_RESPONSE}." + date: "$Date$" + revision: "$Revision$" + +class + WSF_DEFAULT_ROUTER_RESPONSE + +inherit + WSF_DEFAULT_RESPONSE + redefine + send_to + end + +create + make_with_router + +feature {NONE} -- Initialization + + make_with_router (req: WSF_REQUEST; a_router: like router) + -- Initialize Current with request `req' and router `a_router' + -- Initialize Current with request `req' + do + router := a_router + make (req) + end + +feature -- Access + + router: WSF_ROUTER + -- Associated router. + +feature {WSF_RESPONSE} -- Output + + send_to (res: WSF_RESPONSE) + -- Send Current message to `res' + -- + -- This feature should be called via `{WSF_RESPONSE}.send (obj)' + -- where `obj' is the current object + local + msg: WSF_RESPONSE_MESSAGE + req: like request + not_found: WSF_NOT_FOUND_RESPONSE + not_allowed: WSF_METHOD_NOT_ALLOWED_RESPONSE + trace: WSF_TRACE_RESPONSE + do + req := request + if req.is_request_method ({HTTP_REQUEST_METHODS}.method_trace) then + create trace.make (req) + msg := trace + elseif attached router.allowed_methods_for_request (req) as mtds and then not mtds.is_empty then + create not_allowed.make (req) + not_allowed.set_suggested_methods (mtds) + msg := not_allowed + else + create not_found.make (req) + + msg := not_found + end + res.send (msg) + end + +end diff --git a/library/server/wsf/src/response/wsf_method_not_allowed_response.e b/library/server/wsf/src/response/wsf_method_not_allowed_response.e index d92be555..83a32384 100644 --- a/library/server/wsf/src/response/wsf_method_not_allowed_response.e +++ b/library/server/wsf/src/response/wsf_method_not_allowed_response.e @@ -54,6 +54,11 @@ feature {WSF_RESPONSE} -- Output do h := header res.set_status_code ({HTTP_STATUS_CODE}.method_not_allowed) + + if attached suggested_methods as lst and then not lst.is_empty then + h.put_allow (lst) + end + s := "Not allowed" if request.is_content_type_accepted ({HTTP_MIME_TYPES}.text_html) then @@ -119,6 +124,7 @@ feature {WSF_RESPONSE} -- Output end h.put_content_type_text_plain end + h.put_content_length (s.count) res.put_header_text (h.string) res.put_string (s)