Removed generic parameter in WSF_FILTER_HANDLER, since it is useless and make code heavy
Signed-off-by: Olivier Ligot <oligot@gmail.com> Signed-off-by: Jocelyn Fiat <jfiat@eiffel.com>
This commit is contained in:
@@ -23,17 +23,21 @@ feature -- Basic operations
|
||||
execute_delete (ctx, req, res)
|
||||
elseif m.same_string ({HTTP_REQUEST_METHODS}.method_post) then
|
||||
execute_post (ctx, req, res)
|
||||
elseif m.same_string ({HTTP_REQUEST_METHODS}.method_trace) then
|
||||
execute_trace (ctx, req, res)
|
||||
elseif m.same_string ({HTTP_REQUEST_METHODS}.method_options) then
|
||||
execute_options (ctx, req, res)
|
||||
elseif m.same_string ({HTTP_REQUEST_METHODS}.method_head) then
|
||||
execute_head (ctx, req, res)
|
||||
elseif m.same_string ({HTTP_REQUEST_METHODS}.method_connect) then
|
||||
execute_connect (ctx, req, res)
|
||||
else
|
||||
--| Eventually handle other methods...
|
||||
execute_extension_method (ctx, req, res)
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
feature -- Method Get
|
||||
|
||||
execute_get (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
@@ -52,6 +56,8 @@ feature {NONE} -- Implementation
|
||||
handle_not_implemented ("Method GET not implemented", req, res)
|
||||
end
|
||||
|
||||
feature -- Method Post
|
||||
|
||||
execute_post (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
if req.is_chunked_input then
|
||||
@@ -78,6 +84,8 @@ feature {NONE} -- Implementation
|
||||
handle_not_implemented ("Method POST not implemented", req, res)
|
||||
end
|
||||
|
||||
feature-- Method Put
|
||||
|
||||
execute_put (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
if req.is_chunked_input then
|
||||
@@ -96,20 +104,36 @@ feature {NONE} -- Implementation
|
||||
handle_not_implemented ("Method PUT not implemented", req, res)
|
||||
end
|
||||
|
||||
feature -- Method DELETE
|
||||
|
||||
execute_delete (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
do_delete (ctx, req, res)
|
||||
end
|
||||
|
||||
do_delete (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Here we use DELETE to logically delete a person.
|
||||
-- 204 if is ok
|
||||
-- 404 Resource not found
|
||||
-- 500 if we have an internal server error
|
||||
-- Here we use DELETE to logically delete a person.
|
||||
-- 204 if is ok
|
||||
-- 404 Resource not found
|
||||
-- 500 if we have an internal server error
|
||||
do
|
||||
handle_not_implemented ("Method DELETE not implemented", req, res)
|
||||
end
|
||||
|
||||
feature -- Method CONNECT
|
||||
|
||||
execute_connect (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
do_connect (ctx, req, res)
|
||||
end
|
||||
|
||||
do_connect (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
handle_not_implemented ("Method CONNECT not implemented", req, res)
|
||||
end
|
||||
|
||||
feature -- Method HEAD
|
||||
|
||||
execute_head (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
do_head (ctx, req, res)
|
||||
@@ -127,6 +151,8 @@ feature {NONE} -- Implementation
|
||||
handle_not_implemented ("Method HEAD not implemented", req, res)
|
||||
end
|
||||
|
||||
feature -- Method OPTIONS
|
||||
|
||||
execute_options (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
do_options (ctx, req, res)
|
||||
@@ -139,6 +165,20 @@ feature {NONE} -- Implementation
|
||||
handle_not_implemented ("Method OPTIONS not implemented", req, res)
|
||||
end
|
||||
|
||||
feature -- Method TRACE
|
||||
|
||||
execute_trace (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
do_trace (ctx, req, res)
|
||||
end
|
||||
|
||||
do_trace (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
handle_not_implemented ("Method TRACE not implemented", req, res)
|
||||
end
|
||||
|
||||
feature -- Method Extension Method
|
||||
|
||||
execute_extension_method (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
do_extension_method (ctx, req, res)
|
||||
@@ -149,13 +189,25 @@ feature {NONE} -- Implementation
|
||||
handle_not_implemented ("Method extension-method not implemented", req, res)
|
||||
end
|
||||
|
||||
feature -- Handle responses
|
||||
-- TODO Handle Content negotiation.
|
||||
-- The option : Server-driven negotiation: uses request headers to select a variant
|
||||
-- More info : http://www.w3.org/Protocols/rfc2616/rfc2616-sec12.html#sec12
|
||||
|
||||
-- supported_content_types: detachable ARRAY [READABLE_STRING_8]
|
||||
-- -- Supported content types
|
||||
-- -- Can be redefined
|
||||
-- do
|
||||
-- Result := Void
|
||||
-- end
|
||||
|
||||
handle_error (a_description: STRING; a_status_code: INTEGER; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
-- Handle an error.
|
||||
local
|
||||
h: HTTP_HEADER
|
||||
do
|
||||
create h.make
|
||||
h.put_content_type_application_json
|
||||
h.put_content_type_text_plain
|
||||
h.put_content_length (a_description.count)
|
||||
h.put_current_date
|
||||
res.set_status_code (a_status_code)
|
||||
@@ -184,8 +236,35 @@ feature {NONE} -- Implementation
|
||||
handle_error (a_description, {HTTP_STATUS_CODE}.forbidden, req, res)
|
||||
end
|
||||
|
||||
feature -- Handle responses: others
|
||||
|
||||
handle_precondition_fail_response (a_description: STRING; req: WSF_REQUEST; res: WSF_RESPONSE )
|
||||
do
|
||||
handle_error (a_description, {HTTP_STATUS_CODE}.precondition_failed, req, res)
|
||||
end
|
||||
|
||||
handle_internal_server_error (a_description: STRING; req: WSF_REQUEST; res: WSF_RESPONSE )
|
||||
do
|
||||
handle_error (a_description, {HTTP_STATUS_CODE}.internal_server_error, req, res)
|
||||
end
|
||||
|
||||
handle_method_not_allowed_response (a_description: STRING; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
handle_error (a_description, {HTTP_STATUS_CODE}.method_not_allowed, req, res)
|
||||
end
|
||||
|
||||
handle_resource_not_modified_response (a_description: STRING; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
handle_error (a_description, {HTTP_STATUS_CODE}.not_modified, req, res)
|
||||
end
|
||||
|
||||
handle_resource_conflict_response (a_description: STRING; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
handle_error (a_description, {HTTP_STATUS_CODE}.conflict, req, res)
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user