Skip to content

Commit

Permalink
[mms] Fopen driver needs to handle URIs without a protocol scheme - d…
Browse files Browse the repository at this point in the history
…efault to http (Bug #12991).
  • Loading branch information
slusarz committed Feb 24, 2014
1 parent ea572ca commit 25f1b4c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
5 changes: 5 additions & 0 deletions framework/Http/lib/Horde/Http/Request/Fopen.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,11 @@ public function send()
}
}

// fopen() requires a protocol scheme
if (parse_url($uri, PHP_URL_SCHEME) === null) {
$uri = 'http://' . $uri;
}

// Concatenate the headers
$hdr = array();
foreach ($headers as $header => $value) {
Expand Down
4 changes: 2 additions & 2 deletions framework/Http/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
</stability>
<license uri="http://www.horde.org/licenses/bsd">BSD-2-Clause</license>
<notes>
*
* [mms] Fopen driver needs to handle URIs without a protocol scheme - default to http (Bug #12991).
</notes>
<contents>
<dir baseinstalldir="/" name="/">
Expand Down Expand Up @@ -430,7 +430,7 @@
<date>2013-08-27</date>
<license uri="http://www.horde.org/licenses/bsd">BSD-2-Clause</license>
<notes>
*
* [mms] Fopen driver needs to handle URIs without a protocol scheme - default to http (Bug #12991).
</notes>
</release>
</changelog>
Expand Down
11 changes: 11 additions & 0 deletions framework/Http/test/Horde/Http/FopenTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ public function testGetBodyAfter404()
$this->assertTrue(strlen($body) > 0);
}

public function testBug12991()
{
$this->_skipMissingConfig();
$client = new Horde_Http_Client(array(
'request' => new Horde_Http_Request_Fopen()
));
$response = $client->get($this->_server . '/doesntexist');
$body = $response->getBody();
$this->assertTrue(strlen($body) > 0);
}

private function _skipMissingConfig()
{
if (empty($this->_server)) {
Expand Down

0 comments on commit 25f1b4c

Please sign in to comment.