Now inherit create_router ; but it is still possible to redefine it.
Added some wsf_reponse_message for redirection Use "found" for the redirec_now ... Added content to the tutorial
This commit is contained in:
@@ -13,6 +13,14 @@ inherit
|
||||
router
|
||||
end
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_router
|
||||
-- Create router
|
||||
--| it can be redefine to create with precise count if needed.
|
||||
do
|
||||
create router.make (0)
|
||||
end
|
||||
feature -- Router
|
||||
|
||||
router: WSF_URI_ROUTER
|
||||
|
||||
@@ -13,6 +13,15 @@ inherit
|
||||
router
|
||||
end
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
create_router
|
||||
-- Create router
|
||||
--| it can be redefine to create with precise count if needed.
|
||||
do
|
||||
create router.make (0)
|
||||
end
|
||||
|
||||
feature -- Router
|
||||
|
||||
router: WSF_URI_TEMPLATE_ROUTER
|
||||
|
||||
@@ -0,0 +1,77 @@
|
||||
note
|
||||
description: "[
|
||||
Delayed redirection with HTML content using META tag
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_HTML_DELAYED_REDIRECTION_RESPONSE
|
||||
|
||||
inherit
|
||||
WSF_HTML_PAGE_RESPONSE
|
||||
rename
|
||||
make as make_html
|
||||
redefine
|
||||
append_html_head_code
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_url_location: like url_location; a_delay_in_seconds: INTEGER)
|
||||
do
|
||||
url_location := a_url_location
|
||||
delay := a_delay_in_seconds
|
||||
make_html
|
||||
set_status_code ({HTTP_STATUS_CODE}.found)
|
||||
end
|
||||
|
||||
feature -- Header
|
||||
|
||||
url_location: STRING_8
|
||||
-- New url location after redirection
|
||||
|
||||
delay: INTEGER
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_url_location (a_url_location: like url_location)
|
||||
-- Set `url_location' to `a_url_location'
|
||||
do
|
||||
url_location := a_url_location
|
||||
end
|
||||
|
||||
set_delay (a_seconds: INTEGER)
|
||||
do
|
||||
delay := a_seconds
|
||||
end
|
||||
|
||||
feature {NONE} -- Output
|
||||
|
||||
append_html_head_code (s: STRING_8)
|
||||
local
|
||||
h_lines: like head_lines
|
||||
l_lines: like head_lines
|
||||
do
|
||||
h_lines := head_lines
|
||||
l_lines := head_lines.twin
|
||||
head_lines := l_lines
|
||||
add_meta_http_equiv ("refresh", delay.out + ";url=" + url_location)
|
||||
Precursor (s)
|
||||
head_lines := h_lines
|
||||
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
|
||||
@@ -114,8 +114,6 @@ feature {WSF_SERVICE, WSF_RESPONSE} -- Output
|
||||
|
||||
send_to (res: WSF_RESPONSE)
|
||||
local
|
||||
t: like title
|
||||
lines: like head_lines
|
||||
b: like body
|
||||
h: like header
|
||||
s: STRING_8
|
||||
@@ -131,6 +129,32 @@ feature {WSF_SERVICE, WSF_RESPONSE} -- Output
|
||||
end
|
||||
s.append (">%N")
|
||||
|
||||
append_html_head_code (s)
|
||||
append_html_body_code (s)
|
||||
|
||||
|
||||
s.append ("</html>%N")
|
||||
|
||||
h := header
|
||||
res.set_status_code (status_code)
|
||||
|
||||
if not h.has_content_length then
|
||||
h.put_content_length (s.count)
|
||||
end
|
||||
if not h.has_content_type then
|
||||
h.put_content_type_text_html
|
||||
end
|
||||
res.put_header_text (h.string)
|
||||
res.put_string (s)
|
||||
end
|
||||
|
||||
feature {NONE} -- HTML Generation
|
||||
|
||||
append_html_head_code (s: STRING_8)
|
||||
local
|
||||
t: like title
|
||||
lines: like head_lines
|
||||
do
|
||||
t := title
|
||||
lines := head_lines
|
||||
if t /= Void or else lines.count > 0 then
|
||||
@@ -147,25 +171,18 @@ feature {WSF_SERVICE, WSF_RESPONSE} -- Output
|
||||
end
|
||||
s.append ("</head>%N")
|
||||
end
|
||||
end
|
||||
|
||||
append_html_body_code (s: STRING_8)
|
||||
local
|
||||
b: like body
|
||||
do
|
||||
b := body
|
||||
s.append ("<body>%N")
|
||||
if b /= Void then
|
||||
s.append (b)
|
||||
end
|
||||
s.append ("%N</body></html>%N")
|
||||
|
||||
h := header
|
||||
res.set_status_code (status_code)
|
||||
|
||||
if not h.has_content_length then
|
||||
h.put_content_length (s.count)
|
||||
end
|
||||
if not h.has_content_type then
|
||||
h.put_content_type_text_html
|
||||
end
|
||||
res.put_header_text (h.string)
|
||||
res.put_string (s)
|
||||
s.append ("%N</body>")
|
||||
end
|
||||
|
||||
note
|
||||
|
||||
@@ -0,0 +1,71 @@
|
||||
note
|
||||
description: "[
|
||||
Immediate redirection with HTML content
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WSF_HTML_REDIRECTION_RESPONSE
|
||||
|
||||
inherit
|
||||
WSF_HTML_PAGE_RESPONSE
|
||||
rename
|
||||
make as make_html
|
||||
redefine
|
||||
send_to
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (a_url_location: like url_location)
|
||||
do
|
||||
url_location := a_url_location
|
||||
make_html
|
||||
set_status_code ({HTTP_STATUS_CODE}.found)
|
||||
end
|
||||
|
||||
feature -- Header
|
||||
|
||||
url_location: STRING_8
|
||||
-- New url location after redirection
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_url_location (a_url_location: like url_location)
|
||||
-- Set `url_location' to `a_url_location'
|
||||
do
|
||||
url_location := a_url_location
|
||||
end
|
||||
|
||||
feature {WSF_SERVICE, WSF_RESPONSE} -- Output
|
||||
|
||||
send_to (res: WSF_RESPONSE)
|
||||
local
|
||||
h,rh: like header
|
||||
do
|
||||
h := header
|
||||
create rh.make_with_count (1)
|
||||
|
||||
rh.put_location (url_location)
|
||||
rh.append_header_object (h)
|
||||
|
||||
header := rh
|
||||
Precursor (res)
|
||||
header := h
|
||||
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
|
||||
@@ -329,7 +329,7 @@ feature -- Redirect
|
||||
redirect_now_with_content (a_url: READABLE_STRING_8; a_content: READABLE_STRING_8; a_content_type: READABLE_STRING_8)
|
||||
-- Redirect to the given url `a_url'
|
||||
do
|
||||
redirect_now_custom (a_url, {HTTP_STATUS_CODE}.temp_redirect, Void, [a_content, a_content_type])
|
||||
redirect_now_custom (a_url, {HTTP_STATUS_CODE}.found, Void, [a_content, a_content_type])
|
||||
end
|
||||
|
||||
feature -- Error reporting
|
||||
|
||||
Reference in New Issue
Block a user