Skip to content

[HttpClient] Undefined array key "connection" #59039

@PhilETaylor

Description

@PhilETaylor

Symfony version(s) affected

7.2.0

Description

Since deploying 7.2.0 in production today we are getting the occasional exception caught by Sentry (of a warning) when making http-client calls to remote sites.

Undefined array key "connection"

https://phil-taylor.sentry.io/share/issue/cf7fdf8815f3437f9faac44fd4d9065c/

The issue seems to have started with the PR #58562

dumping the headers dd($responses[$id]->headers); of a normal request, I can see there is no array key connection in the headers.

How to reproduce

<?php
// composer req symfony/http-client symfony/var-dumper

use Symfony\Component\HttpClient\CurlHttpClient;

error_reporting(E_ALL);
ini_set('display_errors',1);

require 'vendor/autoload.php';

$client = new CurlHttpClient();

$response = $client->request(
    'GET',
    'https://symfony.com/'
);

$content = $response->getContent(false);

// then edit CurlResponse.php and dd the headers before line 319

Possible Solution

check the array key exists before use

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions