Implemented more user friendly WSF_RESPONSE
i.e allow to change the status code and the header as long as no content is really sent back to the client This requires an addition WGI_RESPONSE, new post_commit_action: PROCEDURE [...]
This commit is contained in:
@@ -44,6 +44,7 @@ feature -- Execution
|
||||
create req.make ((create {EXECUTION_ENVIRONMENT}).starting_environment_variables, create {WGI_CGI_INPUT_STREAM}.make, Current)
|
||||
create res.make (create {WGI_CGI_OUTPUT_STREAM}.make, create {WGI_CGI_ERROR_STREAM}.make)
|
||||
service.execute (req, res)
|
||||
res.push
|
||||
else
|
||||
if attached (create {EXCEPTION_MANAGER}).last_exception as e and then attached e.exception_trace as l_trace then
|
||||
if res /= Void then
|
||||
@@ -53,6 +54,7 @@ feature -- Execution
|
||||
if res.message_writable then
|
||||
res.put_string ("<pre>" + l_trace + "</pre>")
|
||||
end
|
||||
res.push
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -65,6 +65,7 @@ feature -- Execution
|
||||
create req.make (vars, a_input, Current)
|
||||
create res.make (a_output, a_output)
|
||||
service.execute (req, res)
|
||||
res.push
|
||||
else
|
||||
if attached (create {EXCEPTION_MANAGER}).last_exception as e and then attached e.exception_trace as l_trace then
|
||||
if res /= Void then
|
||||
@@ -74,6 +75,7 @@ feature -- Execution
|
||||
if res.message_writable then
|
||||
res.put_string ("<pre>" + l_trace + "</pre>")
|
||||
end
|
||||
res.push
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -133,10 +133,10 @@ feature -- Server
|
||||
res: detachable WGI_NINO_RESPONSE_STREAM
|
||||
do
|
||||
create req.make (env, create {WGI_NINO_INPUT_STREAM}.make (a_socket), Current)
|
||||
create res.make (create {WGI_NINO_OUTPUT_STREAM}.make (a_socket), Void)
|
||||
create res.make (create {WGI_NINO_OUTPUT_STREAM}.make (a_socket), create {WGI_NINO_ERROR_STREAM}.make_stderr (a_socket.descriptor.out))
|
||||
req.set_meta_string_variable ("RAW_HEADER_DATA", a_headers_text)
|
||||
service.execute (req, res)
|
||||
res.commit
|
||||
res.push
|
||||
end
|
||||
|
||||
note
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
note
|
||||
description: "Summary description for WGI_CGI_ERROR_STREAM."
|
||||
legal: "See notice at end of class."
|
||||
status: "See notice at end of class."
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WGI_NINO_ERROR_STREAM
|
||||
|
||||
inherit
|
||||
WGI_ERROR_STREAM
|
||||
|
||||
create
|
||||
make,
|
||||
make_stderr,
|
||||
make_stdout
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_identifier: READABLE_STRING_8; a_file: PLAIN_TEXT_FILE)
|
||||
do
|
||||
identifier := a_identifier
|
||||
output := a_file
|
||||
end
|
||||
|
||||
make_stderr (a_identifier: READABLE_STRING_8)
|
||||
do
|
||||
make (a_identifier, io.error)
|
||||
end
|
||||
|
||||
make_stdout (a_identifier: READABLE_STRING_8)
|
||||
do
|
||||
make (a_identifier, io.error)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
|
||||
identifier: READABLE_STRING_8
|
||||
|
||||
output: FILE
|
||||
|
||||
feature -- Error
|
||||
|
||||
put_error (a_message: READABLE_STRING_8)
|
||||
local
|
||||
s: STRING
|
||||
do
|
||||
create s.make (a_message.count + identifier.count + 4)
|
||||
s.append_character ('[')
|
||||
s.append (identifier)
|
||||
s.append_character (']')
|
||||
s.append_character (' ')
|
||||
s.append (a_message)
|
||||
s.append_character ('%N')
|
||||
-- Display it at once.
|
||||
output.put_string (s)
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2011, 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
|
||||
@@ -17,6 +17,7 @@ feature {NONE} -- Initialization
|
||||
make_with_response (res: WGI_RESPONSE)
|
||||
do
|
||||
wgi_response := res
|
||||
res.set_post_commit_action (agent commit)
|
||||
end
|
||||
|
||||
wgi_response: WGI_RESPONSE
|
||||
@@ -26,7 +27,7 @@ feature {WGI_CONNECTOR, WGI_SERVICE} -- Commit
|
||||
commit
|
||||
-- Commit the current response
|
||||
do
|
||||
-- do nothing, this will be done internal on the original `wgi_response' object
|
||||
wgi_response.set_post_commit_action (Void)
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
@@ -129,7 +130,7 @@ feature -- Error reporting
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
|
||||
@@ -8,6 +8,15 @@ deferred class
|
||||
|
||||
feature {WGI_CONNECTOR, WGI_SERVICE} -- Commit
|
||||
|
||||
push
|
||||
-- Commit and push response
|
||||
do
|
||||
commit
|
||||
if attached post_commit_action as act then
|
||||
act.call (Void)
|
||||
end
|
||||
end
|
||||
|
||||
commit
|
||||
-- Commit the current response
|
||||
deferred
|
||||
@@ -17,6 +26,21 @@ feature {WGI_CONNECTOR, WGI_SERVICE} -- Commit
|
||||
message_committed: message_committed
|
||||
end
|
||||
|
||||
feature -- Access: commit
|
||||
|
||||
post_commit_action: detachable PROCEDURE [ANY, TUPLE]
|
||||
-- Action associated with the final `commit' execution
|
||||
-- Note: useful to trigger action just after the
|
||||
-- response is transfered to the client.
|
||||
|
||||
feature -- Change: commit
|
||||
|
||||
set_post_commit_action (act: like post_commit_action)
|
||||
-- Assign `act' to `post_commit_action'
|
||||
do
|
||||
post_commit_action := act
|
||||
end
|
||||
|
||||
feature -- Status report
|
||||
|
||||
status_committed: BOOLEAN
|
||||
@@ -131,7 +155,7 @@ feature -- Error reporting
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
|
||||
Reference in New Issue
Block a user