Removed any (put|write)_file_content from the WSF_ or WGI_ OUTPUT classes
Now DEFAULT_SERVICE has to be created instead of inherited. - This seems to be better for new user, and this avoid potential conflict and difference when inheriting between the various DEFAULT_SERVICE implementation. - remember that DEFAULT_SERVICE, is mainly to help the user to build its very first service. Use READABLE_STRING_8 as argument whenever it is possible. Added WSF_RESPONSE_MESSAGE, and WSF_RESPONSE.put_response (a_response_message) Now WSF_RESPONSE inherit from WGI_RESPONSE
This commit is contained in:
@@ -8,6 +8,9 @@ note
|
||||
class
|
||||
WSF_RESPONSE
|
||||
|
||||
inherit
|
||||
WGI_RESPONSE
|
||||
|
||||
create {WSF_SERVICE}
|
||||
make_from_wgi
|
||||
|
||||
@@ -55,14 +58,8 @@ feature -- Status setting
|
||||
set_status_code (a_code: INTEGER)
|
||||
-- Set response status code
|
||||
-- Should be done before sending any data back to the client
|
||||
require
|
||||
status_not_set: not status_is_set
|
||||
header_not_committed: not header_committed
|
||||
do
|
||||
wgi_response.set_status_code (a_code)
|
||||
ensure
|
||||
status_code_set: status_code = a_code
|
||||
status_set: status_is_set
|
||||
end
|
||||
|
||||
status_code: INTEGER
|
||||
@@ -71,18 +68,20 @@ feature -- Status setting
|
||||
Result := wgi_response.status_code
|
||||
end
|
||||
|
||||
feature {WGI_RESPONSE} -- Core output operation
|
||||
|
||||
write (s: READABLE_STRING_8)
|
||||
-- Send the string `s'
|
||||
-- this can be used for header and body
|
||||
do
|
||||
wgi_response.write (s)
|
||||
end
|
||||
|
||||
feature -- Header output operation
|
||||
|
||||
write_header_text (a_headers: READABLE_STRING_8)
|
||||
require
|
||||
status_set: status_is_set
|
||||
header_not_committed: not header_committed
|
||||
do
|
||||
wgi_response.write_header_text (a_headers)
|
||||
ensure
|
||||
status_set: status_is_set
|
||||
header_committed: header_committed
|
||||
message_writable: message_writable
|
||||
end
|
||||
|
||||
write_header (a_status_code: INTEGER; a_headers: detachable ARRAY [TUPLE [key: READABLE_STRING_8; value: READABLE_STRING_8]])
|
||||
@@ -114,20 +113,21 @@ feature -- Header output operation
|
||||
message_writable: message_writable
|
||||
end
|
||||
|
||||
write_header_lines (a_lines: ITERABLE [TUPLE [name: READABLE_STRING_8; value: READABLE_STRING_8]])
|
||||
do
|
||||
wgi_response.write_header_lines (a_lines)
|
||||
end
|
||||
|
||||
feature -- Output operation
|
||||
|
||||
write_string (s: READABLE_STRING_8)
|
||||
-- Send the string `s'
|
||||
require
|
||||
message_writable: message_writable
|
||||
do
|
||||
wgi_response.write_string (s)
|
||||
end
|
||||
|
||||
write_substring (s: READABLE_STRING_8; a_begin_index, a_end_index: INTEGER)
|
||||
-- Send the substring `s[a_begin_index:a_end_index]'
|
||||
require
|
||||
message_writable: message_writable
|
||||
do
|
||||
wgi_response.write_substring (s, a_begin_index, a_end_index)
|
||||
end
|
||||
@@ -163,14 +163,6 @@ feature -- Output operation
|
||||
flush
|
||||
end
|
||||
|
||||
write_file_content (fn: READABLE_STRING_8)
|
||||
-- Send the content of file `fn'
|
||||
require
|
||||
message_writable: message_writable
|
||||
do
|
||||
wgi_response.write_file_content (fn)
|
||||
end
|
||||
|
||||
flush
|
||||
-- Flush if it makes sense
|
||||
do
|
||||
@@ -179,6 +171,17 @@ feature -- Output operation
|
||||
|
||||
feature -- Helper
|
||||
|
||||
put_response (obj: WSF_RESPONSE_MESSAGE)
|
||||
require
|
||||
not header_committed
|
||||
not status_is_set
|
||||
not message_committed
|
||||
do
|
||||
obj.send_to (Current)
|
||||
end
|
||||
|
||||
feature -- Redirect
|
||||
|
||||
redirect_now_with_custom_status_code (a_url: READABLE_STRING_8; a_status_code: INTEGER)
|
||||
-- Redirect to the given url `a_url' and precise custom `a_status_code'
|
||||
-- Please see http://www.faqs.org/rfcs/rfc2616 to use proper status code.
|
||||
@@ -205,6 +208,14 @@ feature -- Helper
|
||||
redirect_now_with_custom_status_code (a_url, {HTTP_STATUS_CODE}.moved_permanently)
|
||||
end
|
||||
|
||||
feature {WGI_RESPONSE, WGI_SERVICE} -- Commit
|
||||
|
||||
commit
|
||||
-- Commit the current response
|
||||
do
|
||||
wgi_response.commit
|
||||
end
|
||||
|
||||
note
|
||||
copyright: "2011-2011, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
|
||||
Reference in New Issue
Block a user