Skip to content

Commit

Permalink
[Http] Fixing issue related to nested POST data. Resolves guzzle#20
Browse files Browse the repository at this point in the history
  • Loading branch information
mtdowling committed Feb 14, 2012
1 parent f3a5b01 commit 6edccc2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Guzzle/Http/Message/EntityEnclosingRequest.php
Expand Up @@ -127,7 +127,7 @@ public function getPostFields()
public function getPostFiles() public function getPostFiles()
{ {
return $this->postFields->filter(function($key, $value) { return $this->postFields->filter(function($key, $value) {
return $value && $value[0] == '@'; return $value && is_string($value) && $value[0] == '@';
})->map(function($key, $value) { })->map(function($key, $value) {
return str_replace('@', '', $value); return str_replace('@', '', $value);
})->getAll(); })->getAll();
Expand Down
14 changes: 14 additions & 0 deletions tests/Guzzle/Tests/Http/Message/EntityEnclosingRequestTest.php
Expand Up @@ -303,4 +303,18 @@ public function testThrowsExceptionWhenContentLengthCannotBeDeterminedAndUsingHt
$request->setProtocolVersion('1.0'); $request->setProtocolVersion('1.0');
$request->setBody(fopen($this->getServer()->getUrl(), 'r')); $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.