Response to comments from review "Contracts for non-Void-safe users (take 1)"

This commit is contained in:
Colin Adams
2013-03-14 14:17:03 +00:00
parent ca5619c6fc
commit 4ec2832375
3 changed files with 19 additions and 20 deletions

View File

@@ -50,7 +50,7 @@ feature -- Method Get
require require
req_attached: req /= Void req_attached: req /= Void
res_attached: res /= Void res_attached: res /= Void
get_method: req.request_method.as_upper.same_string ({HTTP_REQUEST_METHODS}.method_get) get_method: req.is_request_method ({HTTP_REQUEST_METHODS}.method_get)
do do
do_get (req, res) do_get (req, res)
end end
@@ -74,7 +74,7 @@ feature -- Method Post
require require
req_attached: req /= Void req_attached: req /= Void
res_attached: res /= Void res_attached: res /= Void
post_method: req.request_method.as_upper.same_string ({HTTP_REQUEST_METHODS}.method_post) post_method: req.is_request_method ({HTTP_REQUEST_METHODS}.method_post)
do do
if req.is_chunked_input then if req.is_chunked_input then
do_post (req, res) do_post (req, res)
@@ -107,7 +107,7 @@ feature-- Method Put
require require
req_attached: req /= Void req_attached: req /= Void
res_attached: res /= Void res_attached: res /= Void
put_method: req.request_method.as_upper.same_string ({HTTP_REQUEST_METHODS}.method_put) put_method: req.is_request_method ({HTTP_REQUEST_METHODS}.method_put)
do do
if req.is_chunked_input then if req.is_chunked_input then
do_put (req, res) do_put (req, res)
@@ -132,7 +132,7 @@ feature -- Method DELETE
require require
req_attached: req /= Void req_attached: req /= Void
res_attached: res /= Void res_attached: res /= Void
delete_method: req.request_method.as_upper.same_string ({HTTP_REQUEST_METHODS}.method_delete) delete_method: req.is_request_method ({HTTP_REQUEST_METHODS}.method_delete)
do do
do_delete (req, res) do_delete (req, res)
end end
@@ -153,7 +153,7 @@ feature -- Method CONNECT
require require
req_attached: req /= Void req_attached: req /= Void
res_attached: res /= Void res_attached: res /= Void
connect_method: req.request_method.as_upper.same_string ({HTTP_REQUEST_METHODS}.method_connect) connect_method: req.is_request_method ({HTTP_REQUEST_METHODS}.method_connect)
do do
do_connect (req, res) do_connect (req, res)
end end
@@ -170,7 +170,7 @@ feature -- Method HEAD
require require
req_attached: req /= Void req_attached: req /= Void
res_attached: res /= Void res_attached: res /= Void
head_method: req.request_method.as_upper.same_string ({HTTP_REQUEST_METHODS}.method_head) head_method: req.is_request_method ({HTTP_REQUEST_METHODS}.method_head)
do do
do_head (req, res) do_head (req, res)
end end
@@ -194,7 +194,7 @@ feature -- Method OPTIONS
require require
req_attached: req /= Void req_attached: req /= Void
res_attached: res /= Void res_attached: res /= Void
options_method: req.request_method.as_upper.same_string ({HTTP_REQUEST_METHODS}.method_options) options_method: req.is_request_method ({HTTP_REQUEST_METHODS}.method_options)
do do
do_options (req, res) do_options (req, res)
end end
@@ -212,7 +212,7 @@ feature -- Method TRACE
require require
req_attached: req /= Void req_attached: req /= Void
res_attached: res /= Void res_attached: res /= Void
trace_method: req.request_method.as_upper.same_string ({HTTP_REQUEST_METHODS}.method_trace) trace_method: req.is_request_method ({HTTP_REQUEST_METHODS}.method_trace)
do do
do_trace (req, res) do_trace (req, res)
end end
@@ -260,13 +260,6 @@ feature -- Handle responses
-- The option : Server-driven negotiation: uses request headers to select a variant -- The option : Server-driven negotiation: uses request headers to select a variant
-- More info : http://www.w3.org/Protocols/rfc2616/rfc2616-sec12.html#sec12 -- 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
-- TODO: review HTTP requirements on `a_description' for each individual error code. -- TODO: review HTTP requirements on `a_description' for each individual error code.
handle_error (a_description: STRING; a_status_code: INTEGER; req: WSF_REQUEST; res: WSF_RESPONSE) handle_error (a_description: STRING; a_status_code: INTEGER; req: WSF_REQUEST; res: WSF_RESPONSE)

View File

@@ -55,7 +55,7 @@ feature {NONE} -- Initialization
end end
make (n: INTEGER) make (n: INTEGER)
-- Initialize with space for `n' methods. -- Initialize with capacity for `n' methods.
require require
valid_number_of_items: n >= 0 valid_number_of_items: n >= 0
do do
@@ -65,7 +65,7 @@ feature {NONE} -- Initialization
make_from_iterable (v: ITERABLE [READABLE_STRING_8]) make_from_iterable (v: ITERABLE [READABLE_STRING_8])
-- Initialize for all methods named by `v'. -- Initialize for all methods named by `v'.
require require
v_attached: v /= Void v_all_methods_attached: v /= Void and then True -- Can this be specified using across? It's annoying that ITERABLE doesn't have for_all.
do do
make (1) make (1)
add_methods (v) add_methods (v)
@@ -427,7 +427,9 @@ feature {WSF_REQUEST_METHODS} -- Implementation
across across
lst as c lst as c
loop loop
add_method_using_constant (c.item) if not c.item.is_empty and not has (c.item) then
add_method_using_constant (c.item)
end
end end
end end
end end
@@ -438,6 +440,8 @@ feature {NONE} -- Implementation
-- Add method `v' using method_* constant. -- Add method `v' using method_* constant.
require require
v_attached: v /= Void v_attached: v /= Void
v_not_empty: not v.is_empty
new_method: not has (v)
do do
if v.is_case_insensitive_equal (method_get) then if v.is_case_insensitive_equal (method_get) then
enable_get enable_get

View File

@@ -134,7 +134,8 @@ feature -- Basic operations
dispatch_and_return_handler (req: WSF_REQUEST; res: WSF_RESPONSE): detachable WSF_HANDLER dispatch_and_return_handler (req: WSF_REQUEST; res: WSF_RESPONSE): detachable WSF_HANDLER
-- Dispatch request `req' among the `mappings' -- Dispatch request `req' among the `mappings'
-- And return the associated handler (violating CQS) if mapping found and handler executed. -- And return the associated handler if mapping found and handler executed.
--| Violates CQS
require require
req_attached: req /= Void req_attached: req /= Void
res_attached: res /= Void res_attached: res /= Void
@@ -157,7 +158,8 @@ feature {NONE} -- Dispatch implementation
dispatch_and_return_handler_for_request_method (req: WSF_REQUEST; res: WSF_RESPONSE; a_request_method: READABLE_STRING_8): detachable WSF_HANDLER dispatch_and_return_handler_for_request_method (req: WSF_REQUEST; res: WSF_RESPONSE; a_request_method: READABLE_STRING_8): detachable WSF_HANDLER
-- Dispatch request `req' among the `mappings' -- Dispatch request `req' among the `mappings'
-- And return the associated handler (violating CQS) if mapping found and handler executed. -- And return the associated handler if mapping found and handler executed.
--| Violates CQS
require require
req_attached: req /= Void req_attached: req /= Void
res_attached: res /= Void res_attached: res /= Void