Changed prefix from EWSGI_ to WGI_
Changed meta variable type to READABLE_STRING_32
This commit is contained in:
@@ -35,7 +35,7 @@ feature -- Setup
|
||||
|
||||
feature -- Execution
|
||||
|
||||
execute (req: EWSGI_REQUEST; res: EWSGI_RESPONSE_BUFFER)
|
||||
execute (req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
do
|
||||
if attached router.dispatch (req, res) as r then
|
||||
--| done
|
||||
@@ -44,7 +44,7 @@ feature -- Execution
|
||||
end
|
||||
end
|
||||
|
||||
execute_default (req: EWSGI_REQUEST; res: EWSGI_RESPONSE_BUFFER)
|
||||
execute_default (req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
deferred
|
||||
end
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ inherit
|
||||
|
||||
feature -- Access
|
||||
|
||||
request: EWSGI_REQUEST
|
||||
request: WGI_REQUEST
|
||||
-- Associated request
|
||||
|
||||
path: STRING
|
||||
@@ -25,35 +25,34 @@ feature -- Access
|
||||
|
||||
request_content_type (content_type_supported: detachable ARRAY [STRING]): detachable READABLE_STRING_8
|
||||
local
|
||||
s: detachable READABLE_STRING_8
|
||||
s: detachable READABLE_STRING_32
|
||||
i,n: INTEGER
|
||||
do
|
||||
Result := request.content_type
|
||||
if Result = Void then
|
||||
s := request.http_accept
|
||||
if s /= Void then
|
||||
if attached accepted_content_types (request) as l_accept_lst then
|
||||
from
|
||||
l_accept_lst.start
|
||||
until
|
||||
l_accept_lst.after or Result /= Void
|
||||
loop
|
||||
s := l_accept_lst.item
|
||||
if content_type_supported /= Void then
|
||||
from
|
||||
i := content_type_supported.lower
|
||||
n := content_type_supported.upper
|
||||
until
|
||||
i > n or Result /= Void
|
||||
loop
|
||||
if content_type_supported[i].same_string (s) then
|
||||
Result := s
|
||||
end
|
||||
i := i + 1
|
||||
s := request.content_type
|
||||
if s /= Void then
|
||||
Result := s
|
||||
else
|
||||
if attached accepted_content_types (request) as l_accept_lst then
|
||||
from
|
||||
l_accept_lst.start
|
||||
until
|
||||
l_accept_lst.after or Result /= Void
|
||||
loop
|
||||
s := l_accept_lst.item
|
||||
if content_type_supported /= Void then
|
||||
from
|
||||
i := content_type_supported.lower
|
||||
n := content_type_supported.upper
|
||||
until
|
||||
i > n or Result /= Void
|
||||
loop
|
||||
if content_type_supported[i].same_string (s) then
|
||||
Result := s
|
||||
end
|
||||
i := i + 1
|
||||
end
|
||||
l_accept_lst.forth
|
||||
end
|
||||
l_accept_lst.forth
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -15,7 +15,7 @@ create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (req: EWSGI_REQUEST; p: like path)
|
||||
make (req: WGI_REQUEST; p: like path)
|
||||
do
|
||||
request := req
|
||||
path := p
|
||||
|
||||
@@ -15,7 +15,7 @@ create
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (req: EWSGI_REQUEST; tpl: URI_TEMPLATE; tpl_res: URI_TEMPLATE_MATCH_RESULT; p: like path)
|
||||
make (req: WGI_REQUEST; tpl: URI_TEMPLATE; tpl_res: URI_TEMPLATE_MATCH_RESULT; p: like path)
|
||||
do
|
||||
request := req
|
||||
uri_template := tpl
|
||||
|
||||
@@ -23,11 +23,11 @@ feature -- Initialization
|
||||
|
||||
feature -- Access
|
||||
|
||||
action: PROCEDURE [ANY, TUPLE [ctx: REQUEST_HANDLER_CONTEXT; req: EWSGI_REQUEST; res: EWSGI_RESPONSE_BUFFER]]
|
||||
action: PROCEDURE [ANY, TUPLE [ctx: REQUEST_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER]]
|
||||
|
||||
feature -- Execution
|
||||
|
||||
execute_application (ctx: REQUEST_HANDLER_CONTEXT; req: EWSGI_REQUEST; res: EWSGI_RESPONSE_BUFFER)
|
||||
execute_application (ctx: REQUEST_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
do
|
||||
action.call ([ctx, req, res])
|
||||
end
|
||||
|
||||
@@ -21,7 +21,7 @@ feature -- Access
|
||||
|
||||
feature -- Status report
|
||||
|
||||
is_valid_context (req: EWSGI_REQUEST): BOOLEAN
|
||||
is_valid_context (req: WGI_REQUEST): BOOLEAN
|
||||
-- Is `req' valid context for current handler?
|
||||
do
|
||||
Result := request_method_name_supported (req.request_method)
|
||||
@@ -29,7 +29,7 @@ feature -- Status report
|
||||
|
||||
feature -- Execution
|
||||
|
||||
execute (a_hdl_context: REQUEST_HANDLER_CONTEXT; req: EWSGI_REQUEST; res: EWSGI_RESPONSE_BUFFER)
|
||||
execute (a_hdl_context: REQUEST_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
-- Execute request handler
|
||||
require
|
||||
is_valid_context: is_valid_context (req)
|
||||
@@ -52,7 +52,7 @@ feature -- Execution
|
||||
retry
|
||||
end
|
||||
|
||||
execute_method_not_allowed (a_hdl_context: REQUEST_HANDLER_CONTEXT; req: EWSGI_REQUEST; res: EWSGI_RESPONSE_BUFFER)
|
||||
execute_method_not_allowed (a_hdl_context: REQUEST_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
local
|
||||
s: STRING
|
||||
lst: LIST [STRING]
|
||||
@@ -75,24 +75,24 @@ feature -- Execution
|
||||
res.write_header ({HTTP_STATUS_CODE}.method_not_allowed, <<["Allow", s]>>)
|
||||
end
|
||||
|
||||
execute_application (a_hdl_context: REQUEST_HANDLER_CONTEXT; req: EWSGI_REQUEST; res: EWSGI_RESPONSE_BUFFER)
|
||||
execute_application (a_hdl_context: REQUEST_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
-- Execute request handler
|
||||
deferred
|
||||
end
|
||||
|
||||
pre_execute (req: EWSGI_REQUEST)
|
||||
pre_execute (req: WGI_REQUEST)
|
||||
-- Operation processed before `execute'
|
||||
do
|
||||
--| To be redefined if needed
|
||||
end
|
||||
|
||||
post_execute (req: EWSGI_REQUEST; res: EWSGI_RESPONSE_BUFFER)
|
||||
post_execute (req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
-- Operation processed after `execute'
|
||||
do
|
||||
--| To be redefined if needed
|
||||
end
|
||||
|
||||
rescue_execute (req: EWSGI_REQUEST; res: EWSGI_RESPONSE_BUFFER)
|
||||
rescue_execute (req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
|
||||
-- Operation processed after a rescue
|
||||
do
|
||||
--| To be redefined if needed
|
||||
@@ -101,7 +101,7 @@ feature -- Execution
|
||||
|
||||
feature -- Execution: report
|
||||
|
||||
-- execution_information (req: EWSGI_REQUEST): detachable REQUEST_HANDLER_CONTEXT
|
||||
-- execution_information (req: WGI_REQUEST): detachable REQUEST_HANDLER_CONTEXT
|
||||
-- -- Execution information related to the request
|
||||
-- do
|
||||
-- if attached path_information (req, req.environment.path_info) as info then
|
||||
@@ -109,7 +109,7 @@ feature -- Execution: report
|
||||
-- end
|
||||
-- end
|
||||
|
||||
-- path_information (req: EWSGI_REQUEST; a_rq_path: STRING): detachable TUPLE [format: detachable STRING; arguments: detachable STRING]
|
||||
-- path_information (req: WGI_REQUEST; a_rq_path: STRING): detachable TUPLE [format: detachable STRING; arguments: detachable STRING]
|
||||
-- -- Information related to `a_path'
|
||||
-- local
|
||||
-- l_rq_path: STRING
|
||||
@@ -156,7 +156,7 @@ feature -- Execution: report
|
||||
-- end
|
||||
-- end
|
||||
|
||||
url (req: EWSGI_REQUEST; args: detachable STRING; abs: BOOLEAN): STRING
|
||||
url (req: WGI_REQUEST; args: detachable STRING; abs: BOOLEAN): STRING
|
||||
-- Associated url based on `path' and `args'
|
||||
-- if `abs' then return absolute url
|
||||
local
|
||||
|
||||
@@ -32,7 +32,7 @@ feature -- Registration
|
||||
|
||||
feature -- Execution
|
||||
|
||||
dispatch (req: EWSGI_REQUEST; res: EWSGI_RESPONSE_BUFFER): detachable REQUEST_HANDLER
|
||||
dispatch (req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER): detachable REQUEST_HANDLER
|
||||
-- Dispatch `req, res' to the associated handler
|
||||
-- And return this handler
|
||||
-- If Result is Void, this means no handler was found.
|
||||
@@ -60,7 +60,7 @@ feature -- Execution
|
||||
|
||||
feature {NONE} -- Access: Implementation
|
||||
|
||||
handler (req: EWSGI_REQUEST): detachable TUPLE [handler: REQUEST_HANDLER; context: REQUEST_HANDLER_CONTEXT]
|
||||
handler (req: WGI_REQUEST): detachable TUPLE [handler: REQUEST_HANDLER; context: REQUEST_HANDLER_CONTEXT]
|
||||
-- Handler whose map matched with `req'
|
||||
require
|
||||
req_valid: req /= Void and then req.path_info /= Void
|
||||
|
||||
@@ -35,14 +35,14 @@ feature -- Registration
|
||||
|
||||
feature {NONE} -- Access: Implementation
|
||||
|
||||
handler (req: EWSGI_REQUEST): detachable TUPLE [handler: REQUEST_HANDLER; context: REQUEST_HANDLER_CONTEXT]
|
||||
handler (req: WGI_REQUEST): detachable TUPLE [handler: REQUEST_HANDLER; context: REQUEST_HANDLER_CONTEXT]
|
||||
local
|
||||
h: detachable REQUEST_HANDLER
|
||||
ctx: detachable REQUEST_HANDLER_CONTEXT
|
||||
do
|
||||
h := handler_by_path (req.environment.path_info)
|
||||
h := handler_by_path (req.path_info)
|
||||
if h = Void then
|
||||
if attached smart_handler_by_path (req.environment.path_info) as info then
|
||||
if attached smart_handler_by_path (req.path_info) as info then
|
||||
h := info.handler
|
||||
ctx := handler_context (info.path, req)
|
||||
end
|
||||
@@ -59,13 +59,13 @@ feature {NONE} -- Access: Implementation
|
||||
end
|
||||
end
|
||||
|
||||
smart_handler (req: EWSGI_REQUEST): detachable TUPLE [path: STRING; handler: REQUEST_HANDLER]
|
||||
smart_handler (req: WGI_REQUEST): detachable TUPLE [path: STRING; handler: REQUEST_HANDLER]
|
||||
require
|
||||
req_valid: req /= Void and then req.environment.path_info /= Void
|
||||
req_valid: req /= Void and then req.path_info /= Void
|
||||
do
|
||||
Result := smart_handler_by_path (req.environment.path_info)
|
||||
Result := smart_handler_by_path (req.path_info)
|
||||
ensure
|
||||
req_path_info_unchanged: req.environment.path_info.same_string (old req.environment.path_info)
|
||||
req_path_info_unchanged: req.path_info.same_string (old req.path_info)
|
||||
end
|
||||
|
||||
handler_by_path (a_path: STRING): detachable REQUEST_HANDLER
|
||||
@@ -107,12 +107,12 @@ feature {NONE} -- Access: Implementation
|
||||
|
||||
feature -- Context factory
|
||||
|
||||
handler_context (p: detachable STRING; req: EWSGI_REQUEST): REQUEST_URI_HANDLER_CONTEXT
|
||||
handler_context (p: detachable STRING; req: WGI_REQUEST): REQUEST_URI_HANDLER_CONTEXT
|
||||
do
|
||||
if p /= Void then
|
||||
create Result.make (req, p)
|
||||
else
|
||||
create Result.make (req, req.environment.path_info)
|
||||
create Result.make (req, req.path_info)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ feature -- Registration
|
||||
|
||||
feature {NONE} -- Access: Implementation
|
||||
|
||||
handler (req: EWSGI_REQUEST): detachable TUPLE [handler: REQUEST_HANDLER; context: REQUEST_HANDLER_CONTEXT]
|
||||
handler (req: WGI_REQUEST): detachable TUPLE [handler: REQUEST_HANDLER; context: REQUEST_HANDLER_CONTEXT]
|
||||
local
|
||||
ctx: detachable REQUEST_URI_TEMPLATE_HANDLER_CONTEXT
|
||||
l_handlers: like handlers
|
||||
@@ -72,7 +72,7 @@ feature {NONE} -- Access: Implementation
|
||||
|
||||
feature -- Context factory
|
||||
|
||||
handler_context (p: detachable STRING; req: EWSGI_REQUEST; tpl: URI_TEMPLATE; tpl_res: URI_TEMPLATE_MATCH_RESULT): REQUEST_URI_TEMPLATE_HANDLER_CONTEXT
|
||||
handler_context (p: detachable STRING; req: WGI_REQUEST; tpl: URI_TEMPLATE; tpl_res: URI_TEMPLATE_MATCH_RESULT): REQUEST_URI_TEMPLATE_HANDLER_CONTEXT
|
||||
do
|
||||
if p /= Void then
|
||||
create Result.make (req, tpl, tpl_res, p)
|
||||
|
||||
@@ -9,9 +9,9 @@ class
|
||||
|
||||
feature -- Access
|
||||
|
||||
accepted_content_types (req: EWSGI_REQUEST): detachable ARRAYED_LIST [STRING]
|
||||
accepted_content_types (req: WGI_REQUEST): detachable ARRAYED_LIST [READABLE_STRING_8]
|
||||
local
|
||||
l_accept: detachable READABLE_STRING_8
|
||||
l_accept: detachable READABLE_STRING_32
|
||||
s: STRING_8
|
||||
q: READABLE_STRING_8
|
||||
p: INTEGER
|
||||
@@ -22,7 +22,7 @@ feature -- Access
|
||||
--TEST l_accept := "text/html,application/xhtml+xml;q=0.6,application/xml;q=0.2,text/plain;q=0.5,*/*;q=0.8"
|
||||
|
||||
if l_accept /= Void then
|
||||
lst := l_accept.split (',')
|
||||
lst := l_accept.as_string_8.split (',')
|
||||
create Result.make (lst.count)
|
||||
from
|
||||
lst.start
|
||||
@@ -41,7 +41,7 @@ feature -- Access
|
||||
|
||||
lst.forth
|
||||
end
|
||||
create qs.make (create {COMPARABLE_COMPARATOR [STRING]})
|
||||
create qs.make (create {COMPARABLE_COMPARATOR [READABLE_STRING_8]})
|
||||
qs.reverse_sort (Result)
|
||||
from
|
||||
Result.start
|
||||
|
||||
Reference in New Issue
Block a user