diff --git a/examples/restbucksCRUD/restbucks-safe.ecf b/examples/restbucksCRUD/restbucks-safe.ecf index 5e884262..30267388 100644 --- a/examples/restbucksCRUD/restbucks-safe.ecf +++ b/examples/restbucksCRUD/restbucks-safe.ecf @@ -1,5 +1,5 @@ - + @@ -9,7 +9,7 @@ @@ -21,9 +21,9 @@ - + - + diff --git a/library/server/wsf/extension/wsf_method_handler.e b/library/server/wsf/extension/wsf_method_handler.e index ace5fde8..b0eb5743 100644 --- a/library/server/wsf/extension/wsf_method_handler.e +++ b/library/server/wsf/extension/wsf_method_handler.e @@ -19,7 +19,7 @@ feature -- Method ensure valid_response_for_http_1_0: is_1_0 (a_req.server_protocol) implies valid_response_for_http_1_0 (a_res.status_code) - empty_body_for_no_content_response: is_no_content_response(a_res.status_code) implies a_res.transfered_content_length = 0 -- Is that the right measure? + empty_body_for_no_content_response: is_no_content_response (a_res.status_code) implies is_empty_content (a_res) end feature -- Contract support @@ -60,5 +60,13 @@ feature -- Contract support end end + is_empty_content (a_res: WSF_RESPONSE): BOOLEAN + -- Does `a_res' not contain an entity? + require + a_res_not_void: a_res /= Void + do + Result := a_res.transfered_content_length = 0 -- Is that the right measure? + end + end diff --git a/library/server/wsf/extension/wsf_method_handlers.e b/library/server/wsf/extension/wsf_method_handlers.e index 4552279d..7fdae634 100644 --- a/library/server/wsf/extension/wsf_method_handlers.e +++ b/library/server/wsf/extension/wsf_method_handlers.e @@ -49,7 +49,30 @@ inherit feature -- Method - + do_head (a_req: WSF_REQUEST; a_res: WSF_RESPONSE) + -- Respond to `a_req' using `a_res'. + deferred + ensure then + empty_body: is_empty_content (a_res) + end + + do_post (a_req: WSF_REQUEST; a_res: WSF_RESPONSE) + -- Respond to `a_req' using `a_res'. + deferred + ensure then + non_empty_body: a_res.status_code = {HTTP_STATUS_CODE}.created implies + not is_empty_content (a_res) + location_header: a_res.status_code = {HTTP_STATUS_CODE}.created implies True -- WSF_RESPONSE needs enhancing + end + + do_trace (a_req: WSF_REQUEST; a_res: WSF_RESPONSE) + -- Respond to `a_req' using `a_res'. + deferred + ensure then + non_empty_body: a_res.status_code = {HTTP_STATUS_CODE}.ok implies + not is_empty_content (a_res) + end + end diff --git a/library/server/wsf/extension/wsf_resource_handler_helper.e b/library/server/wsf/extension/wsf_resource_handler_helper.e index 6c432b05..9e382e24 100644 --- a/library/server/wsf/extension/wsf_resource_handler_helper.e +++ b/library/server/wsf/extension/wsf_resource_handler_helper.e @@ -178,6 +178,7 @@ feature -- Method OPTIONS do_options (req: WSF_REQUEST; res: WSF_RESPONSE) do + -- TODO - implement a default method that lists the accepted methods for the resource. handle_not_implemented ("Method OPTIONS not implemented", req, res) end diff --git a/library/server/wsf/router/wsf_router.e b/library/server/wsf/router/wsf_router.e index 68db1375..bbe24b58 100644 --- a/library/server/wsf/router/wsf_router.e +++ b/library/server/wsf/router/wsf_router.e @@ -53,7 +53,7 @@ feature -- Mapping map_with_request_methods (a_mapping: WSF_ROUTER_MAPPING; rqst_methods: detachable WSF_ROUTER_METHODS) -- Map `a_mapping' for request methods `rqst_methods' do - if attached rqst_methods as l_rm and then l_rm.has ("GET") then + if attached rqst_methods as l_rm and then l_rm.has ({HTTP_REQUEST_METHODS}.method_get) then l_rm.enable_head end mappings.extend (create {WSF_ROUTER_ITEM}.make_with_request_methods (a_mapping, rqst_methods))