From 67f6ad6b9470dc8cc4396298d366e5df008fe69d Mon Sep 17 00:00:00 2001 From: Alex Date: Tue, 29 Apr 2014 22:31:58 +0200 Subject: Fix https proxy authentication, the header was missing a colon so that the auth info was not working. --- inc/HTTPClient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/HTTPClient.php') diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php index 53f3c9a78..f8b836753 100644 --- a/inc/HTTPClient.php +++ b/inc/HTTPClient.php @@ -552,7 +552,7 @@ class HTTPClient { $request = "CONNECT {$requestinfo['host']}:{$requestinfo['port']} HTTP/1.0".HTTP_NL; $request .= "Host: {$requestinfo['host']}".HTTP_NL; if($this->proxy_user) { - $request .= 'Proxy-Authorization Basic '.base64_encode($this->proxy_user.':'.$this->proxy_pass).HTTP_NL; + $request .= 'Proxy-Authorization: Basic '.base64_encode($this->proxy_user.':'.$this->proxy_pass).HTTP_NL; } $request .= HTTP_NL; -- cgit v1.2.3 From 5171287a24c73f32e4765bdb998c23febb131467 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Mon, 19 May 2014 21:37:20 +0200 Subject: fixed parameter type --- inc/HTTPClient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/HTTPClient.php') diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php index f8b836753..b5956a7f8 100644 --- a/inc/HTTPClient.php +++ b/inc/HTTPClient.php @@ -343,7 +343,7 @@ class HTTPClient { try { //set non-blocking - stream_set_blocking($socket, false); + stream_set_blocking($socket, 0); // build request $request = "$method $request_url HTTP/".$this->http.HTTP_NL; -- cgit v1.2.3 From 6fc4ea2c9a414260900dbe10478d307dc3e952c0 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Sun, 25 May 2014 12:16:22 +0200 Subject: removed some unused lines in HTTPClient --- inc/HTTPClient.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'inc/HTTPClient.php') diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php index b5956a7f8..4352bcb97 100644 --- a/inc/HTTPClient.php +++ b/inc/HTTPClient.php @@ -61,6 +61,9 @@ class DokuHTTPClient extends HTTPClient { } +/** + * Class HTTPClientException + */ class HTTPClientException extends Exception { } /** @@ -249,7 +252,6 @@ class HTTPClient { if (empty($port)) $port = 8080; }else{ $request_url = $path; - $server = $server; if (!isset($port)) $port = ($uri['scheme'] == 'https') ? 443 : 80; } @@ -280,7 +282,6 @@ class HTTPClient { } } $headers['Content-Length'] = strlen($data); - $rmethod = 'POST'; }elseif($method == 'GET'){ $data = ''; //no data allowed on GET requests } @@ -458,7 +459,7 @@ class HTTPClient { if ($chunk_size > 0) { $r_body .= $this->_readData($socket, $chunk_size, 'chunk'); - $byte = $this->_readData($socket, 2, 'chunk'); // read trailing \r\n + $this->_readData($socket, 2, 'chunk'); // read trailing \r\n } } while ($chunk_size && !$abort); }elseif(isset($this->resp_headers['content-length']) && !isset($this->resp_headers['transfer-encoding'])){ @@ -480,7 +481,6 @@ class HTTPClient { $r_body = $this->_readData($socket, $this->max_bodysize, 'response (content-length limited)', true); }else{ // read entire socket - $r_size = 0; while (!feof($socket)) { $r_body .= $this->_readData($socket, 4096, 'response (unlimited)', true); } @@ -509,7 +509,6 @@ class HTTPClient { if (!$this->keep_alive || (isset($this->resp_headers['connection']) && $this->resp_headers['connection'] == 'Close')) { // close socket - $status = socket_get_status($socket); fclose($socket); unset(self::$connections[$connectionId]); } -- cgit v1.2.3 From 2314059e5b8fc84fcdc52e4506ec907d0c792f50 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Fri, 4 Jul 2014 17:16:09 +0200 Subject: allow for easier HTTPClient debugging Sometimes users report bugs or problems releated to HTTP connections made by our HTTPCient (eg. in the extension manager or XMLRPC). Debugging those problems previously required modifying some sources to enable the debugging output of the HTTPClient. This patch adds a way to enable the debugging via a request parameter. Since HTTP requests are often done only *after* some button was clicked, the parameter is also looked for in the referrer of a request. Debugging output is enabled through the existence of the parameter 'httpdebug' and is directly printed to the screen. Debugging HTTP only works when allowdebug is enabled. --- inc/HTTPClient.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'inc/HTTPClient.php') diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php index 4352bcb97..6ac67f159 100644 --- a/inc/HTTPClient.php +++ b/inc/HTTPClient.php @@ -35,6 +35,19 @@ class DokuHTTPClient extends HTTPClient { $this->proxy_pass = conf_decodeString($conf['proxy']['pass']); $this->proxy_ssl = $conf['proxy']['ssl']; $this->proxy_except = $conf['proxy']['except']; + + // allow enabling debugging via URL parameter (if debugging allowed) + if($conf['allowdebug']) { + if( + isset($_REQUEST['httpdebug']) || + ( + isset($_SERVER['HTTP_REFERER']) && + strpos($_SERVER['HTTP_REFERER'], 'httpdebug') !== false + ) + ) { + $this->debug = true; + } + } } -- cgit v1.2.3 From 5aca1d54db0f056fec97a36487b09ebf0a864ed3 Mon Sep 17 00:00:00 2001 From: Andreas Gohr Date: Mon, 28 Jul 2014 19:01:42 +0200 Subject: HTTPClient don't omit headers with value 0 --- inc/HTTPClient.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'inc/HTTPClient.php') diff --git a/inc/HTTPClient.php b/inc/HTTPClient.php index 6ac67f159..cd4c7c4c5 100644 --- a/inc/HTTPClient.php +++ b/inc/HTTPClient.php @@ -808,7 +808,7 @@ class HTTPClient { function _buildHeaders($headers){ $string = ''; foreach($headers as $key => $value){ - if(empty($value)) continue; + if($value === '') continue; $string .= $key.': '.$value.HTTP_NL; } return $string; -- cgit v1.2.3