aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Guse <nathaniel.guse@gmail.com>2013-07-05 18:21:38 -0500
committerNathan Guse <nathaniel.guse@gmail.com>2013-07-05 18:21:38 -0500
commite03586f2cff2317efc30d8d5c39d6299ecad90bb (patch)
tree715bea0e6051568095a99ad3be15e7cd7140159e
parent4aef3d0ab9f08b1e5ad5dc776461fc425368c8db (diff)
parent7c84a12f39282b6749908f6c59962776bce10a0a (diff)
downloadforums-e03586f2cff2317efc30d8d5c39d6299ecad90bb.tar
forums-e03586f2cff2317efc30d8d5c39d6299ecad90bb.tar.gz
forums-e03586f2cff2317efc30d8d5c39d6299ecad90bb.tar.bz2
forums-e03586f2cff2317efc30d8d5c39d6299ecad90bb.tar.xz
forums-e03586f2cff2317efc30d8d5c39d6299ecad90bb.zip
Merge branch 'develop-olympus' into develop
# By Andreas Fischer # Via Andreas Fischer (1) and Nathan Guse (1) * develop-olympus: [ticket/11619] Use HTTP/1.0 because of lack of chunked-encoding handling. [ticket/11619] Some tests for get_remote_file().
-rw-r--r--phpBB/includes/functions_admin.php2
-rw-r--r--tests/functions/get_remote_file_test.php75
2 files changed, 76 insertions, 1 deletions
diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php
index 72855af5f8..21662eb493 100644
--- a/phpBB/includes/functions_admin.php
+++ b/phpBB/includes/functions_admin.php
@@ -2899,7 +2899,7 @@ function get_remote_file($host, $directory, $filename, &$errstr, &$errno, $port
if ($fsock = @fsockopen($host, $port, $errno, $errstr, $timeout))
{
- @fputs($fsock, "GET $directory/$filename HTTP/1.1\r\n");
+ @fputs($fsock, "GET $directory/$filename HTTP/1.0\r\n");
@fputs($fsock, "HOST: $host\r\n");
@fputs($fsock, "Connection: close\r\n\r\n");
diff --git a/tests/functions/get_remote_file_test.php b/tests/functions/get_remote_file_test.php
new file mode 100644
index 0000000000..4032ca5b58
--- /dev/null
+++ b/tests/functions/get_remote_file_test.php
@@ -0,0 +1,75 @@
+<?php
+/**
+*
+* @package testing
+* @copyright (c) 2013 phpBB Group
+* @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
+*
+*/
+
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions.php';
+require_once dirname(__FILE__) . '/../../phpBB/includes/functions_admin.php';
+
+/**
+* @group slow
+*/
+class phpbb_functions_get_remote_file extends phpbb_test_case
+{
+ public function test_version_phpbb_com()
+ {
+ $hostname = 'version.phpbb.com';
+
+ if (!phpbb_checkdnsrr($hostname, 'A'))
+ {
+ $this->markTestSkipped(sprintf(
+ 'Could not find a DNS record for hostname %s. ' .
+ 'Assuming network is down.',
+ $hostname
+ ));
+ }
+
+ $errstr = $errno = null;
+ $file = get_remote_file($hostname, '/phpbb', '30x.txt', $errstr, $errno);
+
+ $this->assertNotEquals(
+ 0,
+ strlen($file),
+ 'Failed asserting that the response is not empty.'
+ );
+
+ $this->assertSame(
+ '',
+ $errstr,
+ 'Failed asserting that the error string is empty.'
+ );
+
+ $this->assertSame(
+ 0,
+ $errno,
+ 'Failed asserting that the error number is 0 (i.e. no error occurred).'
+ );
+
+ $lines = explode("\n", $file);
+
+ $this->assertGreaterThanOrEqual(
+ 2,
+ sizeof($lines),
+ 'Failed asserting that the version file has at least two lines.'
+ );
+
+ $this->assertStringStartsWith(
+ '3.',
+ $lines[0],
+ "Failed asserting that the first line of the version file starts with '3.'"
+ );
+
+ $this->assertNotSame(
+ false,
+ filter_var($lines[1], FILTER_VALIDATE_URL),
+ 'Failed asserting that the second line of the version file is a valid URL.'
+ );
+
+ $this->assertContains('http', $lines[1]);
+ $this->assertContains('phpbb.com', $lines[1], '', true);
+ }
+}