]> git.mxchange.org Git - mailer.git/commitdiff
Fixed proxy support where CONNECT is not allowed
authorRoland Häder <roland@mxchange.org>
Mon, 2 Jul 2012 19:12:17 +0000 (19:12 +0000)
committerRoland Häder <roland@mxchange.org>
Mon, 2 Jul 2012 19:12:17 +0000 (19:12 +0000)
inc/http-functions.php

index 2ea26e6b11729d0ac84a16e14f518b1956a21ebc..c1518e2ed5c9d0c33de79181eee61ed49891685b 100644 (file)
@@ -182,7 +182,7 @@ function sendHeadRequest ($baseUrl, $requestData = array()) {
        $host = extractHostnameFromUrl($baseUrl);
 
        // Generate HEAD request header
-       $request  = 'HEAD ' . trim($getUrl) . ' HTTP/1.1' . getConfig('HTTP_EOL');
+       $request  = 'HEAD ' . (isProxyUsed() === true ? $baseUrl : '') . trim($getUrl) . ' HTTP/1.1' . getConfig('HTTP_EOL');
        $request .= 'Host: ' . $host . getConfig('HTTP_EOL');
        $request .= 'Referer: ' . getUrl() . '/admin.php' . getConfig('HTTP_EOL');
        if (isConfigEntrySet('FULL_VERSION')) {
@@ -221,7 +221,7 @@ function sendGetRequest ($baseUrl, $requestData = array(), $removeHeader = false
        $host = extractHostnameFromUrl($baseUrl);
 
        // Generate GET request header
-       $request  = 'GET ' . trim($getUrl) . ' HTTP/1.1' . getConfig('HTTP_EOL');
+       $request  = 'GET ' . (isProxyUsed() === true ? $baseUrl : '') . trim($getUrl) . ' HTTP/1.1' . getConfig('HTTP_EOL');
        $request .= 'Host: ' . $host . getConfig('HTTP_EOL');
        $request .= 'Referer: ' . getUrl() . '/admin.php' . getConfig('HTTP_EOL');
        if (isConfigEntrySet('FULL_VERSION')) {
@@ -269,7 +269,7 @@ function sendPostRequest ($baseUrl, $requestData, $removeHeader = false) {
        $body = http_build_query($requestData, '', '&');
 
        // Generate POST request header
-       $request  = 'POST ' . trim($baseUrl) . ' HTTP/1.0' . getConfig('HTTP_EOL');
+       $request  = 'POST ' . (isProxyUsed() === true ? $baseUrl : '') . trim($baseUrl) . ' HTTP/1.0' . getConfig('HTTP_EOL');
        $request .= 'Host: ' . $host . getConfig('HTTP_EOL');
        $request .= 'Referer: ' . getUrl() . '/admin.php' . getConfig('HTTP_EOL');
        if (isConfigEntrySet('FULL_VERSION')) {
@@ -480,7 +480,8 @@ function setupProxyTunnel ($host, $proxyHost, $port, $resource) {
 
        // Generate CONNECT request header
        $proxyTunnel  = 'CONNECT ' . $host . ':' . $port . ' HTTP/1.0' . getConfig('HTTP_EOL');
-       $proxyTunnel .= 'Host: ' . $proxyHost . getConfig('HTTP_EOL');
+       $proxyTunnel .= 'Host: ' . $host . getConfig('HTTP_EOL');
+       $proxyTunnel .= 'Proxy-Connection: Keep-Alive' . getConfig('HTTP_EOL');
 
        // Use login data to proxy? (username at least!)
        if (getProxyUsername() != '') {
@@ -505,7 +506,7 @@ function setupProxyTunnel ($host, $proxyHost, $port, $resource) {
        // Read the first line
        $resp = trim(fgets($resource, 10240));
        $respArray = explode(' ', $resp);
-       if ((strtolower($respArray[0]) !== 'http/1.0') || ($respArray[1] != '200')) {
+       if (((strtolower($respArray[0]) !== 'http/1.0') && (strtolower($respArray[0]) !== 'http/1.1')) || ($respArray[1] != '200')) {
                // Invalid response!
                return $response;
        } // END - if