Further use of constants for execution variables

This commit is contained in:
Colin Adams
2013-08-14 09:22:35 +01:00
parent c93e50a7e2
commit 275c26b55b
6 changed files with 83 additions and 58 deletions

View File

@@ -12,7 +12,7 @@ deferred class WSF_METHOD_HELPER
inherit
HTTP_STATUS_CODE_MESSAGES
SHARED_HTML_ENCODER
export {NONE} all end
@@ -58,7 +58,7 @@ feature -- Basic operations
l_locs := a_handler.previous_location (req)
handle_redirection_error (req, res, l_locs, {HTTP_STATUS_CODE}.found)
else
check attached {HTTP_HEADER} req.execution_variable ("NEGOTIATED_HTTP_HEADER") as h then
check attached {HTTP_HEADER} req.execution_variable (a_handler.Negotiated_http_header_execution_variable) as h then
-- postcondition header_attached of `handle_content_negotiation'
h.put_content_type_text_plain
h.put_current_date
@@ -68,7 +68,7 @@ feature -- Basic operations
end
end
else
check attached {HTTP_HEADER} req.execution_variable ("NEGOTIATED_HTTP_HEADER") as h then
check attached {HTTP_HEADER} req.execution_variable (a_handler.Negotiated_http_header_execution_variable) as h then
-- postcondition header_attached of `handle_content_negotiation'
h.put_content_type_text_plain
h.put_current_date
@@ -140,7 +140,7 @@ feature -- Basic operations
end
end
if not l_failed then
check attached {HTTP_HEADER} req.execution_variable ("NEGOTIATED_HTTP_HEADER") as h then
check attached {HTTP_HEADER} req.execution_variable (a_handler.Negotiated_http_header_execution_variable) as h then
-- postcondition header_attached of `handle_content_negotiation'
send_response (req, res, a_handler, h, False)
end
@@ -154,7 +154,7 @@ feature -- Content negotiation
handle_content_negotiation (req: WSF_REQUEST; res: WSF_RESPONSE; a_handler: WSF_SKELETON_HANDLER)
-- Negotiate acceptable content for, then write, response requested by `req' into `res'.
-- Policy routines are available in `a_handler'.
--
--
-- Either a 406 Not Acceptable error is sent, or upto four execution variables may be set on `req':
-- "NEGOTIATED_MEDIA_TYPE"
-- "NEGOTIATED_LANGUAGE"
@@ -290,7 +290,7 @@ feature {NONE} -- Implementation
l_chunk := a_handler.next_chunk (req)
res.put_chunk (l_chunk.a_chunk, l_chunk.a_extension)
else
write_error_response (req, res)
write_error_response (req, res)
end
end
if a_handler.finished (req) then
@@ -366,7 +366,7 @@ feature {NONE} -- Implementation
feature -- Errors
feature -- Error reporting
write_error_response (req: WSF_REQUEST; res: WSF_RESPONSE)
@@ -439,7 +439,7 @@ feature -- Error reporting
s.append ("<div id=%"footer%"></div>")
s.append ("</body>%N")
s.append ("</html>%N")
h.put_content_type_text_html
else
s := "Error " + a_status_code.out + " (" + l_msg + "): "
@@ -566,7 +566,7 @@ feature -- Error reporting
res.set_status_code ({HTTP_STATUS_CODE}.not_implemented)
res.put_header_lines (h)
end
handle_request_entity_too_large (req: WSF_REQUEST; res: WSF_RESPONSE; a_handler: WSF_SKELETON_HANDLER)
-- Write a Request Entity Too Large response for `req' to `res'.
require

View File

@@ -22,7 +22,7 @@ feature -- Basic operations
-- Policy routines are available in `a_handler'.
do
if a_handler.allow_post_to_missing_resource (req) then
check attached {HTTP_HEADER} req.execution_variable ("NEGOTIATED_HTTP_HEADER") as h then
check attached {HTTP_HEADER} req.execution_variable (a_handler.Negotiated_http_header_execution_variable) as h then
-- postcondition header_attached of `handle_content_negotiation'
send_response (req, res, a_handler, h, True)
end

View File

@@ -43,10 +43,11 @@ feature -- Access
req_attached: req /= Void
previously_existed: resource_previously_existed (req)
moved: resource_moved_permanently (req) or resource_moved_temporarily (req)
deferred
do
create {LINKED_LIST [URI]} Result.make
ensure
previous_location_attached: Result /= Void
non_empty_list: not Result.empty
non_empty_list: not Result.is_empty
end
note

View File

@@ -24,7 +24,7 @@ feature -- Basic operations
if a_handler.treat_as_moved_permanently (req) then
handle_redirection_error (req, res, a_handler.previous_location (req), {HTTP_STATUS_CODE}.moved_permanently)
else
check attached {HTTP_HEADER} req.execution_variable ("NEGOTIATED_HTTP_HEADER") as h then
check attached {HTTP_HEADER} req.execution_variable (a_handler.Negotiated_http_header_execution_variable) as h then
-- postcondition header_attached of `handle_content_negotiation'
send_response (req, res, a_handler, h, True)
end
@@ -68,5 +68,15 @@ feature {NONE} -- Implementation
end
end
end
note
copyright: "2011-2013, 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
5949 Hollister Ave., Goleta, CA 93117 USA
Telephone 805-685-1006, Fax 805-685-6869
Website http://www.eiffel.com
Customer support http://support.eiffel.com
]"
end

View File

@@ -30,7 +30,7 @@ feature -- Execution variables
Negotiated_language_execution_variable: STRING = "NEGOTIATED_LANGUAGE"
-- Execution variable set by framework
Negotiated_charset_execution_variable: STRING = "NEGOTIATED_CHARSET"
-- Execution variable set by framework
@@ -46,6 +46,15 @@ feature -- Execution variables
Request_entity_execution_variable: STRING = "REQUEST_ENTITY"
-- Execution variable set by framework
Conflict_check_code_execution_variable: STRING = "CONFLICT_CHECK_CODE"
-- Execution variable set by framework
Content_check_code_execution_variable: STRING = "CONTENT_CHECK_CODE"
-- Execution variable set by framework
Request_check_code_execution_variable: STRING = "REQUEST_CHECK_CODE"
-- Execution variable set by framework
feature -- Access
is_chunking (req: WSF_REQUEST): BOOLEAN
@@ -329,7 +338,7 @@ feature -- PUT/POST
end
is_entity_too_large (req: WSF_REQUEST): BOOLEAN
-- Is the entity stored in `req.execution_variable ("REQUEST_ENTITY")' too large for the application?
-- Is the entity stored in `req.execution_variable (Request_entity_execution_variable)' too large for the application?
require
req_attached: req /= Void
deferred
@@ -337,7 +346,7 @@ feature -- PUT/POST
check_content_headers (req: WSF_REQUEST)
-- Check we can support all content headers on request entity.
-- Set `req.execution_variable ("CONTENT_CHECK_CODE")' to {NATURAL} zero if OK, or 415 or 501 if not.
-- Set `req.execution_variable (Content_check_code_execution_variable)' to {NATURAL} zero if OK, or 415 or 501 if not.
require
req_attached: req /= Void
deferred
@@ -348,7 +357,7 @@ feature -- PUT/POST
require
req_attached: req /= Void
do
if attached {NATURAL} req.execution_variable ("CONTENT_CHECK_CODE") as l_code then
if attached {NATURAL} req.execution_variable (Content_check_code_execution_variable) as l_code then
Result := l_code
end
end
@@ -375,7 +384,7 @@ feature -- PUT/POST
check_conflict (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Check to see if updating the resource is problematic due to the current state of the resource.
-- Set `req.execution_variable ("CONFLICT_CHECK_CODE")' to {NATURAL} zero if OK, or 409 if not.
-- Set `req.execution_variable (Conflict_check_code_execution_variable)' to {NATURAL} zero if OK, or 409 if not.
-- In the latter case, write the full error response to `res'.
require
req_attached: req /= Void
@@ -388,15 +397,15 @@ feature -- PUT/POST
require
req_attached: req /= Void
do
if attached {NATURAL} req.execution_variable ("CONFLICT_CHECK_CODE") as l_code then
if attached {NATURAL} req.execution_variable (Conflict_check_code_execution_variable) as l_code then
Result := l_code
end
end
check_request (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Check that the request entity is a valid request.
-- The entity is available as `req.execution_variable ("REQUEST_ENTITY")'.
-- Set `req.execution_variable ("REQUEST_CHECK_CODE")' to {NATURAL} zero if OK, or 400 if not.
-- The entity is available as `req.execution_variable (Conflict_check_code_execution_variable)'.
-- Set `req.execution_variable (Request_check_code_execution_variable)' to {NATURAL} zero if OK, or 400 if not.
-- In the latter case, write the full error response to `res'.
require
req_attached: req /= Void
@@ -410,7 +419,7 @@ feature -- PUT/POST
require
req_attached: req /= Void
do
if attached {NATURAL} req.execution_variable ("REQUEST_CHECK_CODE") as l_code then
if attached {NATURAL} req.execution_variable (Request_check_code_execution_variable) as l_code then
Result := l_code
end
end