Nino connector:
- fixed issue related to `ready_for_reading' now use the `try_...' variant - for now Nino does not support persistent connection, then we have to respond with "Connection: close" REQUEST_FILE_SYSTEM_HANDLER: - added not_found_handler and access_denied_handler, so that the user can customize related response WSF_REQUEST and WSF_VALUE: - modified how uploaded file are handled, fixed various issues, and added WSF_UPLOADED_FILE (it is a WSF_VALUE) WSF_VALUE: - added change_name (a_name: like name) - added url_encoded_name to other WSF_values WSF_REQUEST: - added `destroy' to perform end of request cleaning (such as deleting temp uploaded files) - renamed `raw_post_data_recorded' as `raw_input_data_recorded', and related feature - do not store the RAW_POST_DATA in meta variable anymore, but in WSF_REQUEST.raw_input_data is asked Added WSF_HTML_PAGE_RESPONSE to help user WSF_REPONSE.redirect_... now use "temp_redirect" as default instead of "moved_permanently" which is specific usage Removed many obsolete features.
This commit is contained in:
@@ -31,6 +31,11 @@ feature -- Access
|
||||
directory_index: detachable ARRAY [READABLE_STRING_8]
|
||||
-- File serve if a directory index is requested
|
||||
|
||||
not_found_handler: detachable PROCEDURE [ANY, TUPLE [uri: READABLE_STRING_8; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE]]
|
||||
|
||||
access_denied_handler: detachable PROCEDURE [ANY, TUPLE [uri: READABLE_STRING_8; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE]]
|
||||
|
||||
|
||||
feature -- Element change
|
||||
|
||||
set_directory_index (idx: like directory_index)
|
||||
@@ -43,6 +48,18 @@ feature -- Element change
|
||||
end
|
||||
end
|
||||
|
||||
set_not_found_handler (h: like not_found_handler)
|
||||
-- Set `not_found_handler' to `h'
|
||||
do
|
||||
not_found_handler := h
|
||||
end
|
||||
|
||||
set_access_denied_handler (h: like access_denied_handler)
|
||||
-- Set `access_denied_handler' to `h'
|
||||
do
|
||||
access_denied_handler := h
|
||||
end
|
||||
|
||||
feature -- Execution
|
||||
|
||||
execute (ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
@@ -168,15 +185,19 @@ feature -- Execution
|
||||
h: HTTP_HEADER
|
||||
s: STRING_8
|
||||
do
|
||||
create h.make
|
||||
h.put_content_type_text_plain
|
||||
create s.make_empty
|
||||
s.append ("Resource %"" + uri + "%" not found%N")
|
||||
res.set_status_code ({HTTP_STATUS_CODE}.not_found)
|
||||
h.put_content_length (s.count)
|
||||
res.put_header_text (h.string)
|
||||
res.put_string (s)
|
||||
res.flush
|
||||
if attached not_found_handler as hdl then
|
||||
hdl.call ([uri, ctx, req, res])
|
||||
else
|
||||
create h.make
|
||||
h.put_content_type_text_plain
|
||||
create s.make_empty
|
||||
s.append ("Resource %"" + uri + "%" not found%N")
|
||||
res.set_status_code ({HTTP_STATUS_CODE}.not_found)
|
||||
h.put_content_length (s.count)
|
||||
res.put_header_text (h.string)
|
||||
res.put_string (s)
|
||||
res.flush
|
||||
end
|
||||
end
|
||||
|
||||
respond_access_denied (uri: READABLE_STRING_8; ctx: C; req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
@@ -184,15 +205,19 @@ feature -- Execution
|
||||
h: HTTP_HEADER
|
||||
s: STRING_8
|
||||
do
|
||||
create h.make
|
||||
h.put_content_type_text_plain
|
||||
create s.make_empty
|
||||
s.append ("Resource %"" + uri + "%": Access denied%N")
|
||||
res.set_status_code ({HTTP_STATUS_CODE}.forbidden)
|
||||
h.put_content_length (s.count)
|
||||
res.put_header_text (h.string)
|
||||
res.put_string (s)
|
||||
res.flush
|
||||
if attached access_denied_handler as hdl then
|
||||
hdl.call ([uri, ctx, req, res])
|
||||
else
|
||||
create h.make
|
||||
h.put_content_type_text_plain
|
||||
create s.make_empty
|
||||
s.append ("Resource %"" + uri + "%": Access denied%N")
|
||||
res.set_status_code ({HTTP_STATUS_CODE}.forbidden)
|
||||
h.put_content_length (s.count)
|
||||
res.put_header_text (h.string)
|
||||
res.put_string (s)
|
||||
res.flush
|
||||
end
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
@@ -127,21 +127,50 @@ feature -- Query
|
||||
end
|
||||
end
|
||||
|
||||
feature -- String query
|
||||
feature -- Convertion
|
||||
|
||||
string_from (a_value: detachable WSF_VALUE): detachable READABLE_STRING_32
|
||||
-- String value from `a_value' if relevant.
|
||||
do
|
||||
if attached {WSF_STRING} a_value as val then
|
||||
Result := val.string
|
||||
end
|
||||
end
|
||||
|
||||
integer_from (a_value: detachable WSF_VALUE): INTEGER
|
||||
-- String value from `a_value' if relevant.
|
||||
do
|
||||
if attached string_from (a_value) as val then
|
||||
if val.is_integer then
|
||||
Result := val.to_integer
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Path parameter
|
||||
|
||||
is_integer_path_parameter (a_name: READABLE_STRING_8): BOOLEAN
|
||||
-- Is path parameter related to `a_name' an integer value?
|
||||
do
|
||||
Result := attached string_path_parameter (a_name) as s and then s.is_integer
|
||||
end
|
||||
|
||||
integer_path_parameter (a_name: READABLE_STRING_8): INTEGER
|
||||
-- Integer value for path parameter `a_name' if relevant.
|
||||
require
|
||||
is_integer_path_parameter: is_integer_path_parameter (a_name)
|
||||
do
|
||||
Result := integer_from (path_parameter (a_name))
|
||||
end
|
||||
|
||||
string_path_parameter (a_name: READABLE_STRING_8): detachable READABLE_STRING_32
|
||||
-- String value for path parameter `a_name' if relevant.
|
||||
do
|
||||
Result := string_from (path_parameter (a_name))
|
||||
end
|
||||
|
||||
string_array_path_parameter (a_name: READABLE_STRING_8): detachable ARRAY [READABLE_STRING_32]
|
||||
-- Array of string values for path parameter `a_name' if relevant.
|
||||
local
|
||||
i: INTEGER
|
||||
n: INTEGER
|
||||
@@ -164,12 +193,56 @@ feature -- String query
|
||||
Result.keep_head (n - 1)
|
||||
end
|
||||
|
||||
feature -- String parameter
|
||||
|
||||
is_integer_query_parameter (a_name: READABLE_STRING_8): BOOLEAN
|
||||
-- Is query parameter related to `a_name' an integer value?
|
||||
do
|
||||
Result := attached string_query_parameter (a_name) as s and then s.is_integer
|
||||
end
|
||||
|
||||
integer_query_parameter (a_name: READABLE_STRING_8): INTEGER
|
||||
-- Integer value for query parameter `a_name' if relevant.
|
||||
require
|
||||
is_integer_query_parameter: is_integer_query_parameter (a_name)
|
||||
do
|
||||
Result := integer_from (query_parameter (a_name))
|
||||
end
|
||||
|
||||
string_query_parameter (a_name: READABLE_STRING_8): detachable READABLE_STRING_32
|
||||
-- String value for query parameter `a_name' if relevant.
|
||||
do
|
||||
Result := string_from (query_parameter (a_name))
|
||||
end
|
||||
|
||||
string_array_query_parameter (a_name: READABLE_STRING_8): detachable ARRAY [READABLE_STRING_32]
|
||||
-- Array of string values for query parameter `a_name' if relevant.
|
||||
local
|
||||
i: INTEGER
|
||||
n: INTEGER
|
||||
do
|
||||
from
|
||||
i := 1
|
||||
n := 1
|
||||
create Result.make_filled ("", 1, 5)
|
||||
until
|
||||
i = 0
|
||||
loop
|
||||
if attached string_query_parameter (a_name + "[" + i.out + "]") as v then
|
||||
Result.force (v, n)
|
||||
n := n + 1
|
||||
i := i + 1
|
||||
else
|
||||
i := 0 -- Exit
|
||||
end
|
||||
end
|
||||
Result.keep_head (n - 1)
|
||||
end
|
||||
|
||||
feature -- Parameter
|
||||
|
||||
string_parameter (a_name: READABLE_STRING_8): detachable READABLE_STRING_32
|
||||
-- String value for path or query parameter `a_name' if relevant.
|
||||
do
|
||||
Result := string_from (parameter (a_name))
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user