Implemented support for base url in httpd connector.

This commit is contained in:
2015-03-25 22:22:57 +01:00
parent b4a9c92ffc
commit 7d2ce8a77f
19 changed files with 168 additions and 198 deletions

View File

@@ -16,55 +16,7 @@
<library name="encoder" location="..\..\..\..\text\encoder\encoder-safe.ecf"/>
<library name="ewsgi" location="..\..\ewsgi-safe.ecf" readonly="false"/>
<library name="http" location="..\..\..\..\network\protocol\http\http-safe.ecf"/>
<library name="net" location="$ISE_LIBRARY\library\net\net-safe.ecf">
<option>
<assertions precondition="true" postcondition="true" check="true"/>
</option>
</library>
<library name="net_ssl" location="$ISE_LIBRARY\unstable\library\network\socket\netssl\net_ssl-safe.ecf">
<condition>
<custom name="httpd_ssl_enabled" value="true"/>
</condition>
</library>
<library name="thread" location="$ISE_LIBRARY\library\thread\thread-safe.ecf">
<condition>
<concurrency excluded_value="none"/>
</condition>
</library>
<library name="time" location="$ISE_LIBRARY\library\time\time-safe.ecf"/>
<cluster name="httpd_server" location=".\src\httpd\" recursive="true">
<file_rule>
<exclude>/ssl$</exclude>
<exclude>/EIFGENs$</exclude>
<exclude>/no_ssl$</exclude>
<exclude>/concurrency$</exclude>
</file_rule>
<cluster name="no_ssl" location="$|no_ssl\" recursive="true">
<condition>
<custom name="httpd_ssl_enabled" excluded_value="true"/>
</condition>
</cluster>
<cluster name="ssl" location="$|ssl\" recursive="true">
<condition>
<custom name="httpd_ssl_enabled" value="true"/>
</condition>
</cluster>
<cluster name="concurrency_none" location="$|concurrency\none\" recursive="true">
<condition>
<concurrency value="none"/>
</condition>
</cluster>
<cluster name="concurrency_thread" location="$|concurrency\thread\" recursive="true">
<condition>
<concurrency value="thread"/>
</condition>
</cluster>
<cluster name="concurrency_scoop" location="$|concurrency\scoop\" recursive="true">
<condition>
<concurrency value="scoop"/>
</condition>
</cluster>
</cluster>
<library name="httpd" location="src\httpd\httpd-safe.ecf"/>
<cluster name="src" location=".\src\" recursive="true">
<file_rule>
<exclude>/httpd$</exclude>

View File

@@ -10,9 +10,8 @@
<option warning="true" full_class_checking="false" is_attached_by_default="true" void_safety="all" syntax="standard">
<assertions precondition="true" postcondition="true" check="true" invariant="true" loop="true" supplier_precondition="true"/>
</option>
<setting name="concurrency" value="thread"/>
<setting name="concurrency" value="scoop"/>
<library name="base" location="$ISE_LIBRARY\library\base\base-safe.ecf"/>
<library name="encoder" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\text\encoder\encoder-safe.ecf"/>
<library name="net" location="$ISE_LIBRARY\library\net\net-safe.ecf"/>
<library name="net_ssl" location="$ISE_LIBRARY\unstable\library\network\socket\netssl\net_ssl-safe.ecf">
<condition>

View File

@@ -46,7 +46,7 @@ feature {NONE} -- Initialization
set_base (a_base)
end
set_factory_connector (conn: detachable separate WGI_CONNECTOR; fac: separate WGI_HTTPD_REQUEST_HANDLER_FACTORY [G])
set_factory_connector (conn: detachable separate WGI_HTTPD_CONNECTOR [G]; fac: separate WGI_HTTPD_REQUEST_HANDLER_FACTORY [G])
do
fac.set_connector (conn)
end
@@ -129,8 +129,15 @@ feature -- Element change
end
set_max_concurrent_connections (nb: INTEGER)
require
nb_positive_or_zero: nb >= 0
do
set_max_concurrent_connections_on_configuration (nb, configuration)
end
set_is_verbose (b: BOOLEAN)
do
set_is_verbose_on_configuration (b, configuration)
end
feature {NONE} -- Implementation
@@ -145,6 +152,11 @@ feature {NONE} -- Implementation
cfg.set_max_concurrent_connections (nb)
end
set_is_verbose_on_configuration (b: BOOLEAN; cfg: like configuration)
do
cfg.set_is_verbose (b)
end
feature -- Server
launch

View File

@@ -14,6 +14,8 @@ inherit
REFACTORING_HELPER
SHARED_HTML_ENCODER
create
make,
make_with_connector
@@ -26,7 +28,21 @@ feature {NONE} -- Initialization
connector := conn
end
connector: detachable separate WGI_CONNECTOR
connector: detachable separate WGI_HTTPD_CONNECTOR [G]
base: detachable IMMUTABLE_STRING_8
do
if attached connector as conn then
if attached connector_base (conn) as l_base then
create Result.make_from_separate (l_base)
end
end
end
connector_base (conn: separate WGI_HTTPD_CONNECTOR [G]): detachable separate READABLE_STRING_8
do
Result := conn.base
end
feature -- Request processing
@@ -53,23 +69,10 @@ feature -- Request processing
create {G} exec.make (req, res)
exec.execute
res.flush
res.push
exec.clean
else
if attached (create {EXCEPTION_MANAGER}).last_exception as e and then attached e.exception_trace as l_trace then
if res /= Void then
if not res.status_is_set then
res.set_status_code ({HTTP_STATUS_CODE}.internal_server_error, Void)
end
if res.message_writable then
res.put_string ("<pre>")
res.put_string (l_trace)
res.put_string ("</pre>")
end
res.push
end
end
process_rescue (res)
if exec /= Void then
exec.clean
end
@@ -81,10 +84,21 @@ feature -- Request processing
end
end
base: detachable READABLE_STRING_8
process_rescue (res: detachable WGI_RESPONSE)
do
--TODO
to_implement ("Base url support")
if attached (create {EXCEPTION_MANAGER}).last_exception as e and then attached e.trace as l_trace then
if res /= Void then
if not res.status_is_set then
res.set_status_code ({HTTP_STATUS_CODE}.internal_server_error, Void)
end
if res.message_writable then
res.put_string ("<pre>")
res.put_string (html_encoder.encoded_string (l_trace))
res.put_string ("</pre>")
end
res.push
end
end
end
httpd_environment (a_socket: HTTPD_STREAM_SOCKET): STRING_TABLE [READABLE_STRING_8]
@@ -93,6 +107,7 @@ feature -- Request processing
l_request_uri, l_script_name, l_query_string, l_path_info: STRING
l_server_name, l_server_port: detachable STRING
l_headers_map: HASH_TABLE [STRING, STRING]
l_base: detachable READABLE_STRING_8
vn: STRING
e: EXECUTION_ENVIRONMENT
@@ -189,7 +204,11 @@ feature -- Request processing
set_environment_variable ({HTTPD_CONFIGURATION}.Server_details, "SERVER_SOFTWARE", Result)
--| Apply `base' value
if attached base as l_base and then l_request_uri /= Void then
l_base := base
if l_base = Void then
l_base := ""
end
if l_request_uri /= Void then
if l_request_uri.starts_with (l_base) then
l_path_info := l_request_uri.substring (l_base.count + 1, l_request_uri.count)
p := l_path_info.index_of ('?', 1)

View File

@@ -12,7 +12,7 @@ inherit
feature -- Access
connector: detachable separate WGI_CONNECTOR
connector: detachable separate WGI_HTTPD_CONNECTOR [G]
feature -- Element change