Permalink
Browse files

[Http] Fixing issue related to nested POST data. Resolves #20

  • Loading branch information...
1 parent f3a5b01 commit 6edccc2db838dd9185315e3f9e4bf225b4ac86b9 @mtdowling mtdowling committed Feb 14, 2012
@@ -127,7 +127,7 @@ public function getPostFields()
public function getPostFiles()
{
return $this->postFields->filter(function($key, $value) {
- return $value && $value[0] == '@';
+ return $value && is_string($value) && $value[0] == '@';
})->map(function($key, $value) {
return str_replace('@', '', $value);
})->getAll();
@@ -303,4 +303,18 @@ public function testThrowsExceptionWhenContentLengthCannotBeDeterminedAndUsingHt
$request->setProtocolVersion('1.0');
$request->setBody(fopen($this->getServer()->getUrl(), 'r'));
}
+
+ /**
+ * @covers Guzzle\Http\Message\EntityEnclosingRequest::getPostFiles
+ */
+ public function testAllowsNestedPostData()
+ {
+ $request = new EntityEnclosingRequest('POST', 'http://test.com/');
+ $request->addPostFields(array(
+ 'a' => array('b', 'c')
+ ));
+ $this->assertEquals(array(
+ 'a' => array('b', 'c')
+ ), $request->getPostFields());
+ }
}

0 comments on commit 6edccc2

Please sign in to comment.