namshi / cuzzle

This library let's you dump a Guzzle request to a cURL command for debug and log purpose.
https://github.com/namshi/cuzzle
331 stars 68 forks source link

Does not extract headers if passed as options to Guzzle #25

Open Einenlum opened 6 years ago

Einenlum commented 6 years ago

Cuzzle formats correctly headers when they are passed to the Request object, but not when passed to the array options of Guzzle. These two pieces of code should return the same value, but they don't.

<?php

use Namshi\Cuzzle\Formatter\CurlFormatter;
use GuzzleHttp\Psr7\Request;

require_once(__DIR__.'/vendor/autoload.php');

// curl 'http://some-url.com/path' -H 'Some-Header: lorem'
echo (new CurlFormatter())->format(
    new Request('get', 'http://some-url.com/path', ['Some-Header' => 'lorem']),
    []
);

// curl 'http://some-url.com/path'
echo (new CurlFormatter())->format(
    new Request('get', 'http://some-url.com/path'),
    ['headers' => ['Some-Header' => 'lorem']]
);