guzzle/guzzle — pull request #266 by lapause (2013-03-15 22:54:37+00:00)
Title: Easy handling of PUT requests with data in application/x-www-form-urlencoded format

Given this common example, a RESTful API exposing **PUT** entry points to update a resource and expecting incoming data in the **application/x-www-form-urlencoded** content-type, exactly like a POST (no attached file(s)).

### With a HttpClient
I think it would be logic to be able to create those PUT requests the same simple way POST requests are, just by passing an array as the $body parameter:

$client->put("/resource/1", null, array("name" => "New name"));

### With a ServiceClient
I ran into the same kind of problem trying to use a ServiceClient. Here is a sample extract of my service description JSON:

...
"sample" => array(
"httpMethod" => "PUT",
"uri" => "/resource/{id}",
"parameters" => array(
"id" => array(
"type" => "integer",
"location" => "uri",
"required" => "true"
),
"name" => array(
"type" => "string",
"location" => "postField",
"required" => true
)
)
)
...
And the command call:

$client->getCommand("sample", array("id" => 1, "name" => "New name");

The problem in that case is that no **Content-Length** header is set in the request, thus preventing the analysis of the request body on the server side.

This commit aims to fix those 2 usecases. What do you think?

Thanks a lot for your reactivity with the pull requests!