I have a very simple guzzle request to github to download a zip archive:
$client = new \Guzzle\Http\Client();
$response
= $client->get("https://github.com/xxxxx/{$name}/zipball/master")
->setResponseBody($file)
->send();
The problem is that $file seems to end up containing two (2) copies of the archive, i.e. its size is exactly twice that obtained by running
wget https://github.com/xxxxx/{$name}/zipball/master
and of course unzip complains when unzipping the guzzle version. Is there something that I am missing in the guzzle API, perhaps due to the redirect?
This is guzzle 3.9.2 (2014-09-10), Linux, PHP 5.6.6 (cli) (built: Feb 19 2015 13:46:39)
I'm new to using Guzzle and I could be wrong but...
It seems as if $client->get is getting a copy of the zip, then you're taking that copy, and sending it back as the response body (thus adding the first copy, to the end of the second), then you're sending the request.
If all you want to do is download a copy of that zip, then just do something like this:
$client = new Client();
$response = $client->get('https://github.com/xxxxx/{$name}/zipball/master')->getBody();
file_put_contents("{$name}-master.zip", $response);