[limb-svn] r6875 - in 3.x/trunk/limb/net: src tests/cases
svn at limb-project.com
svn at limb-project.com
Mon Mar 31 16:08:36 MSD 2008
Author: pachanga
Date: 2008-03-31 16:08:36 +0400 (Mon, 31 Mar 2008)
New Revision: 6875
URL: http://fisheye.limb-project.com/changelog/limb/?cs=6875
Modified:
3.x/trunk/limb/net/src/lmbHttpRequest.class.php
3.x/trunk/limb/net/tests/cases/lmbHttpRequestTest.class.php
Log:
-- lmbHttpRequest now extracts port from server HTTP_HOST variable
Modified: 3.x/trunk/limb/net/src/lmbHttpRequest.class.php
===================================================================
--- 3.x/trunk/limb/net/src/lmbHttpRequest.class.php 2008-03-31 07:23:58 UTC (rev 6874)
+++ 3.x/trunk/limb/net/src/lmbHttpRequest.class.php 2008-03-31 12:08:36 UTC (rev 6875)
@@ -162,9 +162,17 @@
{
$host = 'localhost';
if(!empty($_SERVER['HTTP_HOST']))
- list($host) = explode(':', $_SERVER['HTTP_HOST']);
+ {
+ $items = explode(':', $_SERVER['HTTP_HOST']);
+ $host = $items[0];
+ $port = isset($items[1]) ? $items[1] : null;
+ }
elseif(!empty($_SERVER['SERVER_NAME']))
- list($host) = explode(':', $_SERVER['SERVER_NAME']);
+ {
+ $items = explode(':', $_SERVER['SERVER_NAME']);
+ $host = $items[0];
+ $port = isset($items[1]) ? $items[1] : null;
+ }
if(isset($_SERVER['HTTPS']) && !strcasecmp($_SERVER['HTTPS'], 'on'))
$protocol = 'https';
Modified: 3.x/trunk/limb/net/tests/cases/lmbHttpRequestTest.class.php
===================================================================
--- 3.x/trunk/limb/net/tests/cases/lmbHttpRequestTest.class.php 2008-03-31 07:23:58 UTC (rev 6874)
+++ 3.x/trunk/limb/net/tests/cases/lmbHttpRequestTest.class.php 2008-03-31 12:08:36 UTC (rev 6875)
@@ -131,9 +131,7 @@
function testGetFilesMultipartException()
{
- $old = null;
- if(isset($_SERVER['CONTENT_TYPE']))
- $old = $_SERVER['CONTENT_TYPE'];
+ $old = @$_SERVER['CONTENT_TYPE'];
$_SERVER['CONTENT_TYPE'] = 'blah';
@@ -152,6 +150,39 @@
$_SERVER['CONTENT_TYPE'] = $old;
}
+ function testInitByServerVariables()
+ {
+ $old_uri = @$_SERVER['REQUEST_URI'];
+ $old_host = @$_SERVER['HTTP_HOST'];
+ $old_port = @$_SERVER['SERVER_PORT'];
+
+ $_SERVER['REQUEST_URI'] = '/';
+ $_SERVER['HTTP_HOST'] = 'test.com';
+ $_SERVER['SERVER_PORT'] = '8080';
+
+ $request = new lmbHttpRequest();
+ $this->assertEqual($request->getRawUriString(), 'http://test.com:8080/');
+
+ $_SERVER['REQUEST_URI'] = $old_uri;
+ $_SERVER['HTTP_HOST'] = $old_host;
+ $_SERVER['SERVER_PORT'] = $old_port;
+ }
+
+ function testExtractPortFromHost()
+ {
+ $old_uri = @$_SERVER['REQUEST_URI'];
+ $old_host = @$_SERVER['HTTP_HOST'];
+
+ $_SERVER['REQUEST_URI'] = '/';
+ $_SERVER['HTTP_HOST'] = 'test.com:8787';
+
+ $request = new lmbHttpRequest();
+ $this->assertEqual($request->getRawUriString(), 'http://test.com:8787/');
+
+ $_SERVER['REQUEST_URI'] = $old_uri;
+ $_SERVER['HTTP_HOST'] = $old_host;
+ }
+
function testToString()
{
$files = array(
More information about the limb-svn
mailing list