Actioned Jocelyns comments re. a_req and a_res
This commit is contained in:
@@ -53,21 +53,21 @@ feature -- API DOC
|
|||||||
|
|
||||||
feature -- HTTP Methods
|
feature -- HTTP Methods
|
||||||
|
|
||||||
do_get (a_req: WSF_REQUEST; a_res: WSF_RESPONSE)
|
do_get (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||||
-- <Precursor>
|
-- <Precursor>
|
||||||
local
|
local
|
||||||
id: STRING
|
id: STRING
|
||||||
do
|
do
|
||||||
if attached a_req.orig_path_info as orig_path then
|
if attached req.orig_path_info as orig_path then
|
||||||
id := get_order_id_from_path (orig_path)
|
id := get_order_id_from_path (orig_path)
|
||||||
if attached retrieve_order (id) as l_order then
|
if attached retrieve_order (id) as l_order then
|
||||||
if is_conditional_get (a_req, l_order) then
|
if is_conditional_get (req, l_order) then
|
||||||
handle_resource_not_modified_response ("The resource" + orig_path + "does not change", a_req, a_res)
|
handle_resource_not_modified_response ("The resource" + orig_path + "does not change", req, res)
|
||||||
else
|
else
|
||||||
compute_response_get (a_req, a_res, l_order)
|
compute_response_get (req, res, l_order)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
handle_resource_not_found_response ("The following resource" + orig_path + " is not found ", a_req, a_res)
|
handle_resource_not_found_response ("The following resource" + orig_path + " is not found ", req, res)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -87,7 +87,7 @@ feature -- HTTP Methods
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
compute_response_get (a_req: WSF_REQUEST; a_res: WSF_RESPONSE; l_order: ORDER)
|
compute_response_get (req: WSF_REQUEST; res: WSF_RESPONSE; l_order: ORDER)
|
||||||
local
|
local
|
||||||
h: HTTP_HEADER
|
h: HTTP_HEADER
|
||||||
l_msg : STRING
|
l_msg : STRING
|
||||||
@@ -99,13 +99,13 @@ feature -- HTTP Methods
|
|||||||
if attached {JSON_VALUE} json.value (l_order) as jv then
|
if attached {JSON_VALUE} json.value (l_order) as jv then
|
||||||
l_msg := jv.representation
|
l_msg := jv.representation
|
||||||
h.put_content_length (l_msg.count)
|
h.put_content_length (l_msg.count)
|
||||||
if attached a_req.request_time as time then
|
if attached req.request_time as time then
|
||||||
h.add_header ("Date:" + time.formatted_out ("ddd,[0]dd mmm yyyy [0]hh:[0]mi:[0]ss.ff2") + " GMT")
|
h.add_header ("Date:" + time.formatted_out ("ddd,[0]dd mmm yyyy [0]hh:[0]mi:[0]ss.ff2") + " GMT")
|
||||||
end
|
end
|
||||||
h.add_header ("etag:" + etag_utils.md5_digest (l_order.out))
|
h.add_header ("etag:" + etag_utils.md5_digest (l_order.out))
|
||||||
a_res.set_status_code ({HTTP_STATUS_CODE}.ok)
|
res.set_status_code ({HTTP_STATUS_CODE}.ok)
|
||||||
a_res.put_header_text (h.string)
|
res.put_header_text (h.string)
|
||||||
a_res.put_string (l_msg)
|
res.put_string (l_msg)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -10,16 +10,16 @@ deferred class WSF_METHOD_HANDLER
|
|||||||
|
|
||||||
feature -- Method
|
feature -- Method
|
||||||
|
|
||||||
do_method (a_req: WSF_REQUEST; a_res: WSF_RESPONSE)
|
do_method (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||||
-- Respond to `a_req' using `a_res'.
|
-- Respond to `req' using `res'.
|
||||||
require
|
require
|
||||||
a_req_not_void: a_req /= Void
|
req_not_void: req /= Void
|
||||||
a_res_not_void: a_res /= Void
|
res_not_void: res /= Void
|
||||||
deferred
|
deferred
|
||||||
ensure
|
ensure
|
||||||
valid_response_for_http_1_0: is_1_0 (a_req.server_protocol) implies
|
valid_response_for_http_1_0: is_1_0 (req.server_protocol) implies
|
||||||
valid_response_for_http_1_0 (a_res.status_code)
|
valid_response_for_http_1_0 (res.status_code)
|
||||||
empty_body_for_no_content_response: is_no_content_response (a_res.status_code) implies is_empty_content (a_res)
|
empty_body_for_no_content_response: is_no_content_response (res.status_code) implies is_empty_content (res)
|
||||||
end
|
end
|
||||||
|
|
||||||
feature -- Contract support
|
feature -- Contract support
|
||||||
@@ -60,12 +60,12 @@ feature -- Contract support
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
is_empty_content (a_res: WSF_RESPONSE): BOOLEAN
|
is_empty_content (res: WSF_RESPONSE): BOOLEAN
|
||||||
-- Does `a_res' not contain an entity?
|
-- Does `res' not contain an entity?
|
||||||
require
|
require
|
||||||
a_res_not_void: a_res /= Void
|
res_not_void: res /= Void
|
||||||
do
|
do
|
||||||
Result := a_res.transfered_content_length = 0 -- Is that the right measure?
|
Result := res.transfered_content_length = 0 -- Is that the right measure?
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -49,28 +49,28 @@ inherit
|
|||||||
|
|
||||||
feature -- Method
|
feature -- Method
|
||||||
|
|
||||||
do_head (a_req: WSF_REQUEST; a_res: WSF_RESPONSE)
|
do_head (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||||
-- Respond to `a_req' using `a_res'.
|
-- Respond to `req' using `res'.
|
||||||
deferred
|
deferred
|
||||||
ensure then
|
ensure then
|
||||||
empty_body: is_empty_content (a_res)
|
empty_body: is_empty_content (res)
|
||||||
end
|
end
|
||||||
|
|
||||||
do_post (a_req: WSF_REQUEST; a_res: WSF_RESPONSE)
|
do_post (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||||
-- Respond to `a_req' using `a_res'.
|
-- Respond to `req' using `res'.
|
||||||
deferred
|
deferred
|
||||||
ensure then
|
ensure then
|
||||||
non_empty_body: a_res.status_code = {HTTP_STATUS_CODE}.created implies
|
non_empty_body: res.status_code = {HTTP_STATUS_CODE}.created implies
|
||||||
not is_empty_content (a_res)
|
not is_empty_content (res)
|
||||||
location_header: a_res.status_code = {HTTP_STATUS_CODE}.created implies True -- WSF_RESPONSE needs enhancing
|
location_header: res.status_code = {HTTP_STATUS_CODE}.created implies True -- WSF_RESPONSE needs enhancing
|
||||||
end
|
end
|
||||||
|
|
||||||
do_trace (a_req: WSF_REQUEST; a_res: WSF_RESPONSE)
|
do_trace (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||||
-- Respond to `a_req' using `a_res'.
|
-- Respond to `req' using `res'.
|
||||||
deferred
|
deferred
|
||||||
ensure then
|
ensure then
|
||||||
non_empty_body: a_res.status_code = {HTTP_STATUS_CODE}.ok implies
|
non_empty_body: res.status_code = {HTTP_STATUS_CODE}.ok implies
|
||||||
not is_empty_content (a_res)
|
not is_empty_content (res)
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user