Skip to content

Make changes due to guzzlehttp/guzzle >= 8.2 #506

Description

@sypets
  • In Guzzle 8.0, the method getHandlerContext() has been completely removed from RequestException and ConnectException
  • in Guzzle 8.2.0 the classes ClientException | ServerException do not contain hasResponse()
  • ideally use ResponseException directly
use GuzzleHttp\TransferStats;

$options = [
    'on_stats' => function (TransferStats $stats) {
        $context = $stats->getHandlerContext();
        
        // Safely verify if cURL was the underlying driver
        if (array_key_exists('errno', $context)) {
            $curlErrorCode = $context['errno'];
            // This is definitively a cURL transfer
        } else {
            // It used a PHP Stream, MockHandler, or another abstraction
        }
    }
];

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions