Fixup HTTPRequest.class.php
[GitHub/WoltLab/WCF.git] / wcfsetup / install / files / lib / util / HTTPRequest.class.php
index d8d26687cc5e0eeca6598db9d4fb6cfc2ab880e6..5853c0b7f35059bf5a3fe4c3afbfcb7a64e49a9b 100644 (file)
@@ -219,23 +219,27 @@ final class HTTPRequest {
         */
        private function setURL($url) {
                $parsedUrl = $originUrl = parse_url($url);
-               if (PROXY_SERVER_HTTP) {
-                       $parsedUrl = parse_url(PROXY_SERVER_HTTP);
+               
+               $this->originUseSSL = $originUrl['scheme'] === 'https';
+               $this->originHost = $originUrl['host'];
+               $this->originPort = isset($originUrl['port']) ? $originUrl['port'] : ($this->originUseSSL ? 443 : 80);
+               
+               if (PROXY_SERVER_HTTP && !$this->originUseSSL) {
                        $this->path = $url;
                }
                else {
                        $this->path = isset($parsedUrl['path']) ? $parsedUrl['path'] : '/';
                }
                
+               if (PROXY_SERVER_HTTP) {
+                       $parsedUrl = parse_url(PROXY_SERVER_HTTP);
+               }
+               
                $this->useSSL = $parsedUrl['scheme'] === 'https';
                $this->host = $parsedUrl['host'];
                $this->port = isset($parsedUrl['port']) ? $parsedUrl['port'] : ($this->useSSL ? 443 : 80);
                $this->query = isset($parsedUrl['query']) ? $parsedUrl['query'] : '';
                
-               $this->originUseSSL = $originUrl['scheme'] === 'https';
-               $this->originHost = $originUrl['host'];
-               $this->originPort = isset($originUrl['port']) ? $originUrl['port'] : ($this->originUseSSL ? 443 : 80);
-               
                // update the 'Host:' header if URL has changed
                if ($this->url != $url) {
                        $this->addHeader('host', $this->originHost.($this->originPort != ($this->originUseSSL ? 443 : 80) ? ':'.$this->originPort : ''));