aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorVirtualTam <virtualtam@flibidi.net>2018-12-03 00:34:53 +0100
committerVirtualTam <virtualtam@flibidi.net>2019-01-12 22:47:48 +0100
commit51753e403fa69c0ce124ede27d300477e3e799ca (patch)
tree0afe2a84598648b49cc53bb3e8640569ac370240
parentfb1b182fbf0ee5afed586f77eec84d7a906831ef (diff)
downloadShaarli-51753e403fa69c0ce124ede27d300477e3e799ca.tar.gz
Shaarli-51753e403fa69c0ce124ede27d300477e3e799ca.tar.zst
Shaarli-51753e403fa69c0ce124ede27d300477e3e799ca.zip
namespacing: move HTTP utilities along \Shaarli\Http\ classes
Signed-off-by: VirtualTam <virtualtam@flibidi.net>
-rw-r--r--application/http/HttpUtils.php (renamed from application/HttpUtils.php)2
-rw-r--r--application/http/Url.php2
-rw-r--r--application/http/UrlUtils.php (renamed from application/Url.php)4
-rw-r--r--index.php4
-rw-r--r--tests/http/HttpUtils/ClientIpIdTest.php (renamed from tests/HttpUtils/ClientIpIdTest.php)6
-rw-r--r--tests/http/HttpUtils/GetHttpUrlTest.php (renamed from tests/HttpUtils/GetHttpUrlTest.php)10
-rw-r--r--tests/http/HttpUtils/GetIpAdressFromProxyTest.php (renamed from tests/HttpUtils/GetIpAdressFromProxyTest.php)6
-rw-r--r--tests/http/HttpUtils/IndexUrlTest.php (renamed from tests/HttpUtils/IndexUrlTest.php)6
-rw-r--r--tests/http/HttpUtils/IsHttpsTest.php (renamed from tests/HttpUtils/IsHttpsTest.php)5
-rw-r--r--tests/http/HttpUtils/PageUrlTest.php (renamed from tests/HttpUtils/PageUrlTest.php)6
-rw-r--r--tests/http/HttpUtils/ServerUrlTest.php (renamed from tests/HttpUtils/ServerUrlTest.php)6
-rw-r--r--tests/http/UrlTest.php2
-rw-r--r--tests/http/UrlUtils/CleanupUrlTest.php (renamed from tests/Url/CleanupUrlTest.php)6
-rw-r--r--tests/http/UrlUtils/GetUrlSchemeTest.php (renamed from tests/Url/GetUrlSchemeTest.php)10
-rw-r--r--tests/http/UrlUtils/UnparseUrlTest.php (renamed from tests/Url/UnparseUrlTest.php)8
-rw-r--r--tests/http/UrlUtils/WhitelistProtocolsTest.php (renamed from tests/Url/WhitelistProtocolsTest.php)8
16 files changed, 56 insertions, 35 deletions
diff --git a/application/HttpUtils.php b/application/http/HttpUtils.php
index 51af5d0d..2ea9195d 100644
--- a/application/HttpUtils.php
+++ b/application/http/HttpUtils.php
@@ -41,7 +41,7 @@ function get_http_response($url, $timeout = 30, $maxBytes = 4194304, $curlWriteF
41 $cleanUrl = $urlObj->idnToAscii(); 41 $cleanUrl = $urlObj->idnToAscii();
42 42
43 if (!filter_var($cleanUrl, FILTER_VALIDATE_URL) || !$urlObj->isHttp()) { 43 if (!filter_var($cleanUrl, FILTER_VALIDATE_URL) || !$urlObj->isHttp()) {
44 return array(array(0 => 'Invalid HTTP Url'), false); 44 return array(array(0 => 'Invalid HTTP UrlUtils'), false);
45 } 45 }
46 46
47 $userAgent = 47 $userAgent =
diff --git a/application/http/Url.php b/application/http/Url.php
index 260231c6..90444a2f 100644
--- a/application/http/Url.php
+++ b/application/http/Url.php
@@ -206,7 +206,7 @@ class Url
206 } 206 }
207 207
208 /** 208 /**
209 * Test if the Url is an HTTP one. 209 * Test if the UrlUtils is an HTTP one.
210 * 210 *
211 * @return true is HTTP, false otherwise. 211 * @return true is HTTP, false otherwise.
212 */ 212 */
diff --git a/application/Url.php b/application/http/UrlUtils.php
index 81f72fb0..4bc84b82 100644
--- a/application/Url.php
+++ b/application/http/UrlUtils.php
@@ -28,7 +28,7 @@ function unparse_url($parsedUrl)
28/** 28/**
29 * Removes undesired query parameters and fragments 29 * Removes undesired query parameters and fragments
30 * 30 *
31 * @param string url Url to be cleaned 31 * @param string url UrlUtils to be cleaned
32 * 32 *
33 * @return string the string representation of this URL after cleanup 33 * @return string the string representation of this URL after cleanup
34 */ 34 */
@@ -41,7 +41,7 @@ function cleanup_url($url)
41/** 41/**
42 * Get URL scheme. 42 * Get URL scheme.
43 * 43 *
44 * @param string url Url for which the scheme is requested 44 * @param string url UrlUtils for which the scheme is requested
45 * 45 *
46 * @return mixed the URL scheme or false if none is provided. 46 * @return mixed the URL scheme or false if none is provided.
47 */ 47 */
diff --git a/index.php b/index.php
index 6d1ae3fc..66fe30f1 100644
--- a/index.php
+++ b/index.php
@@ -59,16 +59,16 @@ require_once __DIR__ . '/vendor/autoload.php';
59require_once 'application/ApplicationUtils.php'; 59require_once 'application/ApplicationUtils.php';
60require_once 'application/config/ConfigPlugin.php'; 60require_once 'application/config/ConfigPlugin.php';
61require_once 'application/feed/Cache.php'; 61require_once 'application/feed/Cache.php';
62require_once 'application/http/HttpUtils.php';
63require_once 'application/http/UrlUtils.php';
62require_once 'application/FileUtils.php'; 64require_once 'application/FileUtils.php';
63require_once 'application/History.php'; 65require_once 'application/History.php';
64require_once 'application/HttpUtils.php';
65require_once 'application/LinkDB.php'; 66require_once 'application/LinkDB.php';
66require_once 'application/LinkFilter.php'; 67require_once 'application/LinkFilter.php';
67require_once 'application/LinkUtils.php'; 68require_once 'application/LinkUtils.php';
68require_once 'application/NetscapeBookmarkUtils.php'; 69require_once 'application/NetscapeBookmarkUtils.php';
69require_once 'application/PageBuilder.php'; 70require_once 'application/PageBuilder.php';
70require_once 'application/TimeZone.php'; 71require_once 'application/TimeZone.php';
71require_once 'application/Url.php';
72require_once 'application/Utils.php'; 72require_once 'application/Utils.php';
73require_once 'application/PluginManager.php'; 73require_once 'application/PluginManager.php';
74require_once 'application/Router.php'; 74require_once 'application/Router.php';
diff --git a/tests/HttpUtils/ClientIpIdTest.php b/tests/http/HttpUtils/ClientIpIdTest.php
index c15ac5cc..982e57e0 100644
--- a/tests/HttpUtils/ClientIpIdTest.php
+++ b/tests/http/HttpUtils/ClientIpIdTest.php
@@ -3,12 +3,14 @@
3 * HttpUtils' tests 3 * HttpUtils' tests
4 */ 4 */
5 5
6require_once 'application/HttpUtils.php'; 6namespace Shaarli\Http;
7
8require_once 'application/http/HttpUtils.php';
7 9
8/** 10/**
9 * Unitary tests for client_ip_id() 11 * Unitary tests for client_ip_id()
10 */ 12 */
11class ClientIpIdTest extends PHPUnit_Framework_TestCase 13class ClientIpIdTest extends \PHPUnit\Framework\TestCase
12{ 14{
13 /** 15 /**
14 * Get a remote client ID based on its IP 16 * Get a remote client ID based on its IP
diff --git a/tests/HttpUtils/GetHttpUrlTest.php b/tests/http/HttpUtils/GetHttpUrlTest.php
index ea53de5f..3dc5bc9b 100644
--- a/tests/HttpUtils/GetHttpUrlTest.php
+++ b/tests/http/HttpUtils/GetHttpUrlTest.php
@@ -3,12 +3,14 @@
3 * HttpUtils' tests 3 * HttpUtils' tests
4 */ 4 */
5 5
6require_once 'application/HttpUtils.php'; 6namespace Shaarli\Http;
7
8require_once 'application/http/HttpUtils.php';
7 9
8/** 10/**
9 * Unitary tests for get_http_response() 11 * Unitary tests for get_http_response()
10 */ 12 */
11class GetHttpUrlTest extends PHPUnit_Framework_TestCase 13class GetHttpUrlTest extends \PHPUnit\Framework\TestCase
12{ 14{
13 /** 15 /**
14 * Get an invalid local URL 16 * Get an invalid local URL
@@ -17,12 +19,12 @@ class GetHttpUrlTest extends PHPUnit_Framework_TestCase
17 { 19 {
18 // Local 20 // Local
19 list($headers, $content) = get_http_response('/non/existent', 1); 21 list($headers, $content) = get_http_response('/non/existent', 1);
20 $this->assertEquals('Invalid HTTP Url', $headers[0]); 22 $this->assertEquals('Invalid HTTP UrlUtils', $headers[0]);
21 $this->assertFalse($content); 23 $this->assertFalse($content);
22 24
23 // Non HTTP 25 // Non HTTP
24 list($headers, $content) = get_http_response('ftp://save.tld/mysave', 1); 26 list($headers, $content) = get_http_response('ftp://save.tld/mysave', 1);
25 $this->assertEquals('Invalid HTTP Url', $headers[0]); 27 $this->assertEquals('Invalid HTTP UrlUtils', $headers[0]);
26 $this->assertFalse($content); 28 $this->assertFalse($content);
27 } 29 }
28 30
diff --git a/tests/HttpUtils/GetIpAdressFromProxyTest.php b/tests/http/HttpUtils/GetIpAdressFromProxyTest.php
index 7af5bd9d..fe3a639e 100644
--- a/tests/HttpUtils/GetIpAdressFromProxyTest.php
+++ b/tests/http/HttpUtils/GetIpAdressFromProxyTest.php
@@ -1,11 +1,13 @@
1<?php 1<?php
2 2
3require_once 'application/HttpUtils.php'; 3namespace Shaarli\Http;
4
5require_once 'application/http/HttpUtils.php';
4 6
5/** 7/**
6 * Unitary tests for getIpAddressFromProxy() 8 * Unitary tests for getIpAddressFromProxy()
7 */ 9 */
8class GetIpAdressFromProxyTest extends PHPUnit_Framework_TestCase 10class GetIpAdressFromProxyTest extends \PHPUnit\Framework\TestCase
9{ 11{
10 12
11 /** 13 /**
diff --git a/tests/HttpUtils/IndexUrlTest.php b/tests/http/HttpUtils/IndexUrlTest.php
index 337dcab0..bcbe59cb 100644
--- a/tests/HttpUtils/IndexUrlTest.php
+++ b/tests/http/HttpUtils/IndexUrlTest.php
@@ -3,12 +3,14 @@
3 * HttpUtils' tests 3 * HttpUtils' tests
4 */ 4 */
5 5
6require_once 'application/HttpUtils.php'; 6namespace Shaarli\Http;
7
8require_once 'application/http/HttpUtils.php';
7 9
8/** 10/**
9 * Unitary tests for index_url() 11 * Unitary tests for index_url()
10 */ 12 */
11class IndexUrlTest extends PHPUnit_Framework_TestCase 13class IndexUrlTest extends \PHPUnit\Framework\TestCase
12{ 14{
13 /** 15 /**
14 * If on the main page, remove "index.php" from the URL resource 16 * If on the main page, remove "index.php" from the URL resource
diff --git a/tests/HttpUtils/IsHttpsTest.php b/tests/http/HttpUtils/IsHttpsTest.php
index 097f2bcf..348956c6 100644
--- a/tests/HttpUtils/IsHttpsTest.php
+++ b/tests/http/HttpUtils/IsHttpsTest.php
@@ -1,12 +1,15 @@
1<?php 1<?php
2 2
3namespace Shaarli\Http;
4
5require_once 'application/http/HttpUtils.php';
3 6
4/** 7/**
5 * Class IsHttpsTest 8 * Class IsHttpsTest
6 * 9 *
7 * Test class for is_https() function. 10 * Test class for is_https() function.
8 */ 11 */
9class IsHttpsTest extends PHPUnit_Framework_TestCase 12class IsHttpsTest extends \PHPUnit\Framework\TestCase
10{ 13{
11 14
12 /** 15 /**
diff --git a/tests/HttpUtils/PageUrlTest.php b/tests/http/HttpUtils/PageUrlTest.php
index 4dbbe9cf..f1991716 100644
--- a/tests/HttpUtils/PageUrlTest.php
+++ b/tests/http/HttpUtils/PageUrlTest.php
@@ -3,12 +3,14 @@
3 * HttpUtils' tests 3 * HttpUtils' tests
4 */ 4 */
5 5
6require_once 'application/HttpUtils.php'; 6namespace Shaarli\Http;
7
8require_once 'application/http/HttpUtils.php';
7 9
8/** 10/**
9 * Unitary tests for page_url() 11 * Unitary tests for page_url()
10 */ 12 */
11class PageUrlTest extends PHPUnit_Framework_TestCase 13class PageUrlTest extends \PHPUnit\Framework\TestCase
12{ 14{
13 /** 15 /**
14 * If on the main page, remove "index.php" from the URL resource 16 * If on the main page, remove "index.php" from the URL resource
diff --git a/tests/HttpUtils/ServerUrlTest.php b/tests/http/HttpUtils/ServerUrlTest.php
index 324b827a..9caf1049 100644
--- a/tests/HttpUtils/ServerUrlTest.php
+++ b/tests/http/HttpUtils/ServerUrlTest.php
@@ -3,12 +3,14 @@
3 * HttpUtils' tests 3 * HttpUtils' tests
4 */ 4 */
5 5
6require_once 'application/HttpUtils.php'; 6namespace Shaarli\Http;
7
8require_once 'application/http/HttpUtils.php';
7 9
8/** 10/**
9 * Unitary tests for server_url() 11 * Unitary tests for server_url()
10 */ 12 */
11class ServerUrlTest extends PHPUnit_Framework_TestCase 13class ServerUrlTest extends \PHPUnit\Framework\TestCase
12{ 14{
13 /** 15 /**
14 * Detect if the server uses SSL 16 * Detect if the server uses SSL
diff --git a/tests/http/UrlTest.php b/tests/http/UrlTest.php
index 011b416d..342b78a4 100644
--- a/tests/http/UrlTest.php
+++ b/tests/http/UrlTest.php
@@ -1,6 +1,6 @@
1<?php 1<?php
2/** 2/**
3 * Url's tests 3 * UrlUtils's tests
4 */ 4 */
5 5
6namespace Shaarli\Http; 6namespace Shaarli\Http;
diff --git a/tests/Url/CleanupUrlTest.php b/tests/http/UrlUtils/CleanupUrlTest.php
index 24791948..6c4d124b 100644
--- a/tests/Url/CleanupUrlTest.php
+++ b/tests/http/UrlUtils/CleanupUrlTest.php
@@ -3,9 +3,11 @@
3 * Unitary tests for cleanup_url() 3 * Unitary tests for cleanup_url()
4 */ 4 */
5 5
6require_once 'application/Url.php'; 6namespace Shaarli\Http;
7 7
8class CleanupUrlTest extends PHPUnit_Framework_TestCase 8require_once 'application/http/UrlUtils.php';
9
10class CleanupUrlTest extends \PHPUnit\Framework\TestCase
9{ 11{
10 /** 12 /**
11 * @var string reference URL 13 * @var string reference URL
diff --git a/tests/Url/GetUrlSchemeTest.php b/tests/http/UrlUtils/GetUrlSchemeTest.php
index 18b932d6..2b97f7be 100644
--- a/tests/Url/GetUrlSchemeTest.php
+++ b/tests/http/UrlUtils/GetUrlSchemeTest.php
@@ -3,12 +3,14 @@
3 * Unitary tests for get_url_scheme() 3 * Unitary tests for get_url_scheme()
4 */ 4 */
5 5
6require_once 'application/Url.php'; 6namespace Shaarli\Http;
7 7
8class GetUrlSchemeTest extends PHPUnit_Framework_TestCase 8require_once 'application/http/UrlUtils.php';
9
10class GetUrlSchemeTest extends \PHPUnit\Framework\TestCase
9{ 11{
10 /** 12 /**
11 * Get empty scheme string for empty Url 13 * Get empty scheme string for empty UrlUtils
12 */ 14 */
13 public function testGetUrlSchemeEmpty() 15 public function testGetUrlSchemeEmpty()
14 { 16 {
@@ -16,7 +18,7 @@ class GetUrlSchemeTest extends PHPUnit_Framework_TestCase
16 } 18 }
17 19
18 /** 20 /**
19 * Get normal scheme of Url 21 * Get normal scheme of UrlUtils
20 */ 22 */
21 public function testGetUrlScheme() 23 public function testGetUrlScheme()
22 { 24 {
diff --git a/tests/Url/UnparseUrlTest.php b/tests/http/UrlUtils/UnparseUrlTest.php
index e314b484..040d8c54 100644
--- a/tests/Url/UnparseUrlTest.php
+++ b/tests/http/UrlUtils/UnparseUrlTest.php
@@ -1,14 +1,16 @@
1<?php 1<?php
2/** 2/**
3 * Unpares Url's tests 3 * Unpares UrlUtils's tests
4 */ 4 */
5 5
6require_once 'application/Url.php'; 6namespace Shaarli\Http;
7
8require_once 'application/http/UrlUtils.php';
7 9
8/** 10/**
9 * Unitary tests for unparse_url() 11 * Unitary tests for unparse_url()
10 */ 12 */
11class UnparseUrlTest extends PHPUnit_Framework_TestCase 13class UnparseUrlTest extends \PHPUnit\Framework\TestCase
12{ 14{
13 /** 15 /**
14 * Thanks for building nothing 16 * Thanks for building nothing
diff --git a/tests/Url/WhitelistProtocolsTest.php b/tests/http/UrlUtils/WhitelistProtocolsTest.php
index a3156804..69512dbd 100644
--- a/tests/Url/WhitelistProtocolsTest.php
+++ b/tests/http/UrlUtils/WhitelistProtocolsTest.php
@@ -1,15 +1,15 @@
1<?php 1<?php
2 2
3require_once 'application/Url.php'; 3namespace Shaarli\Http;
4 4
5use Shaarli\Config\ConfigManager; 5require_once 'application/http/UrlUtils.php';
6 6
7/** 7/**
8 * Class WhitelistProtocolsTest 8 * Class WhitelistProtocolsTest
9 * 9 *
10 * Test whitelist_protocols() function of Url. 10 * Test whitelist_protocols() function of UrlUtils.
11 */ 11 */
12class WhitelistProtocolsTest extends PHPUnit_Framework_TestCase 12class WhitelistProtocolsTest extends \PHPUnit\Framework\TestCase
13{ 13{
14 /** 14 /**
15 * Test whitelist_protocols() on a note (relative URL). 15 * Test whitelist_protocols() on a note (relative URL).