Skip to content
This repository
Browse code

Fixing HttpSocket::buildUri when host key is empty.

Tests added
Fixes #271
  • Loading branch information...
commit 9376826aa4232a103494166de1a60a84671c2064 1 parent 8d407ac
Mark Story authored November 13, 2009
4  cake/libs/http_socket.php
@@ -564,7 +564,8 @@ function buildUri($uri = array(), $uriTemplate = '%scheme://%user:%pass@%host:%p
564 564
 		$stripIfEmpty = array(
565 565
 			'query' => '?%query',
566 566
 			'fragment' => '#%fragment',
567  
-			'user' => '%user:%pass@'
  567
+			'user' => '%user:%pass@',
  568
+			'host' => '%host:%port/'
568 569
 		);
569 570
 
570 571
 		foreach ($stripIfEmpty as $key => $strip) {
@@ -577,7 +578,6 @@ function buildUri($uri = array(), $uriTemplate = '%scheme://%user:%pass@%host:%p
577 578
 		if (array_key_exists($uri['scheme'], $defaultPorts) && $defaultPorts[$uri['scheme']] == $uri['port']) {
578 579
 			$uriTemplate = str_replace(':%port', null, $uriTemplate);
579 580
 		}
580  
-
581 581
 		foreach ($uri as $property => $value) {
582 582
 			$uriTemplate = str_replace('%'.$property, $value, $uriTemplate);
583 583
 		}
3  cake/tests/cases/libs/http_socket.test.php
@@ -925,6 +925,9 @@ function testBuildUri() {
925 925
 		$r = $this->Socket->buildUri(array('host' => 'www.cakephp.org', 'port' => 23));
926 926
 		$this->assertIdentical($r, 'http://www.cakephp.org:23/');
927 927
 
  928
+		$r = $this->Socket->buildUri(array('path' => 'www.google.com/search', 'query' => 'q=cakephp'));
  929
+		$this->assertIdentical($r, 'http://www.google.com/search?q=cakephp');
  930
+
928 931
 		$r = $this->Socket->buildUri(array('host' => 'www.cakephp.org', 'scheme' => 'https', 'port' => 79));
929 932
 		$this->assertIdentical($r, 'https://www.cakephp.org:79/');
930 933
 

0 notes on commit 9376826

Please sign in to comment.
Something went wrong with that request. Please try again.