Explorar o código

Fix ZF-4491: Support the new Microsoft URL Rewrite Module for IIS 7.0.

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@24842 44c647ce-9c0f-0410-b52a-842ac1e357ba
rob %!s(int64=13) %!d(string=hai) anos
pai
achega
80c1c28336

+ 5 - 1
library/Zend/Controller/Request/Http.php

@@ -390,7 +390,11 @@ class Zend_Controller_Request_Http extends Zend_Controller_Request_Abstract
     public function setRequestUri($requestUri = null)
     {
         if ($requestUri === null) {
-            if (isset($_SERVER['HTTP_X_REWRITE_URL'])) { // check this first so IIS will catch
+            if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) { 
+                // IIS with Microsoft Rewrite Module
+                $requestUri = $_SERVER['HTTP_X_ORIGINAL_URL'];
+            } elseif (isset($_SERVER['HTTP_X_REWRITE_URL'])) { 
+                // IIS with ISAPI_Rewrite
                 $requestUri = $_SERVER['HTTP_X_REWRITE_URL'];
             } elseif (
                 // IIS7 with URL Rewrite: make sure we get the unencoded url (double slash problem)

+ 3 - 1
library/Zend/Feed/Pubsubhubbub/CallbackAbstract.php

@@ -219,7 +219,9 @@ abstract class Zend_Feed_Pubsubhubbub_CallbackAbstract
     protected function _detectCallbackUrl()
     {
         $callbackUrl = '';
-        if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
+        if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) {
+            $callbackUrl = $_SERVER['HTTP_X_ORIGINAL_URL'];
+        } elseif (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
             $callbackUrl = $_SERVER['HTTP_X_REWRITE_URL'];
         } elseif (isset($_SERVER['REQUEST_URI'])) {
             $callbackUrl = $_SERVER['REQUEST_URI'];

+ 5 - 1
library/Zend/OpenId.php

@@ -124,7 +124,11 @@ class Zend_OpenId
         }
 
         $url .= $port;
-        if (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
+        if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) { 
+            // IIS with Microsoft Rewrite Module
+            $url .= $_SERVER['HTTP_X_ORIGINAL_URL'];
+        } elseif (isset($_SERVER['HTTP_X_REWRITE_URL'])) {
+            // IIS with ISAPI_Rewrite 
             $url .= $_SERVER['HTTP_X_REWRITE_URL'];
         } elseif (isset($_SERVER['REQUEST_URI'])) {
             $query = strpos($_SERVER['REQUEST_URI'], '?');

+ 3 - 1
library/Zend/Soap/AutoDiscover.php

@@ -268,7 +268,9 @@ class Zend_Soap_AutoDiscover implements Zend_Server_Interface
      */
     protected function getRequestUriWithoutParameters()
     {
-        if (isset($_SERVER['HTTP_X_REWRITE_URL'])) { // check this first so IIS will catch
+        if (isset($_SERVER['HTTP_X_ORIGINAL_URL'])) { // IIS with Microsoft Rewrite Module
+            $requestUri = $_SERVER['HTTP_X_ORIGINAL_URL'];
+        } elseif (isset($_SERVER['HTTP_X_REWRITE_URL'])) { // check this first so IIS will catch
             $requestUri = $_SERVER['HTTP_X_REWRITE_URL'];
         } elseif (isset($_SERVER['REQUEST_URI'])) {
             $requestUri = $_SERVER['REQUEST_URI'];

+ 15 - 0
tests/Zend/Controller/Request/HttpTest.php

@@ -549,6 +549,21 @@ class Zend_Controller_Request_HttpTest extends PHPUnit_Framework_TestCase
         $this->assertEquals('/index.php', $request->getBaseUrl());
     }
 
+    public function testSetBaseUrlAutoDiscoveryUsingXOriginalUrl()
+    {
+        unset($_SERVER['REQUEST_URI']);
+        $_SERVER['HTTP_X_ORIGINAL_URL'] = '/index.php/news/3?var1=val1&var2=val2';
+        $_SERVER['PHP_SELF']           = '/index.php/news/3';
+        $_SERVER['SCRIPT_FILENAME']    = '/var/web/html/index.php';
+        $_GET = array(
+            'var1' => 'val1',
+            'var2' => 'val2'
+        );
+        $request = new Zend_Controller_Request_Http();
+
+        $this->assertEquals('/index.php', $request->getBaseUrl());
+    }
+
     public function testSetBaseUrlAutoDiscoveryUsingOrigPathInfo()
     {
         unset($_SERVER['REQUEST_URI']);

+ 8 - 1
tests/Zend/Soap/AutoDiscoverTest.php

@@ -739,12 +739,19 @@ class Zend_Soap_AutoDiscoverTest extends PHPUnit_Framework_TestCase
         $this->assertNotContains("?wsdl", $uri);
         $this->assertEquals("http://localhost/my_script.php", $uri);
 
-        // IIS
+        // IIS with ISAPI_Rewrite
         $_SERVER = array('HTTP_X_REWRITE_URL' => '/my_script.php?wsdl', 'SERVER_NAME' => 'localhost');
         $server = new Zend_Soap_AutoDiscover();
         $uri = $server->getUri()->getUri();
         $this->assertNotContains("?wsdl", $uri);
         $this->assertEquals("http://localhost/my_script.php", $uri);
+
+        // IIS with Microsoft Rewrite Module
+        $_SERVER = array('HTTP_X_ORIGINAL_URL' => '/my_script.php?wsdl', 'SERVER_NAME' => 'localhost');
+        $server = new Zend_Soap_AutoDiscover();
+        $uri = $server->getUri()->getUri();
+        $this->assertNotContains("?wsdl", $uri);
+        $this->assertEquals("http://localhost/my_script.php", $uri);
     }
 
     /**