fix merge conflict from master

This commit is contained in:
Colin Adams
2013-03-21 15:55:14 +00:00
72 changed files with 894 additions and 183 deletions

View File

@@ -0,0 +1,15 @@
GOAL: include EWF into your own git repository
For instance, let's put it under lib/EWF
git remote add -f _ewf https://github.com/EiffelWebFramework/EWF.git
git merge --squash -s ours --no-commit _ewf/master
git read-tree --prefix=lib/EWF/ -u _ewf/master
git commit -m "Imported EWF into subtree lib/EWF/"
Then to update lib/EWF
git pull -X subtree=lib/EWF _ewf master
From another git clone, reconnect this "import"
git remote add -f _ewf https://github.com/EiffelWebFramework/EWF.git
git merge -s ours --no-commit --squash _ewf/master
and then update lib/EWF as described before

View File

@@ -13,10 +13,12 @@
</option>
<setting name="concurrency" value="thread"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf" readonly="true"/>
<library name="net" location="$ISE_LIBRARY\library\net\net-safe.ecf" readonly="true"/>
<library name="default_nino" location="..\..\library\server\wsf\default\nino-safe.ecf" readonly="true"/>
<library name="http" location="../../library/network/protocol/http/http-safe.ecf" readonly="true"/>
<library name="json" location="..\..\contrib\library\text\parser\json\library\json-safe.ecf" readonly="true"/>
<library name="wsf" location="..\..\library\server\wsf\wsf-safe.ecf" readonly="true"/>
<library name="wsf_router_context" location="..\..\library\server\wsf\wsf_router_context-safe.ecf" readonly="true"/>
<library name="wsf_extension" location="..\..\library\server\wsf\wsf_extension-safe.ecf" readonly="true"/>
<library name="http_authorization" location="..\..\library\server\authentication\http_authorization\http_authorization-safe.ecf" readonly="true"/>
<cluster name="src" location="src\" recursive="true"/>

View File

@@ -10,12 +10,22 @@ class
inherit
ANY
WSF_FILTERED_SERVICE
WSF_HANDLER_HELPER
WSF_DEFAULT_SERVICE
WSF_ROUTED_SERVICE
rename
execute as execute_router
end
WSF_FILTERED_SERVICE
WSF_FILTER
rename
execute as execute_router
end
SHARED_EJSON
create
@@ -24,29 +34,29 @@ create
feature {NONE} -- Initialization
make
local
l_message: STRING
l_factory: INET_ADDRESS_FACTORY
do
initialize_router
initialize_filter
initialize_json
set_service_option ("port", 9090)
set_service_option ("port", port)
create l_message.make_empty
l_message.append_string ("Launching filter server at ")
create l_factory
l_message.append_string (l_factory.create_localhost.host_name)
l_message.append_string (" port ")
l_message.append_integer (port)
io.put_string (l_message)
io.put_new_line
make_and_launch
end
create_filter
-- Create `filter'
local
l_authentication_filter_hdl: AUTHENTICATION_FILTER
l_user_filter: USER_HANDLER
l_routing_filter: WSF_ROUTING_FILTER
do
create router.make (1)
create l_authentication_filter_hdl
create l_user_filter
l_authentication_filter_hdl.set_next (l_user_filter)
router.handle_with_request_methods ("/user/{userid}", l_authentication_filter_hdl, router.methods_get)
create l_routing_filter.make (router)
l_routing_filter.set_execute_default_action (agent execute_default)
filter := l_routing_filter
create {WSF_CORS_FILTER} filter
end
setup_filter
@@ -56,6 +66,28 @@ feature {NONE} -- Initialization
do
create l_logging_filter
filter.set_next (l_logging_filter)
l_logging_filter.set_next (Current)
end
setup_router
-- Setup `router'
local
l_options_filter: WSF_CORS_OPTIONS_FILTER
l_authentication_filter: AUTHENTICATION_FILTER
l_user_filter: USER_HANDLER
l_methods: WSF_REQUEST_METHODS
do
create l_options_filter.make (router)
create l_authentication_filter
create l_user_filter
l_options_filter.set_next (l_authentication_filter)
l_authentication_filter.set_next (l_user_filter)
create l_methods
l_methods.enable_options
l_methods.enable_get
router.handle_with_request_methods ("/user/{userid}", create {WSF_URI_TEMPLATE_AGENT_HANDLER}.make (agent l_options_filter.execute), l_methods)
end
initialize_json
@@ -64,26 +96,10 @@ feature {NONE} -- Initialization
json.add_converter (create {JSON_USER_CONVERTER}.make)
end
feature -- Basic operations
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
do
filter.execute (req, res)
end
execute_default (req: WSF_REQUEST; res: WSF_RESPONSE)
local
l_message: WSF_DEFAULT_ROUTER_RESPONSE
do
create l_message.make_with_router (req, router)
l_message.set_documentation_included (True)
res.send (l_message)
end
feature {NONE} -- Implementation
router: WSF_ROUTER;
-- Router
port: INTEGER = 9090
-- Port number
note
copyright: "2011-2013, Olivier Ligot, Jocelyn Fiat and others"

View File

@@ -504,6 +504,32 @@ feature -- Content-type helpers
put_content_type_multipart_encrypted do put_content_type ({HTTP_MIME_TYPES}.multipart_encrypted) end
put_content_type_application_x_www_form_encoded do put_content_type ({HTTP_MIME_TYPES}.application_x_www_form_encoded) end
feature -- Cross-Origin Resource Sharing
put_access_control_allow_origin (s: READABLE_STRING_8)
-- Put "Access-Control-Allow-Origin" header.
do
put_header_key_value ({HTTP_HEADER_NAMES}.header_access_control_allow_origin, s)
end
put_access_control_allow_all_origin
-- Put "Access-Control-Allow-Origin: *" header.
do
put_access_control_allow_origin ("*")
end
put_access_control_allow_methods (a_methods: ITERABLE [READABLE_STRING_8])
-- If `a_methods' is not empty, put `Access-Control-Allow-Methods' header with list `a_methods' of methods
do
put_header_key_values ({HTTP_HEADER_NAMES}.header_access_control_allow_methods, a_methods, Void)
end
put_access_control_allow_headers (s: READABLE_STRING_8)
-- Put "Access-Control-Allow-Headers" header.
do
put_header_key_value ({HTTP_HEADER_NAMES}.header_access_control_allow_headers, s)
end
feature -- Method related
put_allow (a_methods: ITERABLE [READABLE_STRING_8])

View File

@@ -194,6 +194,23 @@ feature -- Response header name
-- Indicates the authentication scheme that should be used to access the requested entity.
--| Example: WWW-Authenticate: Basic
feature -- Cross-Origin Resource Sharing
header_access_control_allow_origin: STRING = "Access-Control-Allow-Origin"
-- Indicates whether a resource can be shared based by returning
-- the value of the Origin request header in the response.
-- | Example: Access-Control-Allow-Origin: http://example.org
header_access_control_allow_methods: STRING = "Access-Control-Allow-Methods"
-- Indicates, as part of the response to a preflight request,
-- which methods can be used during the actual request.
-- | Example: Access-Control-Allow-Methods: PUT, DELETE
header_access_control_allow_headers: STRING = "Access-Control-Allow-Headers"
-- Indicates, as part of the response to a preflight request,
-- which header field names can be used during the actual request.
-- | Example: Access-Control-Allow-Headers: Authorization
feature -- Request or Response header name
header_cache_control: STRING = "Cache-Control"
@@ -248,7 +265,7 @@ feature -- MIME related
header_content_transfer_encoding: STRING = "Content-Transfer-Encoding"
note
copyright: "2011-2012, Jocelyn Fiat, Eiffel Software and others"
copyright: "2011-2013, Jocelyn Fiat, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -92,5 +92,19 @@ feature -- Access
http_authorization: detachable IMMUTABLE_STRING_8
feature -- Status report
is_basic: BOOLEAN
-- Is Basic authorization?
do
if attached type as t then
Result := t.same_string ("basic")
end
end
invariant
type_is_lower: attached type as t implies t.same_string (t.as_lower)
end

View File

@@ -50,6 +50,8 @@ feature -- Access
http_transfer_encoding: STRING = "HTTP_TRANSFER_ENCODING"
http_access_control_request_headers: STRING = "HTTP_ACCESS_CONTROL_REQUEST_HEADERS"
gateway_interface: STRING = "GATEWAY_INTERFACE"
auth_type: STRING = "AUTH_TYPE"

View File

@@ -598,6 +598,12 @@ feature -- HTTP_*
deferred
end
http_access_control_request_headers: detachable READABLE_STRING_8
-- Indicates which headers will be used in the actual request
-- as part of the preflight request
deferred
end
feature -- Extra CGI environment variables
request_uri: READABLE_STRING_8

View File

@@ -241,6 +241,13 @@ feature -- Access: HTTP_* CGI meta parameters - 1.1
Result := meta_string_variable ({WGI_META_NAMES}.http_transfer_encoding)
end
http_access_control_request_headers: detachable READABLE_STRING_8
-- Indicates which headers will be used in the actual request
-- as part of the preflight request
do
Result := meta_string_variable ({WGI_META_NAMES}.http_access_control_request_headers)
end
feature -- Access: Extension to CGI meta parameters - 1.1
request_uri: READABLE_STRING_8

View File

@@ -0,0 +1,37 @@
note
description: "Cross-Origin Resource Sharing filter."
author: "Olivier Ligot"
date: "$Date$"
revision: "$Revision$"
EIS: "name=Cross-Origin Resource Sharing", "src=http://www.w3.org/TR/cors/", "tag=W3C"
class
WSF_CORS_FILTER
inherit
WSF_FILTER
feature -- Basic operations
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute the filter.
local
l_header: HTTP_HEADER
do
create l_header.make
l_header.put_access_control_allow_all_origin
res.put_header_text (l_header.string)
execute_next (req, res)
end
note
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, 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

View File

@@ -0,0 +1,57 @@
note
description: "Filter that handles an OPTIONS request, with Cross-Origin Resource Sharing support."
author: "Olvier Ligot"
date: "$Date$"
revision: "$Revision$"
EIS: "name=Cross-Origin Resource Sharing", "src=http://www.w3.org/TR/cors/", "tag=W3C"
class
WSF_CORS_OPTIONS_FILTER
inherit
WSF_FILTER
create
make
feature {NONE} -- Initialization
make (a_router: like router)
-- Initialize Current with `a_router'.
do
router := a_router
ensure
router_set: router = a_router
end
feature -- Access
router: WSF_ROUTER
-- Associated router
feature -- Basic operations
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute the filter.
local
msg: WSF_CORS_OPTIONS_RESPONSE
do
if req.is_request_method ({HTTP_REQUEST_METHODS}.method_options) then
create msg.make (req, router)
res.send (msg)
else
execute_next (req, res)
end
end
note
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, 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

View File

@@ -14,7 +14,7 @@ feature -- Access
feature -- Element change
set_next (a_next: WSF_FILTER)
set_next (a_next: like next)
-- Set `next' to `a_next'
do
next := a_next
@@ -26,6 +26,9 @@ feature -- Basic operations
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute the filter.
require
req_attached: req /= Void
res_attached: res /= Void
deferred
end
@@ -33,6 +36,9 @@ feature {NONE} -- Implementation
execute_next (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute the `next' filter.
require
req_attached: req /= Void
res_attached: res /= Void
do
if attached next as n then
n.execute (req, res)
@@ -40,7 +46,7 @@ feature {NONE} -- Implementation
end
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -8,14 +8,14 @@ note
revision: "$Revision$"
deferred class
WSF_FILTER_HANDLER
WSF_FILTER_HANDLER [G -> WSF_HANDLER]
inherit
WSF_HANDLER
feature -- Access
next: detachable WSF_HANDLER
next: detachable G
-- Next handler
feature -- Element change
@@ -29,7 +29,7 @@ feature -- Element change
end
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -35,8 +35,15 @@ feature -- Access
filter: WSF_FILTER
-- Filter
feature -- Execution
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
do
filter.execute (req, res)
end
;note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -0,0 +1,53 @@
note
description: "[
Handler wrapping a filter
]"
date: "$Date$"
revision: "$Revision$"
class
WSF_HANDLER_FILTER_WRAPPER
inherit
WSF_HANDLER
create
make_with_filter
feature {NONE} -- Initialization
make_with_filter (f: WSF_FILTER)
-- Build Current with `f'.
require
f_attached: f /= Void
do
filter := f
ensure
filter_set: filter = f
end
feature -- Access
filter: WSF_FILTER
-- Associated filter.
feature -- Execution
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute handler for `req' and respond in `res'
-- by passing through filter `filter'
do
filter.execute (req, res)
end
note
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, 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

View File

@@ -44,10 +44,12 @@ feature -- Basic operations
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute the filter
local
sess: WSF_ROUTER_SESSION
do
if attached router.dispatch_and_return_handler (req, res) then
check router.is_dispatched end
else
create sess
router.dispatch (req, res, sess)
if not sess.dispatched then
execute_default (req, res)
end
execute_next (req, res)
@@ -63,7 +65,7 @@ feature -- Basic operations
end
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -8,18 +8,10 @@ deferred class
WSF_STARTS_WITH_FILTER_HANDLER
inherit
WSF_FILTER_HANDLER
redefine
next
end
WSF_FILTER_HANDLER [WSF_STARTS_WITH_HANDLER]
WSF_STARTS_WITH_HANDLER
feature -- Access
next: detachable WSF_STARTS_WITH_FILTER_HANDLER
-- Next handler
feature -- Execution
execute_next (a_start_path: READABLE_STRING_8; req: WSF_REQUEST; res: WSF_RESPONSE)
@@ -30,7 +22,7 @@ feature -- Execution
end
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -58,7 +58,7 @@ feature -- Status
Result := p.starts_with (s)
end
routed_handler (req: WSF_REQUEST; res: WSF_RESPONSE; a_router: WSF_ROUTER): detachable WSF_HANDLER
try (req: WSF_REQUEST; res: WSF_RESPONSE; sess: WSF_ROUTER_SESSION; a_router: WSF_ROUTER)
-- Return the handler if Current matches the request `req'.
local
p: READABLE_STRING_8
@@ -67,7 +67,7 @@ feature -- Status
p := path_from_request (req)
s := based_uri (uri, a_router)
if p.starts_with (s) then
Result := handler
sess.set_dispatched_handler (handler)
a_router.execute_before (Current)
execute_handler (handler, s, req, res)
a_router.execute_after (Current)
@@ -113,7 +113,7 @@ invariant
uri_attached: uri /= Void
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -20,6 +20,8 @@ feature {NONE} -- Initialization
action := a_action
end
feature -- Access
action: PROCEDURE [ANY, TUPLE [request: WSF_REQUEST; response: WSF_RESPONSE]]
feature -- Execution
@@ -30,7 +32,7 @@ feature -- Execution
end
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -8,18 +8,10 @@ deferred class
WSF_URI_FILTER_HANDLER
inherit
WSF_FILTER_HANDLER
redefine
next
end
WSF_FILTER_HANDLER [WSF_URI_HANDLER]
WSF_URI_HANDLER
feature -- Access
next: detachable WSF_URI_FILTER_HANDLER
-- Next handler
feature -- Execution
execute_next (req: WSF_REQUEST; res: WSF_RESPONSE)
@@ -30,7 +22,7 @@ feature -- Execution
end
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -7,35 +7,15 @@ note
deferred class
WSF_URI_ROUTED_SERVICE
obsolete "Inherit from WSF_ROUTED_SERVICE and WSF_URI_ROUTER_HELPER [2013-mar-19]"
inherit
WSF_ROUTED_SERVICE
feature -- Mapping helper: uri
map_uri (a_uri: READABLE_STRING_8; h: WSF_URI_HANDLER)
do
map_uri_with_request_methods (a_uri, h, Void)
end
map_uri_with_request_methods (a_uri: READABLE_STRING_8; h: WSF_URI_HANDLER; rqst_methods: detachable WSF_REQUEST_METHODS)
do
router.map_with_request_methods (create {WSF_URI_MAPPING}.make (a_uri, h), rqst_methods)
end
feature -- Mapping helper: uri agent
map_uri_agent (a_uri: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]])
do
map_uri_agent_with_request_methods (a_uri, proc, Void)
end
map_uri_agent_with_request_methods (a_uri: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]]; rqst_methods: detachable WSF_REQUEST_METHODS)
do
map_uri_with_request_methods (a_uri, create {WSF_URI_AGENT_HANDLER}.make (proc), rqst_methods)
end
WSF_URI_ROUTER_HELPER
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -0,0 +1,50 @@
note
description: "Summary description for {WSF_URI_ROUTER_HELPER}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_URI_ROUTER_HELPER
feature -- Access
router: WSF_ROUTER
deferred
end
feature -- Mapping helper: uri
map_uri (a_uri: READABLE_STRING_8; h: WSF_URI_HANDLER)
do
map_uri_with_request_methods (a_uri, h, Void)
end
map_uri_with_request_methods (a_uri: READABLE_STRING_8; h: WSF_URI_HANDLER; rqst_methods: detachable WSF_REQUEST_METHODS)
do
router.map_with_request_methods (create {WSF_URI_MAPPING}.make (a_uri, h), rqst_methods)
end
feature -- Mapping helper: uri agent
map_uri_agent (a_uri: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]])
do
map_uri_agent_with_request_methods (a_uri, proc, Void)
end
map_uri_agent_with_request_methods (a_uri: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]]; rqst_methods: detachable WSF_REQUEST_METHODS)
do
map_uri_with_request_methods (a_uri, create {WSF_URI_AGENT_HANDLER}.make (proc), rqst_methods)
end
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, 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

View File

@@ -72,10 +72,10 @@ feature -- Status
end
end
routed_handler (req: WSF_REQUEST; res: WSF_RESPONSE; a_router: WSF_ROUTER): detachable WSF_HANDLER
try (req: WSF_REQUEST; res: WSF_RESPONSE; sess: WSF_ROUTER_SESSION; a_router: WSF_ROUTER)
do
if is_mapping (req, a_router) then
Result := handler
sess.set_dispatched_handler (handler)
a_router.execute_before (Current)
execute_handler (handler, req, res)
a_router.execute_after (Current)
@@ -105,7 +105,7 @@ feature {NONE} -- Implementation
end
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -20,6 +20,8 @@ feature {NONE} -- Initialization
action := a_action
end
feature -- Access
action: PROCEDURE [ANY, TUPLE [request: WSF_REQUEST; response: WSF_RESPONSE]]
feature -- Execution
@@ -30,7 +32,7 @@ feature -- Execution
end
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -8,18 +8,10 @@ deferred class
WSF_URI_TEMPLATE_FILTER_HANDLER
inherit
WSF_FILTER_HANDLER
redefine
next
end
WSF_FILTER_HANDLER [WSF_URI_TEMPLATE_HANDLER]
WSF_URI_TEMPLATE_HANDLER
feature -- Access
next: detachable WSF_URI_TEMPLATE_HANDLER
-- Next handler
feature -- Execution
execute_next (req: WSF_REQUEST; res: WSF_RESPONSE)
@@ -30,7 +22,7 @@ feature -- Execution
end
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -6,11 +6,14 @@ note
deferred class WSF_URI_TEMPLATE_ROUTED_SERVICE
obsolete "Inherit from WSF_ROUTED_SERVICE and WSF_URI_ROUTER_HELPER [2013-mar-19]"
inherit
WSF_ROUTED_SERVICE
WSF_URI_TEMPLATE_HELPER_FOR_ROUTED_SERVICE
WSF_URI_TEMPLATE_ROUTER_HELPER
note
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"

View File

@@ -0,0 +1,66 @@
note
description: "Summary description for {WSF_URI_TEMPLATE_ROUTER_HELPER}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_URI_TEMPLATE_ROUTER_HELPER
feature -- Access
router: WSF_ROUTER
deferred
end
feature -- Mapping helper: uri
map_uri_template (a_tpl: STRING; h: WSF_URI_TEMPLATE_HANDLER)
-- Map `h' as handler for `a_tpl'
require
a_tpl_attached: a_tpl /= Void
h_attached: h /= Void
do
map_uri_template_with_request_methods (a_tpl, h, Void)
end
map_uri_template_with_request_methods (a_tpl: READABLE_STRING_8; h: WSF_URI_TEMPLATE_HANDLER; rqst_methods: detachable WSF_REQUEST_METHODS)
-- Map `h' as handler for `a_tpl' for request methods `rqst_methods'.
require
a_tpl_attached: a_tpl /= Void
h_attached: h /= Void
do
router.map_with_request_methods (create {WSF_URI_TEMPLATE_MAPPING}.make (a_tpl, h), rqst_methods)
end
feature -- Mapping helper: uri agent
map_uri_template_agent (a_tpl: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]])
-- Map `proc' as handler for `a_tpl'
require
a_tpl_attached: a_tpl /= Void
proc_attached: proc /= Void
do
map_uri_template_agent_with_request_methods (a_tpl, proc, Void)
end
map_uri_template_agent_with_request_methods (a_tpl: READABLE_STRING_8; proc: PROCEDURE [ANY, TUPLE [req: WSF_REQUEST; res: WSF_RESPONSE]]; rqst_methods: detachable WSF_REQUEST_METHODS)
-- Map `proc' as handler for `a_tpl' for request methods `rqst_methods'.
require
a_tpl_attached: a_tpl /= Void
proc_attached: proc /= Void
do
map_uri_template_with_request_methods (a_tpl, create {WSF_URI_TEMPLATE_AGENT_HANDLER}.make (proc), rqst_methods)
end
note
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, 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

View File

@@ -68,7 +68,7 @@ feature -- Status
Result := tpl.match (p) /= Void
end
routed_handler (req: WSF_REQUEST; res: WSF_RESPONSE; a_router: WSF_ROUTER): detachable WSF_HANDLER
try (req: WSF_REQUEST; res: WSF_RESPONSE; sess: WSF_ROUTER_SESSION; a_router: WSF_ROUTER)
-- <Precursor>
local
tpl: URI_TEMPLATE
@@ -78,7 +78,7 @@ feature -- Status
p := path_from_request (req)
tpl := based_uri_template (template, a_router)
if attached tpl.match (p) as tpl_res then
Result := handler
sess.set_dispatched_handler (handler)
a_router.execute_before (Current)
--| Applied the context to the request
--| in practice, this will fill the {WSF_REQUEST}.path_parameters
@@ -126,7 +126,7 @@ feature {NONE} -- Implementation
end
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -1,6 +1,7 @@
note
description: "Summary description for {WSF_HANDLER}."
author: ""
description: "[
Represents the ancestor of all the WSF_ROUTER handler.
]"
date: "$Date$"
revision: "$Revision$"
@@ -27,7 +28,7 @@ feature {WSF_ROUTER} -- Mapping
end
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -40,10 +40,12 @@ feature -- Execution
require
req_attached: req /= Void
res_attached: res /= Void
local
sess: WSF_ROUTER_SESSION
do
if attached router.dispatch_and_return_handler (req, res) as p then
-- executed
else
create sess
router.dispatch (req, res, sess)
if not sess.dispatched then
execute_default (req, res)
end
ensure

View File

@@ -112,75 +112,84 @@ feature -- Mapping handler
map_with_request_methods (f.new_mapping (a_resource), rqst_methods)
end
feature -- Access
is_dispatched: BOOLEAN
-- `dispatch' set `is_dispatched' to True
-- if mapping was found, and associated handler executed
feature -- Basic operations
dispatch (req: WSF_REQUEST; res: WSF_RESPONSE)
dispatch (req: WSF_REQUEST; res: WSF_RESPONSE; sess: detachable WSF_ROUTER_SESSION)
-- Dispatch request `req' among the `mappings'.
-- Set `is_dispatched' if the request were dispatched.
-- Set `sess' if the request were dispatched and `sess' attached.
require
req_attached: req /= Void
res_attached: res /= Void
local
l_sess: detachable WSF_ROUTER_SESSION
do
if attached dispatch_and_return_handler (req, res) then
check is_dispatched: is_dispatched end
l_sess := sess
if l_sess = Void then
create l_sess
end
router_dispatch (req, res, l_sess)
end
dispatch_and_return_handler (req: WSF_REQUEST; res: WSF_RESPONSE): detachable WSF_HANDLER
-- Dispatch request `req' among the `mappings'
-- And return the associated handler if mapping found and handler executed.
--| Violates CQS
obsolete
"Use `dispatch' [2013-mar-21]"
require
req_attached: req /= Void
res_attached: res /= Void
local
sess: WSF_ROUTER_SESSION
do
create sess
router_dispatch (req, res, sess)
Result := sess.dispatched_handler
end
feature {NONE} -- Dispatch implementation
router_dispatch (req: WSF_REQUEST; res: WSF_RESPONSE; sess: WSF_ROUTER_SESSION)
require
req_attached: req /= Void
res_attached: res /= Void
sess_attached: sess /= Void
sess_not_dispatched: not sess.dispatched
local
l_req_method: READABLE_STRING_8
head_res: WSF_HEAD_RESPONSE_WRAPPER
do
l_req_method := request_method (req)
is_dispatched := False
Result := dispatch_and_return_handler_for_request_method (req, res, l_req_method)
if Result = Void and l_req_method = {HTTP_REQUEST_METHODS}.method_head then
check is_not_dispatched: not is_dispatched end
router_dispatch_for_request_method (req, res, sess, l_req_method)
if not sess.dispatched and l_req_method = {HTTP_REQUEST_METHODS}.method_head then
create head_res.make_from_response (res)
req.set_request_method ({HTTP_REQUEST_METHODS}.method_GET)
Result := dispatch_and_return_handler_for_request_method (req, head_res, {HTTP_REQUEST_METHODS}.method_GET)
router_dispatch_for_request_method (req, head_res, sess, {HTTP_REQUEST_METHODS}.method_GET)
end
end
feature {NONE} -- Dispatch implementation
dispatch_and_return_handler_for_request_method (req: WSF_REQUEST; res: WSF_RESPONSE; a_request_method: READABLE_STRING_8): detachable WSF_HANDLER
router_dispatch_for_request_method (req: WSF_REQUEST; res: WSF_RESPONSE; sess: WSF_ROUTER_SESSION; a_request_method: READABLE_STRING_8)
-- Dispatch request `req' among the `mappings'
-- And return the associated handler if mapping found and handler executed.
--| Violates CQS
require
req_attached: req /= Void
res_attached: res /= Void
sess_attached: sess /= Void
sess_not_dispatched: not sess.dispatched
a_request_method_attached: a_request_method /= Void
local
m: WSF_ROUTER_MAPPING
do
is_dispatched := False
across
mappings as c
until
Result /= Void
sess.dispatched
loop
if attached c.item as l_info then
if is_matching_request_methods (a_request_method, l_info.request_methods) then
m := l_info.mapping
if attached m.routed_handler (req, res, Current) as r then
is_dispatched := True
Result := r
end
m.try (req, res, sess, Current)
end
end
end

View File

@@ -1,6 +1,7 @@
note
description: "Summary description for {WSF_ROUTER_MAPPING}."
author: ""
description: "[
Describes a route or mapping for the WSF_ROUTER
]"
date: "$Date$"
revision: "$Revision$"
@@ -23,14 +24,14 @@ feature {NONE} -- Initialization
feature -- Access
associated_resource: READABLE_STRING_8
-- Name (URI, or URI template or regular expression or ...) of handled resource
-- Name (URI, or URI template or regular expression or ...) of handled resource.
deferred
ensure
assciated_resource_not_void: Result /= Void
end
handler: WSF_HANDLER
-- Handler associated with `Current' mapping
-- Handler associated with `Current' mapping.
deferred
ensure
handler_attached: Result /= Void
@@ -39,7 +40,7 @@ feature -- Access
feature -- Documentation
description: READABLE_STRING_32
-- Short description of associated mapping
-- Short description of associated mapping.
deferred
ensure
description_attached: Result /= Void
@@ -63,11 +64,13 @@ feature -- Status
deferred
end
routed_handler (req: WSF_REQUEST; res: WSF_RESPONSE; a_router: WSF_ROUTER): detachable WSF_HANDLER
-- Handler when `Current' matches the request `req'
try (req: WSF_REQUEST; res: WSF_RESPONSE; sess: WSF_ROUTER_SESSION; a_router: WSF_ROUTER)
-- Try using `Current' mapping and if it matches request `req'
-- execute associated handler and set this handler in session `sess'.
require
req_attached: req /= Void
res_attached: res /= Void
sess_attached: sess /= Void
a_router_attached: a_router /= Void
deferred
end
@@ -75,7 +78,7 @@ feature -- Status
feature -- Helper
path_from_request (req: WSF_REQUEST): READABLE_STRING_32
-- Path used by `Current' to check that mapping matches request `req'
-- Path used by `Current' to check that mapping matches request `req'.
require
req_attached: req /= Void
do

View File

@@ -0,0 +1,46 @@
note
description: "[
This class represents the processing of a request via a WSF_ROUTER.
]"
date: "$Date$"
revision: "$Revision$"
class
WSF_ROUTER_SESSION
feature -- Status report
dispatched: BOOLEAN
-- Handler dispatched?
do
Result := dispatched_handler /= Void
ensure
Result implies dispatched_handler /= Void
end
feature -- Access
dispatched_handler: detachable WSF_HANDLER
-- Handler dispatched
feature -- Change
set_dispatched_handler (h: like dispatched_handler)
do
dispatched_handler := h
ensure
h_set: dispatched_handler = h
end
note
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, 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

View File

@@ -54,16 +54,18 @@ feature -- Execution
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
-- Execute request handler
local
sess: WSF_ROUTER_SESSION
do
if attached router.dispatch_and_return_handler (req, res) as h then
check is_dispatched: router.is_dispatched end
else
create sess
router.dispatch (req, res, sess)
if not sess.dispatched then
res.put_header ({HTTP_STATUS_CODE}.not_found, <<[{HTTP_HEADER_NAMES}.header_content_length, "0"]>>)
end
end
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -0,0 +1,27 @@
note
description: "Summary description for {WSF_STARTS_WITH_CONTEXT_ROUTED_SERVICE}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_STARTS_WITH_CONTEXT_ROUTED_SERVICE [C -> WSF_HANDLER_CONTEXT create make end]
obsolete "Inherit from WSF_ROUTED_SERVICE and WSF_STARTS_WITH_CONTEXT_ROUTER_HELPER [2013-mar-19]"
inherit
WSF_ROUTED_SERVICE
WSF_STARTS_WITH_CONTEXT_ROUTER_HELPER [C]
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, 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

View File

@@ -5,10 +5,13 @@ note
revision: "$Revision$"
deferred class
WSF_STARTS_WITH_CONTEXT_ROUTED_SERVICE [C -> WSF_HANDLER_CONTEXT create make end]
WSF_STARTS_WITH_CONTEXT_ROUTER_HELPER [C -> WSF_HANDLER_CONTEXT create make end]
inherit
WSF_ROUTED_SERVICE
feature -- Access
router: WSF_ROUTER
deferred
end
feature -- Mapping helper: starts_with

View File

@@ -0,0 +1,28 @@
note
description: "Summary description for {WSF_URI_CONTEXT_ROUTED_SERVICE}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_URI_CONTEXT_ROUTED_SERVICE [C -> WSF_HANDLER_CONTEXT create make end]
obsolete "Inherit from WSF_ROUTED_SERVICE and WSF_URI_CONTEXT_ROUTER_HELPER [2013-mar-19]"
inherit
WSF_ROUTED_SERVICE
WSF_URI_CONTEXT_ROUTER_HELPER [C]
note
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, 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

View File

@@ -1,14 +1,17 @@
note
description: "Summary description for {WSF_URI_CONTEXT_ROUTED_SERVICE}."
description: "Summary description for {WSF_URI_CONTEXT_ROUTER_HELPER}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_URI_CONTEXT_ROUTED_SERVICE [C -> WSF_HANDLER_CONTEXT create make end]
WSF_URI_CONTEXT_ROUTER_HELPER [C -> WSF_HANDLER_CONTEXT create make end]
inherit
WSF_ROUTED_SERVICE
feature -- Access
router: WSF_ROUTER
deferred
end
feature -- Mapping helper: uri

View File

@@ -0,0 +1,27 @@
note
description: "Summary description for {WSF_URI_TEMPLATE_CONTEXT_ROUTED_SERVICE}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_URI_TEMPLATE_CONTEXT_ROUTED_SERVICE [C -> WSF_HANDLER_CONTEXT create make end]
obsolete "Inherit from WSF_ROUTED_SERVICE and WSF_URI_TEMPLATE_CONTEXT_ROUTER_HELPER [2013-mar-19]"
inherit
WSF_ROUTED_SERVICE
WSF_URI_TEMPLATE_CONTEXT_ROUTER_HELPER [C]
note
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, 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

View File

@@ -1,14 +1,17 @@
note
description: "Summary description for {WSF_URI_TEMPLATE_CONTEXT_ROUTED_SERVICE}."
description: "Summary description for {WSF_URI_TEMPLATE_CONTEXT_ROUTER_HELPER}."
author: ""
date: "$Date$"
revision: "$Revision$"
deferred class
WSF_URI_TEMPLATE_CONTEXT_ROUTED_SERVICE [C -> WSF_HANDLER_CONTEXT create make end]
WSF_URI_TEMPLATE_CONTEXT_ROUTER_HELPER [C -> WSF_HANDLER_CONTEXT create make end]
inherit
WSF_ROUTED_SERVICE
feature -- Access
router: WSF_ROUTER
deferred
end
feature -- Mapping helper: uri

View File

@@ -8,18 +8,10 @@ deferred class
WSF_FILTER_CONTEXT_HANDLER [C -> WSF_HANDLER_CONTEXT create make end]
inherit
WSF_FILTER_HANDLER
redefine
next
end
WSF_FILTER_HANDLER [WSF_CONTEXT_HANDLER [C]]
WSF_CONTEXT_HANDLER [C]
feature -- Access
next: detachable WSF_CONTEXT_HANDLER [C]
-- Next handler
feature {NONE} -- Implementation
execute_next (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
@@ -30,7 +22,7 @@ feature {NONE} -- Implementation
end
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -31,7 +31,7 @@ feature -- Access
-- Associated mapping
;note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -0,0 +1,68 @@
note
description: "Response to an OPTIONS request, with Cross-Origin Resource Sharing support."
author: "Olivier Ligt"
date: "$Date$"
revision: "$Revision$"
EIS: "name=Cross-Origin Resource Sharing", "src=http://www.w3.org/TR/cors/", "tag=W3C"
class
WSF_CORS_OPTIONS_RESPONSE
inherit
WSF_RESPONSE_MESSAGE
create
make
feature {NONE} -- Initialization
make (req: WSF_REQUEST; a_router: like router)
do
request := req
router := a_router
create header.make
end
feature -- Access
request: WSF_REQUEST
-- Associated request
router: WSF_ROUTER
-- Associated router
header: HTTP_HEADER
-- Response' header
feature {WSF_RESPONSE} -- Output
send_to (res: WSF_RESPONSE)
local
l_methods: WSF_REQUEST_METHODS
do
res.set_status_code ({HTTP_STATUS_CODE}.Ok)
header.put_content_type ({HTTP_MIME_TYPES}.text_plain)
header.put_current_date
header.put_content_length (0)
if attached request.http_access_control_request_headers as l_headers then
header.put_access_control_allow_headers (l_headers)
end
l_methods := router.allowed_methods_for_request (request)
if not l_methods.is_empty then
header.put_allow (l_methods)
header.put_access_control_allow_methods (l_methods)
end
res.put_header_text (header.string)
end
note
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, 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

View File

@@ -19,6 +19,7 @@ feature {NONE} -- Initialization
make (a_file_name: READABLE_STRING_8)
do
set_status_code ({HTTP_STATUS_CODE}.ok)
file_name := a_file_name
base_name := basename (a_file_name)
get_content_type
@@ -28,6 +29,7 @@ feature {NONE} -- Initialization
make_with_content_type (a_content_type: READABLE_STRING_8; a_filename: READABLE_STRING_8)
-- Initialize `Current'.
do
set_status_code ({HTTP_STATUS_CODE}.ok)
file_name := a_filename
base_name := basename (a_filename)
content_type := a_content_type
@@ -54,6 +56,14 @@ feature {NONE} -- Initialization
feature -- Element change
set_base_name (n: like base_name)
do
base_name := n
header.put_content_disposition ("attachment", "filename=%""+ n +"%"")
ensure
base_name_set: n.same_string (base_name)
end
set_expires (t: INTEGER)
do
header.put_expires (t)
@@ -91,7 +101,7 @@ feature -- Element change
set_status_code (c: like status_code)
-- Set `status_code' to `c'.
require
valid_status_code: status_code > 0
valid_status_code: c > 0
do
status_code := c
ensure
@@ -207,8 +217,11 @@ feature -- Implementation: output
f.close
end
invariant
status_code_set: status_code /= 0
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -19,6 +19,7 @@ feature {NONE} -- Initialization
make (a_file_name: READABLE_STRING_8)
do
set_status_code ({HTTP_STATUS_CODE}.ok)
file_name := a_file_name
get_content_type
initialize
@@ -27,6 +28,7 @@ feature {NONE} -- Initialization
make_with_content_type (a_content_type: READABLE_STRING_8; a_filename: READABLE_STRING_8)
-- Initialize `Current'.
do
set_status_code ({HTTP_STATUS_CODE}.ok)
file_name := a_filename
content_type := a_content_type
initialize
@@ -279,7 +281,7 @@ feature {NONE} -- Implementation: output
end
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -0,0 +1,81 @@
note
description: "[
This class is used to report a 501 not implemented
]"
date: "$Date$"
revision: "$Revision$"
class
WSF_NOT_IMPLEMENTED_RESPONSE
inherit
WSF_RESPONSE_MESSAGE
SHARED_HTML_ENCODER
create
make
feature {NONE} -- Initialization
make (req: WSF_REQUEST)
do
create header.make
request := req
end
feature -- Header
header: HTTP_HEADER
-- Response' header
request: WSF_REQUEST
-- Associated request.
body: detachable READABLE_STRING_8
-- Optional body
-- Displayed as extra content
feature -- Element change
set_body (b: like body)
-- Set `body' to `b'
do
body := b
end
feature {WSF_RESPONSE} -- Output
send_to (res: WSF_RESPONSE)
local
s: STRING
h: like header
do
h := header
res.set_status_code ({HTTP_STATUS_CODE}.not_implemented)
s := "Error 501 Not Implemented ! "
s.append (request.request_uri)
if attached body as b then
s.append ("%N")
s.append (b)
s.append ("%N")
end
h.put_content_type_text_plain
h.put_content_length (s.count)
res.put_header_text (h.string)
res.put_string (s)
res.flush
end
note
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Olivier Ligot, 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

View File

@@ -1041,6 +1041,13 @@ feature -- HTTP_*
Result := wgi_request.http_transfer_encoding
end
http_access_control_request_headers: detachable READABLE_STRING_8
-- Indicates which headers will be used in the actual request
-- as part of the preflight request
do
Result := wgi_request.http_access_control_request_headers
end
feature -- Extra CGI environment variables
request_uri: READABLE_STRING_8

View File

@@ -12,7 +12,8 @@
<library name="base" location="$ISE_LIBRARY/library/base/base-safe.ecf"/>
<library name="http" location="../../network/protocol/http/http-safe.ecf"/>
<library name="ewsgi" location="..\ewsgi\ewsgi-safe.ecf"/>
<library name="wsf-safe" location="wsf-safe.ecf"/>
<library name="wsf" location="wsf-safe.ecf"/>
<library name="wsf_router_context" location="wsf_router_context-safe.ecf" readonly="true"/>
<cluster name="extension" location="./extension" recursive="true"/>
</target>
</system>

View File

@@ -13,6 +13,7 @@
<library name="http" location="../../network/protocol/http/http.ecf"/>
<library name="ewsgi" location="..\ewsgi\ewsgi.ecf"/>
<library name="wsf" location="wsf.ecf"/>
<library name="wsf_router_context" location="wsf_router_context.ecf" readonly="true"/>
<cluster name="extension" location="./extension" recursive="true"/>
</target>
</system>

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<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="wsf_router_context" uuid="1A0F9B0E-26CE-4DE0-BE47-C74D1AB2B389" library_target="wsf_router_context">
<target name="wsf_router_context">
<root all_classes="true"/>
<file_rule>
<exclude>/.git$</exclude>
<exclude>/EIFGENs$</exclude>
<exclude>/.svn$</exclude>
</file_rule>
<option warning="true" full_class_checking="true" is_attached_by_default="true" void_safety="all">
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="wsf" location="wsf-safe.ecf"/>
<cluster name="router_context" location=".\router_context" recursive="true"/>
</target>
</system>

View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<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="wsf_router_context" uuid="1A0F9B0E-26CE-4DE0-BE47-C74D1AB2B389" library_target="wsf_router_context">
<target name="wsf_router_context">
<root all_classes="true"/>
<file_rule>
<exclude>/.git$</exclude>
<exclude>/EIFGENs$</exclude>
<exclude>/.svn$</exclude>
</file_rule>
<option warning="true" full_class_checking="true">
</option>
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
<library name="wsf" location="wsf.ecf"/>
<cluster name="router_context" location=".\router_context" recursive="true"/>
</target>
</system>

View File

@@ -31,6 +31,7 @@
<library name="ewf_support" location="..\library\server\ewf_support\ewf_support-safe.ecf" readonly="false"/>
<library name="wsf_extension" location="..\library\server\wsf\wsf_extension-safe.ecf" readonly="false"/>
<library name="wsf_session" location="..\library\server\wsf\wsf_session-safe.ecf" readonly="false"/>
<library name="wsf_router_context" location="..\library\server\wsf\wsf_router_context-safe.ecf" readonly="false"/>
<library name="ex_restbuck" location="..\examples\restbucksCRUD\restbucks-safe.ecf" readonly="false"/>
<library name="ex_simple" location="..\examples\simple\simple.ecf" readonly="false"/>
<library name="ex_filter" location="..\examples\filter\filter-safe.ecf" readonly="false"/>

View File

@@ -77,6 +77,11 @@ echo Install library: http
echo Install library: http_authorization
%SAFE_MD% %TMP_CONTRIB_DIR%\library\network\authentication
%COPYCMD% %TMP_DIR%\library\server\authentication\http_authorization %TMP_CONTRIB_DIR%\library\network\authentication\http_authorization
echo Install library: openid
%SAFE_MD% %TMP_CONTRIB_DIR%\library\security
%COPYCMD% %TMP_DIR%\library\security\openid %TMP_CONTRIB_DIR%\library\security\openid
echo Install library: uri_template
%COPYCMD% %TMP_DIR%\library\text\parser\uri_template %TMP_CONTRIB_DIR%\library\text\parser\uri_template

View File

@@ -70,6 +70,9 @@ COPYCMD $TMP_DIR/library/network/protocol/http $TMP_CONTRIB_DIR/library/network/
echo Install library: http_authorization
mkdir -p $TMP_CONTRIB_DIR/library/network/authentication
COPYCMD $TMP_DIR/library/server/authentication/http_authorization $TMP_CONTRIB_DIR/library/network/authentication/http_authorization
echo Install library: openid
mkdir -p $TMP_CONTRIB_DIR/library/security/openid
COPYCMD $TMP_DIR/library/security/openid $TMP_CONTRIB_DIR/library/security/openid
echo Install library: uri_template
mkdir -p $TMP_CONTRIB_DIR/library/text/parser
COPYCMD $TMP_DIR/library/text/parser/uri_template $TMP_CONTRIB_DIR/library/text/parser/uri_template

View File

@@ -54,10 +54,14 @@ echo Uninstall library: http_client
%RDCMD% %TMP_CONTRIB_DIR%\library\network\http_client
echo Uninstall library: http
%RDCMD% %TMP_CONTRIB_DIR%\library\network\protocol\http
echo Uninstall library: http_authorization
%RDCMD% %TMP_CONTRIB_DIR%\library\network\authentication\http_authorization
echo Uninstall library: security\openid
%RDCMD% %TMP_CONTRIB_DIR%\library\security\openid
echo Uninstall library: uri_template
%RDCMD% %TMP_CONTRIB_DIR%\library\text\parser\uri_template
echo Uninstall contrib library: nino
%RDCMD% %TMP_CONTRIB_DIR%\contrib\library\network\server\nino
%RDCMD% %TMP_CONTRIB_DIR%\library\network\server\nino
:end