Added logger response wrapper, this is mainly to be able to save any response message to a file.
(debugging purpose)
This commit is contained in:
@@ -0,0 +1,141 @@
|
|||||||
|
note
|
||||||
|
description: "Summary description for {WGI_FILTER_RESPONSE}."
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
class
|
||||||
|
WGI_FILTER_RESPONSE
|
||||||
|
|
||||||
|
inherit
|
||||||
|
WGI_RESPONSE
|
||||||
|
|
||||||
|
create
|
||||||
|
make_with_response
|
||||||
|
|
||||||
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
|
make_with_response (res: WGI_RESPONSE)
|
||||||
|
do
|
||||||
|
wgi_response := res
|
||||||
|
end
|
||||||
|
|
||||||
|
wgi_response: WGI_RESPONSE
|
||||||
|
|
||||||
|
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
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Status report
|
||||||
|
|
||||||
|
status_committed: BOOLEAN
|
||||||
|
-- Is status code set and committed?
|
||||||
|
-- i.e: sent to the client and could not be changed anymore
|
||||||
|
do
|
||||||
|
Result := wgi_response.status_committed
|
||||||
|
end
|
||||||
|
|
||||||
|
header_committed: BOOLEAN
|
||||||
|
-- Header committed?
|
||||||
|
do
|
||||||
|
Result := wgi_response.header_committed
|
||||||
|
end
|
||||||
|
|
||||||
|
message_committed: BOOLEAN
|
||||||
|
-- Message committed?
|
||||||
|
do
|
||||||
|
Result := wgi_response.message_committed
|
||||||
|
end
|
||||||
|
|
||||||
|
message_writable: BOOLEAN
|
||||||
|
-- Can message be written?
|
||||||
|
do
|
||||||
|
Result := wgi_response.message_writable
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Status setting
|
||||||
|
|
||||||
|
status_is_set: BOOLEAN
|
||||||
|
-- Is status set?
|
||||||
|
do
|
||||||
|
Result := wgi_response.status_is_set
|
||||||
|
end
|
||||||
|
|
||||||
|
set_status_code (a_code: INTEGER; a_reason_phrase: detachable READABLE_STRING_8)
|
||||||
|
-- Set response status code with custom `a_reason_phrase' if precised
|
||||||
|
-- Should be done before sending any data back to the client
|
||||||
|
do
|
||||||
|
wgi_response.set_status_code (a_code, a_reason_phrase)
|
||||||
|
end
|
||||||
|
|
||||||
|
status_code: INTEGER
|
||||||
|
-- Response status
|
||||||
|
do
|
||||||
|
Result := wgi_response.status_code
|
||||||
|
end
|
||||||
|
|
||||||
|
status_reason_phrase: detachable READABLE_STRING_8
|
||||||
|
-- Custom status reason phrase for the Response (optional)
|
||||||
|
do
|
||||||
|
Result := wgi_response.status_reason_phrase
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Header output operation
|
||||||
|
|
||||||
|
put_header_text (a_text: READABLE_STRING_8)
|
||||||
|
-- Write http header string `a_text'
|
||||||
|
-- It should not contain the ending CR LF CR LF
|
||||||
|
-- since it is the duty of `put_header_text' to write it.
|
||||||
|
do
|
||||||
|
wgi_response.put_header_text (a_text)
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Output operation
|
||||||
|
|
||||||
|
put_character (c: CHARACTER_8)
|
||||||
|
-- Send the character `c'
|
||||||
|
do
|
||||||
|
wgi_response.put_character (c)
|
||||||
|
end
|
||||||
|
|
||||||
|
put_string (s: READABLE_STRING_8)
|
||||||
|
-- Send the string `s'
|
||||||
|
do
|
||||||
|
wgi_response.put_string (s)
|
||||||
|
end
|
||||||
|
|
||||||
|
put_substring (s: READABLE_STRING_8; a_begin_index, a_end_index: INTEGER)
|
||||||
|
-- Send the substring `s[a_begin_index:a_end_index]'
|
||||||
|
do
|
||||||
|
wgi_response.put_substring (s, a_begin_index, a_end_index)
|
||||||
|
end
|
||||||
|
|
||||||
|
flush
|
||||||
|
-- Flush if it makes sense
|
||||||
|
do
|
||||||
|
wgi_response.flush
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Error reporting
|
||||||
|
|
||||||
|
put_error (a_message: READABLE_STRING_8)
|
||||||
|
-- Report error described by `a_message'
|
||||||
|
-- This might be used by the underlying connector
|
||||||
|
do
|
||||||
|
wgi_response.put_error (a_message)
|
||||||
|
end
|
||||||
|
|
||||||
|
note
|
||||||
|
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, 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
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
note
|
||||||
|
description: "Summary description for {WGI_LOGGER_RESPONSE}."
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
class
|
||||||
|
WGI_LOGGER_RESPONSE
|
||||||
|
|
||||||
|
inherit
|
||||||
|
WGI_FILTER_RESPONSE
|
||||||
|
redefine
|
||||||
|
set_status_code,
|
||||||
|
put_header_text,
|
||||||
|
put_character,
|
||||||
|
put_string,
|
||||||
|
put_substring,
|
||||||
|
flush,
|
||||||
|
put_error
|
||||||
|
end
|
||||||
|
|
||||||
|
create
|
||||||
|
make_with_response_and_output
|
||||||
|
|
||||||
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
|
make_with_response_and_output (res: WGI_RESPONSE; a_out: FILE; a_err: FILE)
|
||||||
|
do
|
||||||
|
make_with_response (res)
|
||||||
|
output := a_out
|
||||||
|
error := a_err
|
||||||
|
end
|
||||||
|
|
||||||
|
output: FILE
|
||||||
|
error: FILE
|
||||||
|
|
||||||
|
feature -- Status setting
|
||||||
|
|
||||||
|
set_status_code (a_code: INTEGER; a_reason_phrase: detachable READABLE_STRING_8)
|
||||||
|
-- Set response status code with custom `a_reason_phrase' if precised
|
||||||
|
-- Should be done before sending any data back to the client
|
||||||
|
do
|
||||||
|
output.put_string ("Status: " + a_code.out)
|
||||||
|
if a_reason_phrase /= Void then
|
||||||
|
output.put_string (" " + a_reason_phrase)
|
||||||
|
end
|
||||||
|
output.put_new_line
|
||||||
|
Precursor (a_code, a_reason_phrase)
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Header output operation
|
||||||
|
|
||||||
|
put_header_text (a_text: READABLE_STRING_8)
|
||||||
|
-- Write http header string `a_text'
|
||||||
|
-- It should not contain the ending CR LF CR LF
|
||||||
|
-- since it is the duty of `put_header_text' to write it.
|
||||||
|
do
|
||||||
|
output.put_string (a_text)
|
||||||
|
output.put_character ('%R')
|
||||||
|
output.put_character ('%N')
|
||||||
|
output.put_character ('%R')
|
||||||
|
output.put_character ('%N')
|
||||||
|
Precursor (a_text)
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Output operation
|
||||||
|
|
||||||
|
put_character (c: CHARACTER_8)
|
||||||
|
-- Send the character `c'
|
||||||
|
do
|
||||||
|
output.put_character (c)
|
||||||
|
Precursor (c)
|
||||||
|
end
|
||||||
|
|
||||||
|
put_string (s: READABLE_STRING_8)
|
||||||
|
-- Send the string `s'
|
||||||
|
do
|
||||||
|
output.put_string (s)
|
||||||
|
Precursor (s)
|
||||||
|
end
|
||||||
|
|
||||||
|
put_substring (s: READABLE_STRING_8; a_begin_index, a_end_index: INTEGER)
|
||||||
|
-- Send the substring `s[a_begin_index:a_end_index]'
|
||||||
|
do
|
||||||
|
output.put_string (s.substring (a_begin_index, a_end_index))
|
||||||
|
Precursor (s, a_begin_index, a_end_index)
|
||||||
|
end
|
||||||
|
|
||||||
|
flush
|
||||||
|
-- Flush if it makes sense
|
||||||
|
do
|
||||||
|
output.flush
|
||||||
|
Precursor
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Error reporting
|
||||||
|
|
||||||
|
put_error (a_message: READABLE_STRING_8)
|
||||||
|
-- Report error described by `a_message'
|
||||||
|
-- This might be used by the underlying connector
|
||||||
|
do
|
||||||
|
error.put_string (a_message)
|
||||||
|
error.flush
|
||||||
|
Precursor (a_message)
|
||||||
|
end
|
||||||
|
|
||||||
|
note
|
||||||
|
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, 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
|
||||||
50
library/server/wsf/src/wsf_logger_response_wrapper.e
Normal file
50
library/server/wsf/src/wsf_logger_response_wrapper.e
Normal file
@@ -0,0 +1,50 @@
|
|||||||
|
note
|
||||||
|
description: "[
|
||||||
|
This class is a logger on a standard WSF_RESPONSE
|
||||||
|
It is used to record response
|
||||||
|
]"
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
class
|
||||||
|
WSF_LOGGER_RESPONSE_WRAPPER
|
||||||
|
|
||||||
|
inherit
|
||||||
|
WSF_RESPONSE
|
||||||
|
|
||||||
|
WSF_RESPONSE_EXPORTER
|
||||||
|
|
||||||
|
create
|
||||||
|
make_from_response
|
||||||
|
|
||||||
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
|
make_from_response (res: WSF_RESPONSE; a_out, a_err: FILE)
|
||||||
|
local
|
||||||
|
l_log_wgi_response: WGI_LOGGER_RESPONSE
|
||||||
|
do
|
||||||
|
wsf_response := res
|
||||||
|
create l_log_wgi_response.make_with_response_and_output (res.wgi_response, a_out, a_err)
|
||||||
|
make_from_wgi (l_log_wgi_response)
|
||||||
|
end
|
||||||
|
|
||||||
|
feature {WSF_RESPONSE_EXPORTER} -- Access
|
||||||
|
|
||||||
|
wsf_response: WSF_RESPONSE
|
||||||
|
-- Original WSF response object.
|
||||||
|
|
||||||
|
invariant
|
||||||
|
wsf_response_attached: wsf_response /= Void
|
||||||
|
|
||||||
|
note
|
||||||
|
copyright: "2011-2012, 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
|
||||||
Reference in New Issue
Block a user