Merge remote-tracking branch 'jocelynEWF/master'

Conflicts:
	examples/restbucks/restbucks-safe.ecf
	examples/restbucks/src/resource/order_handler.e
	library/server/request/router/src/misc/request_resource_handler_helper.e
This commit is contained in:
jvelilla
2011-10-23 20:58:28 -03:00
123 changed files with 4212 additions and 2168 deletions

View File

@@ -9,19 +9,16 @@ class
feature -- Access
accepted_content_types (req: WGI_REQUEST): detachable ARRAYED_LIST [READABLE_STRING_8]
accepted_content_types (req: WSF_REQUEST): detachable ARRAYED_LIST [READABLE_STRING_8]
local
l_accept: detachable READABLE_STRING_32
s: STRING_8
q: READABLE_STRING_8
p: INTEGER
lst: LIST [READABLE_STRING_8]
qs: QUICK_SORTER [READABLE_STRING_8]
do
l_accept := req.http_accept
--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
--TEST if attached ("text/html,application/xhtml+xml;q=0.6,application/xml;q=0.2,text/plain;q=0.5,*/*;q=0.8") as l_accept then
if attached req.http_accept as l_accept then
lst := l_accept.as_string_8.split (',')
create Result.make (lst.count)
from

View File

@@ -9,7 +9,7 @@ class
feature -- Execute template
execute_methods (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
execute_methods (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute request and dispatch according to the request method
local
m: READABLE_STRING_8
@@ -41,7 +41,7 @@ feature -- Execute template
feature -- Method Post
execute_post (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
execute_post (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
if req.content_length_value > 0 then
do_post (ctx, req, res)
@@ -50,14 +50,14 @@ feature -- Method Post
end
end
do_post (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
do_post (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
handle_not_implemented ("Method POST not implemented", ctx, req, res)
end
feature-- Method Put
execute_put (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
execute_put (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
if req.content_length_value > 0 then
do_put (ctx, req, res)
@@ -66,91 +66,91 @@ feature-- Method Put
end
end
do_put (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
do_put (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
handle_not_implemented ("Method PUT not implemented", ctx, req, res)
end
feature -- Method Get
execute_get (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
execute_get (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
do_get (ctx, req, res)
end
do_get (ctx: C;req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
do_get (ctx: C;req: WSF_REQUEST; res: WSF_RESPONSE)
do
handle_not_implemented ("Method HEAD not implemented", ctx, req, res)
end
feature -- Method DELETE
execute_delete (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
execute_delete (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
do_delete (ctx, req, res)
end
do_delete (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
do_delete (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
handle_not_implemented ("Method DELETE not implemented", ctx, req, res)
end
feature -- Method CONNECT
execute_connect (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
execute_connect (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
do_connect (ctx, req, res)
end
do_connect (ctx: C;req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
do_connect (ctx: C;req: WSF_REQUEST; res: WSF_RESPONSE)
do
handle_not_implemented ("Method CONNECT not implemented", ctx, req, res)
end
feature -- Method HEAD
execute_head (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
execute_head (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
do_head (ctx, req, res)
end
do_head (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
do_head (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
handle_not_implemented ("Method HEAD not implemented", ctx, req, res)
end
feature -- Method OPTIONS
execute_options (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
execute_options (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
do_options (ctx, req, res)
end
do_options (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
do_options (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
handle_not_implemented ("Method OPTIONS not implemented", ctx, req, res)
end
feature -- Method TRACE
execute_trace (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
execute_trace (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
do_trace (ctx, req, res)
end
do_trace (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
do_trace (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
handle_not_implemented ("Method TRACE not implemented", ctx, req, res)
end
feature -- Method Extension Method
execute_extension_method (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
execute_extension_method (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
do_extension_method (ctx, req, res)
end
do_extension_method (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
do_extension_method (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
do
handle_not_implemented ("Method extension-method not implemented", ctx, req, res)
end
@@ -164,9 +164,9 @@ feature -- Handle responses
Result := Void
end
handle_bad_request_response (a_description:STRING; ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER )
handle_bad_request_response (a_description:STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE )
local
h : EWF_HEADER
h : WSF_HEADER
do
create h.make
h.put_status ({HTTP_STATUS_CODE}.bad_request)
@@ -183,9 +183,9 @@ feature -- Handle responses
end
handle_precondition_fail_response (a_description:STRING; ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER )
handle_precondition_fail_response (a_description:STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE )
local
h : EWF_HEADER
h : WSF_HEADER
do
create h.make
h.put_status ({HTTP_STATUS_CODE}.precondition_failed)
@@ -201,9 +201,9 @@ feature -- Handle responses
res.write_string (a_description)
end
handle_internal_server_error (a_description:STRING; ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER )
handle_internal_server_error (a_description:STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE )
local
h : EWF_HEADER
h : WSF_HEADER
do
create h.make
h.put_status ({HTTP_STATUS_CODE}.internal_server_error)
@@ -221,9 +221,9 @@ feature -- Handle responses
res.write_string (a_description)
end
handle_not_implemented (a_description: STRING; ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER )
handle_not_implemented (a_description: STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE )
local
h : EWF_HEADER
h : WSF_HEADER
do
create h.make
h.put_status ({HTTP_STATUS_CODE}.not_implemented)
@@ -239,9 +239,9 @@ feature -- Handle responses
res.write_string (a_description)
end
handle_method_not_allowed_response (a_description:STRING; ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER )
handle_method_not_allowed_response (a_description:STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
local
h : EWF_HEADER
h : WSF_HEADER
do
create h.make
h.put_status ({HTTP_STATUS_CODE}.method_not_allowed)
@@ -256,9 +256,10 @@ feature -- Handle responses
res.write_headers_string (h.string)
res.write_string (a_description)
end
handle_resource_not_found_response (a_description:STRING; ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
handle_resource_not_found_response (a_description:STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
local
h : EWF_HEADER
h : WSF_HEADER
do
create h.make
h.put_status ({HTTP_STATUS_CODE}.not_found)
@@ -275,9 +276,9 @@ feature -- Handle responses
end
handle_resource_not_modified_response (a_description:STRING; ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
handle_resource_not_modified_response (a_description:STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
local
h : EWF_HEADER
h : WSF_HEADER
do
res.flush
create h.make
@@ -295,9 +296,9 @@ feature -- Handle responses
end
handle_resource_conflict_response (a_description:STRING; ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
handle_resource_conflict_response (a_description:STRING; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
local
h : EWF_HEADER
h : WSF_HEADER
do
create h.make
h.put_status ({HTTP_STATUS_CODE}.conflict)

View File

@@ -12,7 +12,7 @@ inherit
feature -- Helper
execute_content_type_not_allowed (req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER; a_content_types: detachable ARRAY [STRING]; a_uri_formats: detachable ARRAY [STRING])
execute_content_type_not_allowed (req: WSF_REQUEST; res: WSF_RESPONSE; a_content_types: detachable ARRAY [STRING]; a_uri_formats: detachable ARRAY [STRING])
local
accept_s, uri_s: detachable STRING
i, n: INTEGER
@@ -62,7 +62,7 @@ feature -- Helper
end
end
execute_request_method_not_allowed (req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER; a_methods: ITERABLE [STRING])
execute_request_method_not_allowed (req: WSF_REQUEST; res: WSF_RESPONSE; a_methods: ITERABLE [STRING])
local
s: STRING
do