Skip to content

Commit

Permalink
merged branch JEDIBC/postContentFix (PR FriendsOfPHP#55)
Browse files Browse the repository at this point in the history
Commits
-------

5da05f5 . Split of the line of the previou patch for readability . Fixed coding standards with php-cs-fixer
35209eb Merge remote-tracking branch 'upstream/master' into postContentFix
ec33307 . use of ``null !==`` instead of ``!is_null()``
f757aea . Fix POST when you use content to send your data and not parameters

Discussion
----------

Fix POST when you use content to send your data and not parameters

Sometimes, you have to use $request->content to POST your datas instead of $request->parameters (for example sending a soap request)

---------------------------------------------------------------------------

by JEDIBC at 2012-05-24T12:25:37Z

Basically I need to crawl a crappy aspx website which take POST datas like : a=1&b=2&b=3&b=4 (multiple checkbox).
So I use content instead of parameters which worked when the http client was the ZF2 one.
  • Loading branch information
fabpot committed Jun 20, 2012
2 parents 0c4c574 + 5da05f5 commit 200dfa1
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Goutte/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,20 @@ protected function doRequest($request)
}
}

$body = null;
if (!in_array($request->getMethod(), array('GET','HEAD'))) {
if (null !== $request->getContent()) {
$body = $request->getContent();
} else {
$body = $request->getParameters();
}
}

$guzzleRequest = $this->getClient()->createRequest(
$request->getMethod(),
$request->getUri(),
array_merge($this->headers, $headers),
in_array($request->getMethod(), array('GET','HEAD')) ? null : $request->getParameters()
$body
);

if ($this->auth !== null) {
Expand Down

0 comments on commit 200dfa1

Please sign in to comment.