Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormattab <matthieu.aubry@gmail.com>2013-07-23 11:52:15 +0400
committermattab <matthieu.aubry@gmail.com>2013-07-23 11:52:15 +0400
commit5104d94f3b2250f766b9c520e2da8da9b4cab2e9 (patch)
tree5f30daf7bc14373fb1bbd0504ce11a771dafc02f /core/Http.php
parentae4b1f4e38077b174e4df5b7d4513d63fe026a24 (diff)
Refs #4059 Work in progress: Conversion to use Namespaces of dozen more classes
Removed many Piwik_ functions, in Piwik 2 it is best practise to use the methods calls instead Todo: finish converting core/ classes + convert plugins/ classes to use \Piwik\Plugin namespace + fix build + Merge master
Diffstat (limited to 'core/Http.php')
-rw-r--r--core/Http.php58
1 files changed, 31 insertions, 27 deletions
diff --git a/core/Http.php b/core/Http.php
index de30bf3b2f..df00fce2a1 100644
--- a/core/Http.php
+++ b/core/Http.php
@@ -8,9 +8,14 @@
* @category Piwik
* @package Piwik
*/
+namespace Piwik;
+
+use Exception;
use Piwik\Config;
use Piwik\Piwik;
use Piwik\Common;
+use Piwik\IP;
+use Piwik\Version;
/**
* Server-side http client to retrieve content from remote servers, and optionally save to a local file.
@@ -18,7 +23,7 @@ use Piwik\Common;
*
* @package Piwik
*/
-class Piwik_Http
+class Http
{
/**
* Get "best" available transport method for sendHttpRequest() calls.
@@ -55,16 +60,16 @@ class Piwik_Http
* If no $destinationPath is specified, the trimmed response (without header) is returned as a string.
* If a $destinationPath is specified, the response (without header) is saved to a file.
*
- * @param string $aUrl
- * @param int $timeout
- * @param string $userAgent
- * @param string $destinationPath
- * @param int $followDepth
- * @param bool $acceptLanguage
+ * @param string $aUrl
+ * @param int $timeout
+ * @param string $userAgent
+ * @param string $destinationPath
+ * @param int $followDepth
+ * @param bool $acceptLanguage
* @param array|bool $byteRange For Range: header. Should be two element array of bytes, eg, array(0, 1024)
* Doesn't work w/ fopen method.
- * @param bool $getExtendedInfo True to return status code, headers & response, false if just response.
- * @param string $httpMethod The HTTP method to use. Defaults to 'GET'.
+ * @param bool $getExtendedInfo True to return status code, headers & response, false if just response.
+ * @param string $httpMethod The HTTP method to use. Defaults to 'GET'.
*
* @throws Exception
* @return bool true (or string) on success; false on HTTP response error code (1xx or 4xx)
@@ -88,19 +93,19 @@ class Piwik_Http
/**
* Sends http request using the specified transport method
*
- * @param string $method
- * @param string $aUrl
- * @param int $timeout
- * @param string $userAgent
- * @param string $destinationPath
- * @param resource $file
- * @param int $followDepth
+ * @param string $method
+ * @param string $aUrl
+ * @param int $timeout
+ * @param string $userAgent
+ * @param string $destinationPath
+ * @param resource $file
+ * @param int $followDepth
* @param bool|string $acceptLanguage Accept-language header
- * @param bool $acceptInvalidSslCertificate Only used with $method == 'curl'. If set to true (NOT recommended!) the SSL certificate will not be checked
- * @param array|bool $byteRange For Range: header. Should be two element array of bytes, eg, array(0, 1024)
+ * @param bool $acceptInvalidSslCertificate Only used with $method == 'curl'. If set to true (NOT recommended!) the SSL certificate will not be checked
+ * @param array|bool $byteRange For Range: header. Should be two element array of bytes, eg, array(0, 1024)
* Doesn't work w/ fopen method.
- * @param bool $getExtendedInfo True to return status code, headers & response, false if just response.
- * @param string $httpMethod The HTTP method to use. Defaults to 'GET'.
+ * @param bool $getExtendedInfo True to return status code, headers & response, false if just response.
+ * @param string $httpMethod The HTTP method to use. Defaults to 'GET'.
*
* @throws Exception
* @return bool true (or string/array) on success; false on HTTP response error code (1xx or 4xx)
@@ -130,7 +135,7 @@ class Piwik_Http
// Piwik services behave like a proxy, so we should act like one.
$xff = 'X-Forwarded-For: '
. (isset($_SERVER['HTTP_X_FORWARDED_FOR']) && !empty($_SERVER['HTTP_X_FORWARDED_FOR']) ? $_SERVER['HTTP_X_FORWARDED_FOR'] . ',' : '')
- . Piwik_IP::getIpFromHeader();
+ . IP::getIpFromHeader();
if (empty($userAgent)) {
$userAgent = self::getUserAgent();
@@ -138,7 +143,7 @@ class Piwik_Http
$via = 'Via: '
. (isset($_SERVER['HTTP_VIA']) && !empty($_SERVER['HTTP_VIA']) ? $_SERVER['HTTP_VIA'] . ', ' : '')
- . Piwik_Version::VERSION . ' '
+ . Version::VERSION . ' '
. ($userAgent ? " ($userAgent)" : '');
// range header
@@ -450,7 +455,6 @@ class Piwik_Http
@curl_setopt_array($ch, $curl_options);
self::configCurlCertificate($ch);
-
/*
* as of php 5.2.0, CURLOPT_FOLLOWLOCATION can't be set if
* in safe_mode or open_basedir is set
@@ -540,7 +544,7 @@ class Piwik_Http
*
* @param string $url The url to download from.
* @param string $outputPath The path to the file to save/append to.
- * @param bool $isContinuation True if this is the continuation of a download,
+ * @param bool $isContinuation True if this is the continuation of a download,
* or if we're starting a fresh one.
*
* @throws Exception
@@ -560,7 +564,7 @@ class Piwik_Http
// if we're starting a download, get the expected file size & save as an option
$downloadOption = $outputPath . '_expectedDownloadSize';
if (!$isContinuation) {
- $expectedFileSizeResult = Piwik_Http::sendHttpRequest(
+ $expectedFileSizeResult = Http::sendHttpRequest(
$url,
$timeout = 300,
$userAgent = null,
@@ -601,7 +605,7 @@ class Piwik_Http
}
// download a chunk of the file
- $result = Piwik_Http::sendHttpRequest(
+ $result = Http::sendHttpRequest(
$url,
$timeout = 300,
$userAgent = null,
@@ -650,7 +654,7 @@ class Piwik_Http
{
return !empty($_SERVER['HTTP_USER_AGENT'])
? $_SERVER['HTTP_USER_AGENT']
- : 'Piwik/' . Piwik_Version::VERSION;
+ : 'Piwik/' . Version::VERSION;
}
/**