And*_*rew 5 php apache zend-framework
我正在使用Selenium和PHPUnit测试我的Zend Framework应用程序.我有一个需要打开包含编码URL的URL的测试.
$redirectToLocation = urlencode('/myothercontroller/action'); // %2Fmyothercontroller%2Faction
$this->openAndWait('/controller/action/thenRedirectTo/' . $redirectToLocation);
Run Code Online (Sandbox Code Playgroud)
但是当我运行测试时,浏览器尝试打开解码后的URL:
/controller/action/thenRedirectTo//myothercontroller/action
Run Code Online (Sandbox Code Playgroud)
我应该怎么做才能让selenium打开编码的URL?
更新:实际上......结果是selenium正在做它的工作,但似乎Apache在它到达控制器之前解码URL:
The requested URL /controller/action/thenRedirectTo//myothercontroller/action was not found on this server.
Run Code Online (Sandbox Code Playgroud)
我该如何解决这个问题?
更新:这是关于我遇到的同样问题的完整对话:http://old.nabble.com/URL-Encoding-td18850769.html.他们的解决方法是对网址进行base64编码,但这对我来说还不够好.我可以在短期内使用这个解决方案,但我想知道这个问题的真正原因是什么,所以我可以消除它.
更新:我有一个同事认为Zend Framework路由请求的方式可能存在问题.你认为情况可能如此吗?
有趣的问题。我个人在查询字符串中传递另一个 URL 时从未遇到过任何问题,即 /controller/action/thenRedirectTo?q=%2Fmyothercontroller%2Faction ,但我已经很长时间没有使用 Apache 了,这不完全是你的问题正在尝试做。
一种可能的解决方案是对其进行双 url 编码。
$redirectToLocation = urlencode(urlencode('/myothercontroller/action'));
$this->openAndWait('/controller/action/thenRedirectTo/' . $redirectToLocation);
Run Code Online (Sandbox Code Playgroud)
也许 Apache 只会对它进行一级 url 解码。
| 归档时间: |
|
| 查看次数: |
2697 次 |
| 最近记录: |