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

@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-8-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-8-0 http://www.eiffel.com/developers/xml/configuration-1-8-0.xsd" name="hello_routed_world" uuid="7C9887BD-4AE4-47F2-A0AA-4BBB6736D433">
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-9-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-9-0 http://www.eiffel.com/developers/xml/configuration-1-9-0.xsd" name="hello_routed_world" uuid="7C9887BD-4AE4-47F2-A0AA-4BBB6736D433">
<target name="hello_routed_world">
<root class="HELLO_ROUTED_WORLD" feature="make"/>
<file_rule>
@@ -8,14 +8,14 @@
<exclude>/\.svn$</exclude>
</file_rule>
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all" syntax="provisional">
<assertions precondition="true" postcondition="true" invariant="true" supplier_precondition="true"/>
<assertions precondition="true" postcondition="true" check="true" invariant="true" supplier_precondition="true"/>
</option>
<setting name="concurrency" value="thread"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="connector_nino" location="..\..\library\server\ewsgi\connectors\nino\nino-safe.ecf" readonly="false"/>
<library name="default_nino" location="..\..\library\server\ewsgi\default\ewsgi_nino-safe.ecf" readonly="false"/>
<library name="default_nino" location="..\..\library\server\wsf\default\nino-safe.ecf" readonly="false"/>
<library name="encoder" location="..\..\library\text\encoder\encoder-safe.ecf" readonly="false"/>
<library name="ewsgi" location="..\..\library\server\ewsgi\ewsgi-safe.ecf" readonly="false"/>
<library name="wsf" location="..\..\library\server\wsf\wsf-safe.ecf" readonly="false"/>
<library name="http" location="..\..\library\protocol\http\http-safe.ecf" readonly="false"/>
<library name="router" location="..\..\library\server\request\router\router-safe.ecf" readonly="false"/>
<library name="uri_template" location="..\..\library\protocol\uri_template\uri_template-safe.ecf" readonly="false"/>

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,9 @@
<html>
<head>
<title>Hello Eiffel::default</title>
<link rel="stylesheet" href="../style.css" type="text/css" media="all" />
</head>
<body>
<h1>Hello Eiffel Default World</h1>
</body>
</html>

View File

@@ -0,0 +1,9 @@
<html>
<head>
<title>Hello Eiffel</title>
<link rel="stylesheet" href="style.css" type="text/css" media="all" />
</head>
<body>
<h1>Hello Eiffel World :D</h1>
</body>
</html>

Binary file not shown.

View File

@@ -0,0 +1 @@
h1 { border: solid 1px #00f; margin: 5px; padding: 5px; }

File diff suppressed because it is too large Load Diff

View File

@@ -14,7 +14,7 @@ inherit
ROUTED_APPLICATION_HELPER
DEFAULT_WGI_APPLICATION
DEFAULT_APPLICATION
create
make
@@ -37,8 +37,13 @@ feature {NONE} -- Initialization
local
ra: REQUEST_AGENT_HANDLER [REQUEST_URI_TEMPLATE_HANDLER_CONTEXT]
hello: REQUEST_URI_TEMPLATE_ROUTING_HANDLER
www: REQUEST_FILE_SYSTEM_HANDLER [REQUEST_URI_TEMPLATE_HANDLER_CONTEXT]
do
router.map_agent ("/home", agent execute_home)
create www.make (document_root)
www.set_directory_index (<<"index.html">>)
router.map ("/www{/path}{?query}", www)
--| Map all "/hello*" using a ROUTING_HANDLER
create hello.make (3)
@@ -60,11 +65,26 @@ feature {NONE} -- Initialization
router.map_agent_with_request_methods ("/method/custom", agent handle_method_post, <<"POST">>)
end
document_root: READABLE_STRING_8
local
e: EXECUTION_ENVIRONMENT
dn: DIRECTORY_NAME
once
create e
create dn.make_from_string (e.current_working_directory)
dn.extend ("htdocs")
Result := dn.string
if Result[Result.count] = Operating_environment.directory_separator then
Result := Result.substring (1, Result.count - 1)
end
end
feature -- Execution
execute_default (req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
execute_default (req: WSF_REQUEST; res: WSF_RESPONSE)
local
h: EWF_HEADER
h: WSF_HEADER
l_url: STRING
e: EXECUTION_ENVIRONMENT
n: INTEGER
@@ -113,7 +133,7 @@ feature -- Execution
write_chunk (Void, res)
end
write_chunk (s: detachable READABLE_STRING_8; res: WGI_RESPONSE_BUFFER)
write_chunk (s: detachable READABLE_STRING_8; res: WSF_RESPONSE)
do
if s /= Void then
res.write_string (s.count.to_hex_string + {HTTP_CONSTANTS}.crlf)
@@ -124,7 +144,7 @@ feature -- Execution
res.flush
end
execute_home (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
execute_home (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE)
local
l_body: STRING_8
do
@@ -148,10 +168,10 @@ feature -- Execution
res.write_string (l_body)
end
execute_hello (req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER; a_name: detachable READABLE_STRING_32; ctx: REQUEST_HANDLER_CONTEXT)
execute_hello (req: WSF_REQUEST; res: WSF_RESPONSE; a_name: detachable READABLE_STRING_32; ctx: REQUEST_HANDLER_CONTEXT)
local
l_response_content_type: detachable STRING
h: EWF_HEADER
h: WSF_HEADER
content_type_supported: ARRAY [STRING]
l_body: STRING_8
do
@@ -187,33 +207,33 @@ feature -- Execution
end
end
handle_hello (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
handle_hello (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE)
do
execute_hello (req, res, Void, ctx)
end
handle_anonymous_hello (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
handle_anonymous_hello (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE)
do
execute_hello (req, res, ctx.string_parameter ("name"), ctx)
end
handle_method_any (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
handle_method_any (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE)
do
execute_hello (req, res, req.request_method, ctx)
end
handle_method_get (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
handle_method_get (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE)
do
execute_hello (req, res, "GET", ctx)
end
handle_method_post (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
handle_method_post (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE)
do
execute_hello (req, res, "POST", ctx)
end
handle_method_get_or_post (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
handle_method_get_or_post (ctx: REQUEST_URI_TEMPLATE_HANDLER_CONTEXT; req: WSF_REQUEST; res: WSF_RESPONSE)
do
execute_hello (req, res, "GET or POST", ctx)
end

View File

@@ -13,11 +13,11 @@
<setting name="concurrency" value="thread"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="connector_nino" location="..\..\library\server\ewsgi\connectors\nino\nino-safe.ecf" readonly="false"/>
<library name="default_nino" location="..\..\library\server\ewsgi\default\ewsgi_nino-safe.ecf" readonly="false"/>
<library name="default_nino" location="..\..\library\server\wsf\default\nino-safe.ecf" readonly="false"/>
<library name="encoder" location="..\..\library\text\encoder\encoder-safe.ecf" readonly="false"/>
<library name="ewsgi" location="..\..\library\server\ewsgi\ewsgi-safe.ecf" readonly="false"/>
<library name="http" location="..\..\library\protocol\http\http-safe.ecf" readonly="false"/>
<library name="wsf" location="..\..\library\server\wsf\wsf-safe.ecf" readonly="false"/>
<library name="json" location="..\..\ext\text\json\library\json-safe.ecf" readonly="false"/>
<library name="http" location="..\..\library\protocol\http\http-safe.ecf" readonly="false"/>
<library name="eel" location="..\..\ext\crypto\eel\eel-safe.ecf" readonly="false"/>
<library name="router" location="..\..\library\server\request\router\router-safe.ecf" readonly="false"/>
<library name="uri_template" location="..\..\library\protocol\uri_template\uri_template-safe.ecf" readonly="false"/>

View File

@@ -22,7 +22,7 @@ inherit
feature -- execute
execute (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
execute (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute request handler
do
execute_methods (ctx, req, res)
@@ -34,7 +34,7 @@ feature -- API DOC
feature -- HTTP Methods
do_get (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
do_get (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
-- Using GET to retrieve resource information.
-- If the GET request is SUCCESS, we response with
-- 200 OK, and a representation of the order
@@ -59,7 +59,7 @@ feature -- HTTP Methods
end
end
is_conditional_get (req : WGI_REQUEST; l_order : ORDER) : BOOLEAN
is_conditional_get (req : WSF_REQUEST; l_order : ORDER) : BOOLEAN
-- Check if If-None-Match is present and then if there is a representation that has that etag
-- if the representation hasn't changed, we return TRUE
-- then the response is a 304 with no entity body returned.
@@ -74,9 +74,9 @@ feature -- HTTP Methods
end
end
compute_response_get (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER; l_order : ORDER)
compute_response_get (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE; l_order : ORDER)
local
h: EWF_HEADER
h: WSF_HEADER
l_msg : STRING
etag_utils : ETAG_UTILS
do
@@ -97,7 +97,7 @@ feature -- HTTP Methods
end
end
do_put (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
do_put (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
-- Updating a resource with PUT
-- A successful PUT request will not create a new resource, instead it will
-- change the state of the resource identified by the current uri.
@@ -131,7 +131,7 @@ feature -- HTTP Methods
end
end
is_conditional_put (req : WGI_REQUEST; order : ORDER) : BOOLEAN
is_conditional_put (req : WSF_REQUEST; order : ORDER) : BOOLEAN
-- Check if If-Match is present and then if there is a representation that has that etag
-- if the representation hasn't changed, we return TRUE
local
@@ -150,9 +150,9 @@ feature -- HTTP Methods
end
compute_response_put (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER; l_order : ORDER)
compute_response_put (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE; l_order : ORDER)
local
h: EWF_HEADER
h: WSF_HEADER
joc : JSON_ORDER_CONVERTER
etag_utils : ETAG_UTILS
do
@@ -177,7 +177,7 @@ feature -- HTTP Methods
end
do_delete (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
do_delete (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
-- Here we use DELETE to cancel an order, if that order is in state where
-- it can still be canceled.
-- 200 if is ok
@@ -203,9 +203,9 @@ feature -- HTTP Methods
end
end
compute_response_delete (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
compute_response_delete (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}.no_content)
@@ -217,7 +217,7 @@ feature -- HTTP Methods
res.write_headers_string (h.string)
end
do_post (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
do_post (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
-- Here the convention is the following.
-- POST is used for creation and the server determines the URI
-- of the created resource.
@@ -239,9 +239,9 @@ feature -- HTTP Methods
end
end
compute_response_post (ctx: C; req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER; l_order : ORDER)
compute_response_post (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE; l_order : ORDER)
local
h: EWF_HEADER
h: WSF_HEADER
l_msg : STRING
l_location : STRING
joc : JSON_ORDER_CONVERTER

View File

@@ -14,7 +14,7 @@ inherit
ROUTED_APPLICATION_HELPER
DEFAULT_WGI_APPLICATION
DEFAULT_APPLICATION
create
make
@@ -43,12 +43,12 @@ feature {NONE} -- Initialization
feature -- Execution
execute_default (req: WGI_REQUEST; res: WGI_RESPONSE_BUFFER)
execute_default (req: WSF_REQUEST; res: WSF_RESPONSE)
-- I'm using this method to handle the method not allowed response
-- in the case that the given uri does not have a corresponding http method
-- to handle it.
local
h : EWF_HEADER
h : WSF_HEADER
l_description : STRING
l_api_doc : STRING
do

View File

@@ -0,0 +1,35 @@
note
description: "Summary description for {ETAG_UTILS}."
author: ""
date: "$Date$"
revision: "$Revision$"
class
ETAG_UTILS
inherit
ARRAY_FACILITIES
feature
md5_digest ( a_string : STRING ) : STRING
-- Cryptographic hash function that produces a 128-bit (16-byte) hash value, based on `a_string'
local
md5: MD5
output: SPECIAL [NATURAL_8]
do
create md5.make
create output.make_filled (0, 16)
md5.sink_string (a_string)
md5.do_final (output, 0)
Result := as_natural_32_be (output, 0).to_hex_string
Result := Result + as_natural_32_be (output, 4).to_hex_string
Result := Result + as_natural_32_be (output, 8).to_hex_string
Result := Result + as_natural_32_be (output, 12).to_hex_string
end
note
copyright: "2011-2011, Javier Velilla and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
end