[limb-svn] r5793 - in 3.x/trunk/limb/net: src tests/cases
svn at limb-project.com
svn at limb-project.com
Thu May 3 15:06:45 MSD 2007
Author: pachanga
Date: 2007-05-03 15:06:44 +0400 (Thu, 03 May 2007)
New Revision: 5793
URL: http://fisheye.limb-project.com/changelog/limb/?cs=5793
Modified:
3.x/trunk/limb/net/src/lmbHttpRequest.class.php
3.x/trunk/limb/net/tests/cases/lmbHttpRequestTest.class.php
Log:
-- files data is better filtered in lmbHttpRequest :: toString()
Modified: 3.x/trunk/limb/net/src/lmbHttpRequest.class.php
===================================================================
--- 3.x/trunk/limb/net/src/lmbHttpRequest.class.php 2007-05-03 08:41:35 UTC (rev 5792)
+++ 3.x/trunk/limb/net/src/lmbHttpRequest.class.php 2007-05-03 11:06:44 UTC (rev 5793)
@@ -52,12 +52,11 @@
$this->request = lmbArrayHelper :: arrayMerge($this->get, $this->post);
- //ugly hack, uploaded files shouldn't be attributes of request!!!
- $all = $this->request;
- if($this->files)
- $all = lmbArrayHelper :: arrayMerge($all, $this->files);
+ foreach($this->request as $k => $v)
+ $this->set($k, $v);
- foreach($all as $k => $v)
+ //uploaded files shouldn't be attributes of request!?
+ foreach($this->files as $k => $v)
$this->set($k, $v);
}
@@ -186,24 +185,20 @@
function toString()
{
- //ugly hack: making a copy(uri must be a value object)
- $uri = clone $this->uri;
- $uri->removeQueryItems();
-
- $result = array();
+ $flat = array();
$query = '';
- $exported = $this->export();
+ lmbArrayHelper :: toFlatArray($this->export(), $flat);
- //ugly hack again: removing uploaded files data
- if(isset($exported['file']))
- unset($exported['file']);
-
- lmbArrayHelper :: toFlatArray($exported, $result);
-
- foreach($result as $key => $value)
+ foreach($flat as $key => $value)
+ {
+ if(is_object($value)) //skippping uploaded files
+ continue;
$query .= $key . '=' . $value . '&';
+ }
+ $uri = clone($this->uri);
+ $uri->removeQueryItems();
return rtrim($uri->toString() . '?' . rtrim($query, '&'), '?');
}
Modified: 3.x/trunk/limb/net/tests/cases/lmbHttpRequestTest.class.php
===================================================================
--- 3.x/trunk/limb/net/tests/cases/lmbHttpRequestTest.class.php 2007-05-03 08:41:35 UTC (rev 5792)
+++ 3.x/trunk/limb/net/tests/cases/lmbHttpRequestTest.class.php 2007-05-03 11:06:44 UTC (rev 5793)
@@ -127,11 +127,22 @@
function testToString()
{
+ $files = array(
+ 'file1' => array(
+ 'name' => 'file',
+ 'type' => 'file_type',
+ 'tmp_name' => 'file_tmp_name',
+ 'size' => 'file_size',
+ 'error' => 'file_err_code'
+ )
+ );
+
$request = new lmbHttpRequest('http://test.com?z=1',
array('b' => array('c' => 1)),
array('d' => 2),
- array('cookie' => 2), //only get & post data gets into string
- array('file' => array()));
+ //only get & post data gets into string, cookies and files are ignored
+ array('cookie' => 2),
+ $files);
$this->assertEqual($request->toString(), 'http://test.com?b[c]=1&z=1&d=2');
}
More information about the limb-svn
mailing list