From a4d04583787e3bd640444172de3a67ed40692669 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Roland=20H=C3=A4der?= Date: Mon, 2 Jul 2012 19:12:17 +0000 Subject: [PATCH] Fixed proxy support where CONNECT is not allowed --- inc/http-functions.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/inc/http-functions.php b/inc/http-functions.php index 2ea26e6b11..c1518e2ed5 100644 --- a/inc/http-functions.php +++ b/inc/http-functions.php @@ -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 -- 2.39.5