Updated WGI specification to ease future migration to unicode support.

Use STRING_TABLE, and better interface of READABLE_STRING_GENERAL,
    this way the signature are more flexible for unicode keys.

    Note that for now, unicode environment variables are not correctly supported in WGI
    especially the value of the variables.
    Any layer on top of EWGSI suffers from the same issues.

Better exception handling

+ code cleaning
This commit is contained in:
2013-06-12 18:50:45 +02:00
parent 225cda0af7
commit f653507fc8
7 changed files with 52 additions and 43 deletions

View File

@@ -61,9 +61,11 @@ feature -- Execution
end
end
rescue
if not rescued then
rescued := True
retry
end
end
note
copyright: "2011-2013, Eiffel Software and others"

View File

@@ -55,7 +55,7 @@ feature -- Server
feature -- Execution
process_fcgi_request (vars: HASH_TABLE [STRING, STRING]; a_input: like input; a_output: like output)
process_fcgi_request (vars: STRING_TABLE [READABLE_STRING_8]; a_input: like input; a_output: like output)
local
req: WGI_REQUEST_FROM_TABLE
res: detachable WGI_RESPONSE_STREAM
@@ -82,9 +82,11 @@ feature -- Execution
end
end
rescue
if not rescued then
rescued := True
retry
end
end
feature -- Input/Output

View File

@@ -127,20 +127,28 @@ feature -- Server
server.setup (l_http_handler)
end
process_request (env: HASH_TABLE [STRING, STRING]; a_headers_text: STRING; a_socket: TCP_STREAM_SOCKET)
process_request (env: STRING_TABLE [READABLE_STRING_8]; a_headers_text: STRING; a_socket: TCP_STREAM_SOCKET)
local
req: WGI_REQUEST_FROM_TABLE
res: detachable WGI_NINO_RESPONSE_STREAM
retried: BOOLEAN
do
if not retried then
create req.make (env, create {WGI_NINO_INPUT_STREAM}.make (a_socket), Current)
create res.make (create {WGI_NINO_OUTPUT_STREAM}.make (a_socket), create {WGI_NINO_ERROR_STREAM}.make_stderr (a_socket.descriptor.out))
req.set_meta_string_variable ("RAW_HEADER_DATA", a_headers_text)
service.execute (req, res)
res.push
end
rescue
if not retried then
retried := True
retry
end
end
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -61,24 +61,24 @@ feature -- Request processing
process_request (a_handler: HTTP_CONNECTION_HANDLER; a_socket: TCP_STREAM_SOCKET)
-- Process request ...
local
env: HASH_TABLE [STRING, STRING]
env: STRING_TABLE [READABLE_STRING_8]
p: INTEGER
l_request_uri, l_script_name, l_query_string, l_path_info: STRING
l_server_name, l_server_port: detachable STRING
a_headers_map: HASH_TABLE [STRING, STRING]
l_headers_map: HASH_TABLE [STRING, STRING]
vn: STRING
e: EXECUTION_ENVIRONMENT
do
l_request_uri := a_handler.uri
a_headers_map := a_handler.request_header_map
l_headers_map := a_handler.request_header_map
create e
if attached e.starting_environment_variables as vars then
create env.make (vars.count)
create env.make_equal (vars.count)
across
vars as c
loop
env.force (c.item.to_string_8, c.key.to_string_8)
env.force (c.item.to_string_8, c.key)
end
else
create env.make (0)
@@ -86,11 +86,11 @@ feature -- Request processing
--| for Any Abc-Def-Ghi add (or replace) the HTTP_ABC_DEF_GHI variable to `env'
from
a_headers_map.start
l_headers_map.start
until
a_headers_map.after
l_headers_map.after
loop
create vn.make_from_string (a_headers_map.key_for_iteration.as_upper)
create vn.make_from_string (l_headers_map.key_for_iteration.as_upper)
vn.replace_substring_all ("-", "_")
if
vn.starts_with ("CONTENT_") and then
@@ -100,8 +100,8 @@ feature -- Request processing
else
vn.prepend ("HTTP_")
end
add_environment_variable (a_headers_map.item_for_iteration, vn, env)
a_headers_map.forth
add_environment_variable (l_headers_map.item_for_iteration, vn, env)
l_headers_map.forth
end
--| Specific cases
@@ -114,7 +114,7 @@ feature -- Request processing
l_script_name := l_request_uri.string
l_query_string := ""
end
if attached a_headers_map.item ("Host") as l_host then
if attached l_headers_map.item ("Host") as l_host then
check has_host: env.has ("HTTP_HOST") end
-- set_environment_variable (l_host, "HTTP_HOST", env)
p := l_host.index_of (':', 1)
@@ -129,7 +129,7 @@ feature -- Request processing
check host_available: False end
end
if attached a_headers_map.item ("Authorization") as l_authorization then
if attached l_headers_map.item ("Authorization") as l_authorization then
check has_authorization: env.has ("HTTP_AUTHORIZATION") end
-- set_environment_variable (l_authorization, "HTTP_AUTHORIZATION", env)
p := l_authorization.index_of (' ', 1)
@@ -174,7 +174,7 @@ feature -- Request processing
callback.process_request (env, a_handler.request_header, a_socket)
end
add_environment_variable (a_value: detachable STRING; a_var_name: STRING; env: HASH_TABLE [STRING, STRING])
add_environment_variable (a_value: detachable STRING; a_var_name: READABLE_STRING_GENERAL; env: STRING_TABLE [READABLE_STRING_8])
-- Add variable `a_var_name => a_value' to `env'
do
if a_value /= Void then
@@ -188,7 +188,7 @@ feature -- Request processing
end
end
set_environment_variable (a_value: detachable STRING; a_var_name: STRING; env: HASH_TABLE [STRING, STRING])
set_environment_variable (a_value: detachable STRING; a_var_name: READABLE_STRING_GENERAL; env: STRING_TABLE [READABLE_STRING_8])
-- Add variable `a_var_name => a_value' to `env'
do
if a_value /= Void then
@@ -197,7 +197,7 @@ feature -- Request processing
end
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -88,14 +88,14 @@ feature -- Access: Input
feature -- Access: CGI meta variables
meta_variable (a_name: READABLE_STRING_8): detachable READABLE_STRING_8
meta_variable (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_8
-- Environment variable related to `a_name'
require
a_name_valid: a_name /= Void and then not a_name.is_empty
deferred
end
meta_string_variable (a_name: READABLE_STRING_8): detachable READABLE_STRING_8
meta_string_variable (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_8
-- Environment variable related to `a_name'
require
a_name_valid: a_name /= Void and then not a_name.is_empty
@@ -105,7 +105,7 @@ feature -- Access: CGI meta variables
end
end
meta_variables: HASH_TABLE [READABLE_STRING_8, READABLE_STRING_8]
meta_variables: STRING_TABLE [READABLE_STRING_8]
-- These variables are specific to requests made with HTTP.
-- Interpretation of these variables may depend on the value of
-- SERVER_PROTOCOL.
@@ -635,7 +635,7 @@ invariant
path_info_identical: path_info ~ meta_string_variable ({WGI_META_NAMES}.path_info)
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software

View File

@@ -138,8 +138,6 @@ feature -- Input
nb_large_enough: nb > 0
local
s: like last_string
i, end_pos: INTEGER
l_count: INTEGER
n: INTEGER
l_remaining: INTEGER
do

View File

@@ -61,16 +61,16 @@ feature -- EWSGI access
feature -- Access: CGI meta parameters
meta_variables: HASH_TABLE [READABLE_STRING_8, READABLE_STRING_8]
meta_variables: STRING_TABLE [READABLE_STRING_8]
-- CGI Environment parameters
meta_variable (a_name: READABLE_STRING_8): detachable READABLE_STRING_8
meta_variable (a_name: READABLE_STRING_GENERAL): detachable READABLE_STRING_8
-- CGI meta variable related to `a_name'
do
Result := meta_variables.item (a_name)
end
meta_string_variable_or_default (a_name: READABLE_STRING_8; a_default: READABLE_STRING_8; use_default_when_empty: BOOLEAN): READABLE_STRING_8
meta_string_variable_or_default (a_name: READABLE_STRING_GENERAL; a_default: READABLE_STRING_8; use_default_when_empty: BOOLEAN): READABLE_STRING_8
-- Value for meta parameter `a_name'
-- If not found, return `a_default'
require
@@ -86,14 +86,14 @@ feature -- Access: CGI meta parameters
end
end
set_meta_string_variable (a_name: READABLE_STRING_8; a_value: READABLE_STRING_8)
set_meta_string_variable (a_name: READABLE_STRING_GENERAL; a_value: READABLE_STRING_8)
do
meta_variables.force (a_value, a_name)
ensure
param_set: attached meta_variable (a_name) as val and then val ~ a_value
end
unset_meta_variable (a_name: READABLE_STRING_8)
unset_meta_variable (a_name: READABLE_STRING_GENERAL)
do
meta_variables.remove (a_name)
ensure
@@ -268,7 +268,7 @@ feature {NONE} -- Element change: CGI meta parameter related to PATH_INFO
-- Fill with variable from `a_vars'
local
s: like meta_string_variable
table: HASH_TABLE [READABLE_STRING_8, READABLE_STRING_8]
table: STRING_TABLE [READABLE_STRING_8]
l_query_string: like query_string
l_request_uri: detachable STRING_32
l_empty_string: like empty_string
@@ -276,15 +276,14 @@ feature {NONE} -- Element change: CGI meta parameter related to PATH_INFO
create {STRING_8} l_empty_string.make_empty
empty_string := l_empty_string
create table.make (a_vars.count)
table.compare_objects
create table.make_equal (a_vars.count)
meta_variables := table
from
a_vars.start
until
a_vars.after
loop
table.force (a_vars.item_for_iteration.to_string_8, a_vars.key_for_iteration.to_string_8)
table.force (a_vars.item_for_iteration.to_string_8, a_vars.key_for_iteration)
a_vars.forth
end
@@ -446,7 +445,7 @@ invariant
empty_string_unchanged: empty_string.is_empty
note
copyright: "2011-2012, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
copyright: "2011-2013, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
source: "[
Eiffel Software