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

@@ -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
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
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