Made all libraries compilable in any mode (voidsafe or not)
Fixed related examples
This commit is contained in:
@@ -7,7 +7,7 @@
|
|||||||
<exclude>/EIFGENs$</exclude>
|
<exclude>/EIFGENs$</exclude>
|
||||||
<exclude>/.svn$</exclude>
|
<exclude>/.svn$</exclude>
|
||||||
</file_rule>
|
</file_rule>
|
||||||
<option warning="true" full_class_checking="true" void_safety="none" syntax="standard">
|
<option warning="true" full_class_checking="true" void_safety="none" syntax="provisional">
|
||||||
</option>
|
</option>
|
||||||
<library name="base" location="$ISE_LIBRARY/library/base/base.ecf"/>
|
<library name="base" location="$ISE_LIBRARY/library/base/base.ecf"/>
|
||||||
<library name="cURL" location="$ISE_LIBRARY/library/cURL/cURL.ecf"/>
|
<library name="cURL" location="$ISE_LIBRARY/library/cURL/cURL.ecf"/>
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ feature -- Status setting
|
|||||||
|
|
||||||
feature -- Header output operation
|
feature -- Header output operation
|
||||||
|
|
||||||
write_headers_string (a_headers: STRING)
|
write_headers_string (a_headers: READABLE_STRING_8)
|
||||||
require
|
require
|
||||||
status_set: status_is_set
|
status_set: status_is_set
|
||||||
header_not_committed: not header_committed
|
header_not_committed: not header_committed
|
||||||
@@ -80,7 +80,7 @@ feature -- Header output operation
|
|||||||
message_writable: message_writable
|
message_writable: message_writable
|
||||||
end
|
end
|
||||||
|
|
||||||
write_header (a_status_code: INTEGER; a_headers: detachable ARRAY [TUPLE [key: STRING; value: STRING]])
|
write_header (a_status_code: INTEGER; a_headers: detachable ARRAY [TUPLE [key: READABLE_STRING_8; value: READABLE_STRING_8]])
|
||||||
-- Send headers with status `a_status', and headers from `a_headers'
|
-- Send headers with status `a_status', and headers from `a_headers'
|
||||||
require
|
require
|
||||||
status_not_set: not status_is_set
|
status_not_set: not status_is_set
|
||||||
@@ -94,21 +94,21 @@ feature -- Header output operation
|
|||||||
|
|
||||||
feature -- Output operation
|
feature -- Output operation
|
||||||
|
|
||||||
write_string (s: STRING)
|
write_string (s: READABLE_STRING_8)
|
||||||
-- Send the string `s'
|
-- Send the string `s'
|
||||||
require
|
require
|
||||||
message_writable: message_writable
|
message_writable: message_writable
|
||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
write_substring (s: STRING; a_begin_index, a_end_index: INTEGER)
|
write_substring (s: READABLE_STRING_8; a_begin_index, a_end_index: INTEGER)
|
||||||
-- Send the substring `s[a_begin_index:a_end_index]'
|
-- Send the substring `s[a_begin_index:a_end_index]'
|
||||||
require
|
require
|
||||||
message_writable: message_writable
|
message_writable: message_writable
|
||||||
deferred
|
deferred
|
||||||
end
|
end
|
||||||
|
|
||||||
write_file_content (fn: STRING)
|
write_file_content (fn: READABLE_STRING_8)
|
||||||
-- Send the content of file `fn'
|
-- Send the content of file `fn'
|
||||||
require
|
require
|
||||||
message_writable: message_writable
|
message_writable: message_writable
|
||||||
|
|||||||
@@ -25,7 +25,14 @@ create
|
|||||||
|
|
||||||
feature -- Status report
|
feature -- Status report
|
||||||
|
|
||||||
authentication_required: BOOLEAN
|
authentication_required (req: WGI_REQUEST): BOOLEAN
|
||||||
|
do
|
||||||
|
Result := internal_authentication_required
|
||||||
|
end
|
||||||
|
|
||||||
|
feature {NONE} -- Implementation
|
||||||
|
|
||||||
|
internal_authentication_required: BOOLEAN
|
||||||
|
|
||||||
feature -- Execution
|
feature -- Execution
|
||||||
|
|
||||||
|
|||||||
@@ -63,9 +63,9 @@ feature -- Execution
|
|||||||
do
|
do
|
||||||
content_type_supported := <<{HTTP_CONSTANTS}.json_app, {HTTP_CONSTANTS}.xml_text, {HTTP_CONSTANTS}.plain_text>>
|
content_type_supported := <<{HTTP_CONSTANTS}.json_app, {HTTP_CONSTANTS}.xml_text, {HTTP_CONSTANTS}.plain_text>>
|
||||||
l_format_id := ctx.request_format_id ("format", content_type_supported)
|
l_format_id := ctx.request_format_id ("format", content_type_supported)
|
||||||
if ctx.authenticated then
|
if authenticated (ctx) then
|
||||||
l_full := attached ctx.query_parameter ("details") as v and then v.is_case_insensitive_equal ("true")
|
l_full := attached ctx.query_parameter ("details") as v and then v.is_case_insensitive_equal ("true")
|
||||||
if attached ctx.authenticated_identifier as log then
|
if attached authenticated_identifier (ctx) as log then
|
||||||
l_login := log.as_string_8
|
l_login := log.as_string_8
|
||||||
|
|
||||||
create h.make
|
create h.make
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ feature -- Execution
|
|||||||
-- if attached ctx.http_authorization_login_password as t then
|
-- if attached ctx.http_authorization_login_password as t then
|
||||||
-- s.append_string ("Check login=" + t.login + "<br/>%N")
|
-- s.append_string ("Check login=" + t.login + "<br/>%N")
|
||||||
-- end
|
-- end
|
||||||
if ctx.authenticated and then attached ctx.authenticated_identifier as l_login then
|
if authenticated (ctx) and then attached authenticated_identifier (ctx) as l_login then
|
||||||
s.append_string ("Authenticated: login=" + l_login.as_string_8 + "<br/>%N")
|
s.append_string ("Authenticated: login=" + l_login.as_string_8 + "<br/>%N")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ inherit
|
|||||||
end
|
end
|
||||||
|
|
||||||
REST_REQUEST_AGENT_HANDLER [APP_REQUEST_HANDLER_CONTEXT]
|
REST_REQUEST_AGENT_HANDLER [APP_REQUEST_HANDLER_CONTEXT]
|
||||||
|
undefine
|
||||||
|
authenticated
|
||||||
|
end
|
||||||
|
|
||||||
create
|
create
|
||||||
make
|
make
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ deferred class
|
|||||||
|
|
||||||
inherit
|
inherit
|
||||||
REST_REQUEST_HANDLER [APP_REQUEST_HANDLER_CONTEXT]
|
REST_REQUEST_HANDLER [APP_REQUEST_HANDLER_CONTEXT]
|
||||||
|
redefine
|
||||||
|
authenticated
|
||||||
|
end
|
||||||
|
|
||||||
APP_REQUEST_HELPER
|
APP_REQUEST_HELPER
|
||||||
|
|
||||||
@@ -17,7 +20,7 @@ feature {NONE} -- Initialization
|
|||||||
-- Initialize various attributes
|
-- Initialize various attributes
|
||||||
do
|
do
|
||||||
end
|
end
|
||||||
|
|
||||||
feature {NONE} -- Implementation
|
feature {NONE} -- Implementation
|
||||||
|
|
||||||
wgi_value_iteration_to_string (cur: ITERATION_CURSOR [WGI_VALUE]; using_pre: BOOLEAN): STRING_8
|
wgi_value_iteration_to_string (cur: ITERATION_CURSOR [WGI_VALUE]; using_pre: BOOLEAN): STRING_8
|
||||||
@@ -38,6 +41,24 @@ feature {NONE} -- Implementation
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
feature -- Auth
|
||||||
|
|
||||||
|
authenticated (ctx: APP_REQUEST_HANDLER_CONTEXT): BOOLEAN
|
||||||
|
-- Is authenticated?
|
||||||
|
do
|
||||||
|
--| To redefine if needed
|
||||||
|
if attached ctx.request.http_authorization as l_http_authorization then
|
||||||
|
Result := True
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
authenticated_identifier (ctx: APP_REQUEST_HANDLER_CONTEXT): detachable READABLE_STRING_32
|
||||||
|
do
|
||||||
|
if attached ctx.request.http_authorization as l_http_authorization then
|
||||||
|
Result := "foo" -- Implement it as you want
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
feature -- Helpers
|
feature -- Helpers
|
||||||
|
|
||||||
format_id (s: detachable STRING): INTEGER
|
format_id (s: detachable STRING): INTEGER
|
||||||
|
|||||||
@@ -9,29 +9,10 @@ class
|
|||||||
|
|
||||||
inherit
|
inherit
|
||||||
REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT
|
REST_REQUEST_URI_TEMPLATE_HANDLER_CONTEXT
|
||||||
redefine
|
|
||||||
authenticated,
|
|
||||||
authenticated_identifier
|
|
||||||
end
|
|
||||||
|
|
||||||
create
|
create
|
||||||
make
|
make
|
||||||
|
|
||||||
feature -- Auth
|
|
||||||
|
|
||||||
authenticated: BOOLEAN
|
|
||||||
do
|
|
||||||
if attached request.http_authorization as l_http_auth then
|
|
||||||
Result := True
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
authenticated_identifier: detachable READABLE_STRING_32
|
|
||||||
do
|
|
||||||
if authenticated then
|
|
||||||
Result := "foo"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
feature -- Format
|
feature -- Format
|
||||||
|
|
||||||
|
|||||||
@@ -10,12 +10,14 @@ class
|
|||||||
inherit
|
inherit
|
||||||
APP_REQUEST_HANDLER
|
APP_REQUEST_HANDLER
|
||||||
undefine
|
undefine
|
||||||
execute,
|
execute
|
||||||
pre_execute,
|
|
||||||
post_execute
|
|
||||||
end
|
end
|
||||||
|
|
||||||
REST_REQUEST_URI_TEMPLATE_ROUTING_HANDLER_I [APP_REQUEST_HANDLER, APP_REQUEST_HANDLER_CONTEXT]
|
REST_REQUEST_URI_TEMPLATE_ROUTING_HANDLER_I [APP_REQUEST_HANDLER, APP_REQUEST_HANDLER_CONTEXT]
|
||||||
|
undefine
|
||||||
|
authenticated,
|
||||||
|
pre_execute,
|
||||||
|
post_execute
|
||||||
redefine
|
redefine
|
||||||
router
|
router
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -14,31 +14,28 @@ 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: WGI_REQUEST; res: WGI_RESPONSE_BUFFER; a_content_types: detachable ARRAY [STRING]; a_uri_formats: detachable ARRAY [STRING])
|
||||||
local
|
local
|
||||||
s, uri_s: detachable STRING
|
accept_s, uri_s: detachable STRING
|
||||||
i, n: INTEGER
|
i, n: INTEGER
|
||||||
h: EWF_HEADER
|
|
||||||
do
|
do
|
||||||
create h.make
|
|
||||||
h.put_status ({HTTP_STATUS_CODE}.unsupported_media_type)
|
|
||||||
h.put_content_type_text_plain
|
|
||||||
|
|
||||||
if a_content_types /= Void then
|
if a_content_types /= Void then
|
||||||
create s.make (10)
|
create accept_s.make (10)
|
||||||
from
|
from
|
||||||
i := a_content_types.lower
|
i := a_content_types.lower
|
||||||
n := a_content_types.upper
|
n := a_content_types.upper
|
||||||
until
|
until
|
||||||
i > n
|
i > n
|
||||||
loop
|
loop
|
||||||
s.append_string (a_content_types[i])
|
accept_s.append_string (a_content_types[i])
|
||||||
if i < n then
|
if i < n then
|
||||||
s.append_character (',')
|
accept_s.append_character (',')
|
||||||
s.append_character (' ')
|
accept_s.append_character (' ')
|
||||||
end
|
end
|
||||||
i := i + 1
|
i := i + 1
|
||||||
end
|
end
|
||||||
h.put_header_key_value ("Accept", s)
|
else
|
||||||
|
accept_s := "*/*"
|
||||||
end
|
end
|
||||||
|
|
||||||
if a_uri_formats /= Void then
|
if a_uri_formats /= Void then
|
||||||
create uri_s.make (10)
|
create uri_s.make (10)
|
||||||
from
|
from
|
||||||
@@ -56,9 +53,9 @@ feature -- Helper
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
res.set_status_code ({HTTP_STATUS_CODE}.unsupported_media_type)
|
res.set_status_code ({HTTP_STATUS_CODE}.unsupported_media_type)
|
||||||
res.write_headers_string (h.string)
|
res.write_header ({HTTP_STATUS_CODE}.unsupported_media_type, << ["Content-Type", "text/plain"], ["Accept", accept_s]>>)
|
||||||
if s /= Void then
|
if accept_s /= Void then
|
||||||
res.write_string ("Unsupported request content-type, Accept: " + s + "%N")
|
res.write_string ("Unsupported request content-type, Accept: " + accept_s + "%N")
|
||||||
end
|
end
|
||||||
if uri_s /= Void then
|
if uri_s /= Void then
|
||||||
res.write_string ("Unsupported request format from the URI: " + uri_s + "%N")
|
res.write_string ("Unsupported request format from the URI: " + uri_s + "%N")
|
||||||
|
|||||||
Reference in New Issue
Block a user