Where communities thrive

  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
Repo info
    require_once "vendor/autoload.php";
    use GuzzleHttp\Client;
    $client = new Client([
        // Base URI is used with relative requests
        'base_uri' => 'https://api.ma.io',
       // \GuzzleHttp\RequestOptions::VERIFY => \Composer\CaBundle\CaBundle::getSystemCaRootBundlePath()
    $response = $client->request('POST', '/tok/gen, [
        'verify'  => false,
        'headers' => [
            'Accept'     => 'application/json',
            'Content-Type'  => 'application/x-www-form-urlencoded'
        'json' => [
            'username' => 'email@gmail.com',
            'password' => 'pass123'
    i have the error
    PHP Fatal error: Uncaught GuzzleHttp\Exception\ConnectException: cURL error 35: error:1408F10B:SSL routines:ssl3_get_record:wrong version number
    Any ideas?
    Marcel Klehr
    Hi there! I have a URL that causes guzzle to just block forever, what could cause this?
    Marcel Klehr
    I have set connect_timeout and read_timeout
    Pietro Marangon
    Hi all, I'm struggling with a problem regarding request time, I'm trying to find if the problem is on guzzle side or on remote side, I have the following code that made the request twice, the first time with cURL the second time with Guzzle, the first request (code generated by postman) require 1 second to recive the response, the second request with guzzle require 20 seconds for the response. I'm on Windows 10 / PHP 8.0.3. Postman require the same time as cURL. This can't be a DNS problem since I'm using IP in $url. Is a bug on Guzzle or I'm doing something wrong?
    $curl = curl_init();
    curl_setopt_array($curl, array(
      CURLOPT_URL => $url,
      CURLOPT_POSTFIELDS => $string_params,
      CURLOPT_HTTPHEADER => array(
        'Content-Type: application/x-www-form-urlencoded'
    $response = curl_exec($curl);
    $client = new Client();
    $client->request('POST', $url, [
        'form_params' => $array_params
    Diego Gullo

    Ciao Pietro, ensure the request made with Guzzle is the same as the curl one and then try again...

    see https://docs.guzzlephp.org/en/stable/request-options.html

    Pietro Marangon

    @bizmate thanks for your reply, maybe i'm wrong but

      CURLOPT_RETURNTRANSFER => true, <-- Not relevant for Guzzle
      CURLOPT_ENCODING => '',  <-- Act with default like Guzzle
      CURLOPT_MAXREDIRS => 10, <-- Follow redirection are enable by default on Guzzle ( I'm calling a direct endpoint I don't have any redirection)
      CURLOPT_TIMEOUT => 0, <-- Same as Guzzle default
      CURLOPT_FOLLOWLOCATION => true, <-- The endpoint don't return any Location heade
      CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, <-- HTTP 1.1 is Guzzle default
      CURLOPT_CUSTOMREQUEST => 'POST', <-- Specified in request
      CURLOPT_POSTFIELDS => $string_params, <-- Specified as array
      CURLOPT_HTTPHEADER => array('Content-Type: application/x-www-form-urlencoded'), <-- Set because `form_params` specified (?)

    I also tried without antivirus but it don't resolve the problem
    I'm starting to think that is a Guzzle bug and maybe i can move this to Github issues

    Diego Gullo
    @Pe46dro if there is not difference then I am unsure what would be causing the problem. Before opening a github ticket I would suggest you open a packet sniffer such as Wireshark and see what the different is at low level directly in the packets between the Curl vs Guzzle requests
    hello everyone, I'm wondering that is the "fire and forget" request, with guzzle HTTP client, is just delaying the request to the script end and send?
    Sebastian Marek
    morning all, I’ve got a question about ServiceBuilder. I need to upgrade from a non supported version of guzzle and I wonder how to use a ServiceBuilder or an equivalent in guzzle 7?
    Pietro Marangon
    @bizmate the problem was on the remote endpoint 🤦‍♂️
    guzzle seems to do some magic involving adding Content-Length and Content-Type attributes inside a Content-Disposition: form-data; name="file"; filename="xxxx" block.... is htere a way to make it NOT?
    I've got a server that doesn't like it, and i have some python code that doesn't have it and POSTs to the remote server fine... and i'm just trying to implement the same in guzzlephp and failing.
    after spending too many hrs on this crap ( including an attempt at writing a midleware that undoes what guzzle magic was done and failing), i've given up on guzzle, and i'm going back to php's curl
    all i was trying to do was a custom x-blah header, a POST with multipart/form-data with a file name="file"; filename="..."
    terrible request logging, why does 'debug' => true not just give the entire REQUEST including headers and body?
    i had to use a $history = Middleware::history($container);
    and after the request is actioned a
    foreach ($container as $transaction) {
    foreach ($transaction['request']->getHeaders() as $name => $values) {
    echo $name . ': ' . implode(', ', $values) . "\r\n";
    echo (string) $transaction['request']->getBody(); // Hello World
    ... jsut to SEE the request it was making.
    hi, I need to proxy a request to another server using php, that is , create a guzzle request from php global variables, such as $_GET, $_POST, $_FILES, any example please?
    Hello. I use the ->getConfig() method on my client to retrieve cookies for later use (essentially maintaining session over different program calls). Since this method is getting deprecated, is there an alternative way to grab the cookie jar from the client? I tried checking the documentation, but the website is timing out for me.
    Dario Petraroia
    hy is there any way to make this quickier:
    $time_start_pool = microtime(true);
    $responses = Promise\Utils::settle($promises)->wait();
    $time_end_pool = microtime(true);
    $execution_time['pool'] = ($time_end_pool - $time_start_pool);
    $promises[] = $this->client->postAsync('https://test.com ');
    Dario Petraroia
    The array like 30/50 promises
    The array contain*…
    Hello, i have problem with guzzle, where receive 502 bad gate way from server, and guzzle not call CurlFactory::createRejection, $easy->errno = 0. Help please
    I'm having the oddest problem where my composer won't include the psr7/src/functions_include.php in the list of autoloaded files. In .lock the autoload block for psr7 has just the psr-4 section, in the static loader list the promises & guzzle function loaders are there but the psr7 one isn't. Running composer 2.2.4, guzzle 7.4.1, promises 1.5.1, and psr7 2.1.0. Reinstalling the composer libraries, redoing the dump, etc. all result in the same thing. The missing reference to the functions loader. The 7.4.1 guzzle client still uses the deprecated psr7 functions and it's causing issues. Edit: never mind, the newest guzzle psr7 doesn't have the autoload files I thought it did

    I need to suggest a save name in the file, when downloading the stream

    <?php $this->client->request('GET', $uri, ['query' => $params, 'stream' => true]);