Skip to content

Curl Options broken as array merge does not preserve keys #12

Closed
@ajbonner

Description

@ajbonner

Issue Summary

I noticed some code I had depending on the sendgrid-php library suddenly started emitting output after a composer update. Turns out there's this code in Client.php

        curl_setopt_array($curl, array_merge([
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_HEADER => 1,
            CURLOPT_CUSTOMREQUEST => strtoupper($method),
            CURLOPT_SSL_VERIFYPEER => false,
        ], $this->curlOptions));

array_merge does not maintain keys, therefore the curl constants do not get set on the merged options array and return transfer is therefore false i.e. curl emits its body text response as if it had been echo'd out.

Steps to Reproduce

  1. Perform any http request using library that has body content returned to client.

Technical details:

Tested on PHP7 with release sha#aa09fb89e2be2624de9db4dde914d27cbdece95c

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions