Fixed WSF_REQUEST.script_url (..) for clean path
Added related autotests
This commit is contained in:
@@ -1202,7 +1202,7 @@ feature -- URL Utility
|
||||
-- Url relative to script name if any, extended by `a_path'
|
||||
local
|
||||
l_base_url: like internal_url_base
|
||||
i,m,n: INTEGER
|
||||
i,m,n,spos: INTEGER
|
||||
l_rq_uri: like request_uri
|
||||
do
|
||||
l_base_url := internal_url_base
|
||||
@@ -1220,13 +1220,23 @@ feature -- URL Utility
|
||||
until
|
||||
i > m or i > n or l_rq_uri[i] /= l_script_name[i]
|
||||
loop
|
||||
if l_rq_uri[i] = '/' then
|
||||
spos := i
|
||||
end
|
||||
i := i + 1
|
||||
end
|
||||
if i > 1 then
|
||||
if l_rq_uri[i-1] = '/' then
|
||||
i := i -1
|
||||
elseif spos > 0 then
|
||||
i := spos
|
||||
end
|
||||
spos := l_rq_uri.substring_index (path_info, i)
|
||||
if spos > 0 then
|
||||
l_base_url := l_rq_uri.substring (1, spos - 1)
|
||||
else
|
||||
l_base_url := l_rq_uri.substring (1, i - 1)
|
||||
end
|
||||
l_base_url := l_rq_uri.substring (1, i - 1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
91
library/server/wsf/tests/src/test_wsf_request_script_url.e
Normal file
91
library/server/wsf/tests/src/test_wsf_request_script_url.e
Normal file
@@ -0,0 +1,91 @@
|
||||
note
|
||||
description: "[
|
||||
Eiffel tests that can be executed by testing tool.
|
||||
]"
|
||||
author: "EiffelStudio test wizard"
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
testing: "type/manual"
|
||||
|
||||
class
|
||||
TEST_WSF_REQUEST_SCRIPT_URL
|
||||
|
||||
inherit
|
||||
EQA_TEST_SET
|
||||
|
||||
WSF_SERVICE
|
||||
undefine
|
||||
default_create
|
||||
end
|
||||
|
||||
feature {NONE} -- Events
|
||||
|
||||
port_number: INTEGER
|
||||
base_url: detachable STRING
|
||||
|
||||
feature -- Execution
|
||||
|
||||
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||
do
|
||||
--| do nothing
|
||||
end
|
||||
|
||||
feature -- Tests
|
||||
|
||||
test_script_url
|
||||
local
|
||||
req: WSF_REQUEST
|
||||
s: READABLE_STRING_8
|
||||
do
|
||||
--| Case #1
|
||||
req := new_request (<<
|
||||
["REQUEST_METHOD", "GET"],
|
||||
["QUERY_STRING", ""],
|
||||
["REQUEST_URI", "/foo/bar/test/home"],
|
||||
["SCRIPT_NAME", "/foo/bar/app.ext"],
|
||||
["PATH_INFO", "/test/home"]
|
||||
>>
|
||||
)
|
||||
s := req.script_url ("/new/path/")
|
||||
assert ("script_url (/new/path/) = %""+s+"%" but should be %"/foo/bar/new/path/%"", s.same_string ("/foo/bar/new/path/"))
|
||||
|
||||
--| Case #2
|
||||
req := new_request (<<
|
||||
["REQUEST_METHOD", "GET"],
|
||||
["QUERY_STRING", ""],
|
||||
["REQUEST_URI", "/foo/bar/abc/DEF"],
|
||||
["SCRIPT_NAME", "/foo/bar/app.ext"],
|
||||
["PATH_INFO", "/abc/DEF"]
|
||||
>>
|
||||
)
|
||||
s := req.script_url ("/new/path/")
|
||||
assert ("script_url (/new/path/) = %""+s+"%" but should be %"/foo/bar/new/path/%"", s.same_string ("/foo/bar/new/path/"))
|
||||
|
||||
--| Case #3
|
||||
req := new_request (<<
|
||||
["REQUEST_METHOD", "GET"],
|
||||
["QUERY_STRING", ""],
|
||||
["REQUEST_URI", "/intranet/collab/cms/home"],
|
||||
["SCRIPT_NAME", "/intranet/collab/collab.ews"],
|
||||
["PATH_INFO", "/home"]
|
||||
>>
|
||||
)
|
||||
s := req.script_url ("/new/path/")
|
||||
assert ("script_url (/new/path/) = %""+s+"%" but should be %"/intranet/collab/cms/new/path/%"", s.same_string ("/intranet/collab/cms/new/path/"))
|
||||
|
||||
end
|
||||
|
||||
feature {NONE} -- Implementation
|
||||
|
||||
new_request (a_meta: ARRAY [TUPLE [name: READABLE_STRING_8; value: READABLE_STRING_8]]): WSF_REQUEST
|
||||
local
|
||||
wgi_req: WGI_REQUEST
|
||||
req: WSF_REQUEST
|
||||
do
|
||||
create {WGI_REQUEST_NULL} wgi_req.make (Current, a_meta)
|
||||
create Result.make_from_wgi (wgi_req)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
49
library/server/wsf/tests/src/wgi_request_null.e
Normal file
49
library/server/wsf/tests/src/wgi_request_null.e
Normal file
@@ -0,0 +1,49 @@
|
||||
note
|
||||
description: "Summary description for {WGI_REQUEST_NULL}."
|
||||
author: ""
|
||||
date: "$Date$"
|
||||
revision: "$Revision$"
|
||||
|
||||
class
|
||||
WGI_REQUEST_NULL
|
||||
|
||||
inherit
|
||||
WGI_REQUEST_FROM_TABLE
|
||||
rename
|
||||
make as wgi_request_from_table_make
|
||||
end
|
||||
|
||||
create
|
||||
make
|
||||
|
||||
feature {NONE} -- Initialization
|
||||
|
||||
make (s: WSF_SERVICE; a_meta: ARRAY [TUPLE [name: READABLE_STRING_8; value: READABLE_STRING_8]])
|
||||
local
|
||||
ht: HASH_TABLE [READABLE_STRING_8, READABLE_STRING_8]
|
||||
i: WGI_NULL_INPUT_STREAM
|
||||
c: WGI_NULL_CONNECTOR
|
||||
do
|
||||
create c.make (s)
|
||||
create i.make
|
||||
create ht.make (a_meta.count)
|
||||
across
|
||||
a_meta as curs
|
||||
loop
|
||||
ht.force (curs.item.value, curs.item.name)
|
||||
end
|
||||
wgi_request_from_table_make (ht, i, c)
|
||||
end
|
||||
|
||||
|
||||
note
|
||||
copyright: "2011-2011, Eiffel Software and others"
|
||||
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||
source: "[
|
||||
Eiffel Software
|
||||
5949 Hollister Ave., Goleta, CA 93117 USA
|
||||
Telephone 805-685-1006, Fax 805-685-6869
|
||||
Website http://www.eiffel.com
|
||||
Customer support http://support.eiffel.com
|
||||
]"
|
||||
end
|
||||
@@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-8-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-8-0 http://www.eiffel.com/developers/xml/configuration-1-8-0.xsd" name="wsf_tests" uuid="CA72F5B3-E608-4FA5-8F05-A812441DB961">
|
||||
<system xmlns="http://www.eiffel.com/developers/xml/configuration-1-9-0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.eiffel.com/developers/xml/configuration-1-9-0 http://www.eiffel.com/developers/xml/configuration-1-9-0.xsd" name="wsf_tests" uuid="CA72F5B3-E608-4FA5-8F05-A812441DB961">
|
||||
<target name="tests">
|
||||
<root class="ANY" feature="default_create"/>
|
||||
<file_rule>
|
||||
@@ -7,16 +7,18 @@
|
||||
<exclude>/EIFGENs$</exclude>
|
||||
<exclude>/.svn$</exclude>
|
||||
</file_rule>
|
||||
<option warning="true" full_class_checking="true" void_safety="none" syntax="provisional">
|
||||
<option warning="true" full_class_checking="true" is_attached_by_default="false" void_safety="none" syntax="provisional">
|
||||
</option>
|
||||
<setting name="concurrency" value="thread"/>
|
||||
<library name="base" location="$ISE_LIBRARY\library\base\base.ecf"/>
|
||||
<library name="connector_nino" location="..\..\ewsgi\connectors\nino\nino.ecf" readonly="false"/>
|
||||
<library name="connector_null" location="..\..\ewsgi\connectors\null\null.ecf" readonly="false"/>
|
||||
<library name="dft_nino" location="..\default\nino.ecf"/>
|
||||
<library name="ewsgi" location="..\..\ewsgi\ewsgi.ecf"/>
|
||||
<library name="http_client" location="..\..\..\client\http_client\http_client.ecf"/>
|
||||
<library name="testing" location="$ISE_LIBRARY\library\testing\testing.ecf"/>
|
||||
<library name="thread" location="$ISE_LIBRARY\library\thread\thread.ecf"/>
|
||||
<library name="wsf" location="..\wsf.ecf"/>
|
||||
<library name="wsf" location="..\wsf.ecf" readonly="false"/>
|
||||
<tests name="src" location=".\src\" recursive="true"/>
|
||||
</target>
|
||||
</system>
|
||||
|
||||
Reference in New Issue
Block a user