Removed most of the "retry" in rescue clauses, since it was hidding critical issue.

This should be the choice of the application to "retry" on exception, otherwise let the framework handle this in the lower part.

Better handling of response termination (alias commit)
Added the notion of "status_committed"
This commit is contained in:
Jocelyn Fiat
2012-01-23 15:31:34 +01:00
parent 80d68699b1
commit 6dc1c0d2b0
8 changed files with 54 additions and 63 deletions

View File

@@ -118,32 +118,16 @@ feature -- Server
local
req: WGI_REQUEST_FROM_TABLE
res: detachable WGI_RESPONSE_STREAM
rescued: INTEGER
do
if rescued = 0 then
create req.make (env, create {WGI_NINO_INPUT_STREAM}.make (a_socket), Current)
create res.make (create {WGI_NINO_OUTPUT_STREAM}.make (a_socket))
req.set_meta_string_variable ("RAW_HEADER_DATA", a_headers_text)
service.execute (req, res)
elseif rescued = 1 then
if attached (create {EXCEPTION_MANAGER}).last_exception as e and then attached e.exception_trace as l_trace then
if res /= Void then
if not res.status_is_set then
res.set_status_code ({HTTP_STATUS_CODE}.internal_server_error)
end
if res.message_writable then
res.put_string ("<pre>" + l_trace + "</pre>")
end
end
end
end
rescue
rescued := rescued + 1
retry
create req.make (env, create {WGI_NINO_INPUT_STREAM}.make (a_socket), Current)
create res.make (create {WGI_NINO_OUTPUT_STREAM}.make (a_socket))
req.set_meta_string_variable ("RAW_HEADER_DATA", a_headers_text)
service.execute (req, res)
res.commit
end
note
copyright: "2011-2011, Eiffel Software and others"
copyright: "2011-2012, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -6,7 +6,7 @@ note
deferred class
WGI_RESPONSE
feature {WGI_RESPONSE, WGI_SERVICE} -- Commit
feature {WGI_CONNECTOR, WGI_SERVICE} -- Commit
commit
-- Commit the current response
@@ -49,6 +49,14 @@ feature -- Status setting
deferred
end
status_committed: BOOLEAN
-- Is status code set and committed?
-- i.e: sent to the client and could not be changed anymore
deferred
ensure
committed_implies_set: Result implies status_is_set
end
set_status_code (a_code: INTEGER)
-- Set response status code
-- Should be done before sending any data back to the client
@@ -116,7 +124,7 @@ feature -- Output operation
end
note
copyright: "2011-2011, Eiffel Software and others"
copyright: "2011-2012, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -22,7 +22,7 @@ feature {NONE} -- Initialization
output := a_output
end
feature {WGI_SERVICE} -- Commit
feature {WGI_CONNECTOR, WGI_SERVICE} -- Commit
commit
-- Commit the current response
@@ -33,6 +33,9 @@ feature {WGI_SERVICE} -- Commit
feature -- Status report
status_committed: BOOLEAN
-- Status code set and committed?
header_committed: BOOLEAN
-- Header committed?
@@ -68,6 +71,7 @@ feature -- Status setting
do
status_code := a_code
output.put_status_line (a_code)
status_committed := True
end
status_code: INTEGER
@@ -129,7 +133,7 @@ feature {NONE} -- Implementation: Access
-- Server output channel
;note
copyright: "2011-2011, Eiffel Software and others"
copyright: "2011-2012, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -11,7 +11,7 @@ note
deferred class
WGI_SERVICE
feature -- Execution
feature {WGI_CONNECTOR} -- Execution
execute (req: WGI_REQUEST; res: WGI_RESPONSE)
-- Execute the request
@@ -26,7 +26,7 @@ feature -- Execution
end
note
copyright: "2011-2011, Eiffel Software and others"
copyright: "2011-2012, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software