Incompatibility with Guzzle HTTP >= 7.9

Created on 25 July 2024, 5 months ago

Problem/Motivation

When posting a request to an API, Guzzle raises an exception resulting in a 500 Internal Server Error response and a message like "HTTP/HTTP/1.1 is not supported by the cURL handler."

Steps to reproduce

Upgrade GuzzleHttp to a version >= 7.9 and this will likely affect any request you care to make.

In HttpApiPluginBase::forward(), $options['version'] is set to $request->getProtocolVersion();
This retrieves $_SERVER['SERVER_PROTOCOL'] which is a string in the form 'HTTP/1.1'. Refer to https://www.php.net/manual/en/reserved.variables.server.php

This is sent to Guzzle as a request option where only the numeric element of the string is expected. Refer to https://docs.guzzlephp.org/en/stable/request-options.html#version

In the Guzzle CurlFactory::create() function, since version 7.9, there is a test

        if ('2' === $protocolVersion || '2.0' === $protocolVersion) {
            if (!self::supportsHttp2()) {
                throw new ConnectException('HTTP/2 is supported by the cURL handler, however libcurl is built without HTTP/2 support.', $request);
            }
        } elseif ('1.0' !== $protocolVersion && '1.1' !== $protocolVersion) {
            throw new ConnectException(sprintf('HTTP/%s is not supported by the cURL handler.', $protocolVersion), $request);
        }

This raises an exception when api_proxy sends a request.

Proposed resolution

Strip off the 'HTTP/' prefix when retrieving the server protocol.

I have fixed this by overriding preprocessOutgoingRequestOptions() in my module and adding

    if (
      isset($options['version']) && 
      substr($options['version'], 0, 5) == 'HTTP/'
    )  {
      $options['version'] = substr($options['version'], 5);
    }

Remaining tasks

Patch api_proxy and release an update.

User interface changes

None

API changes

None

Data model changes

None

🐛 Bug report
Status

Active

Version

2.0

Component

Code

Created by

🇬🇧United Kingdom Jim Bacon

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @Jim Bacon
  • 🇳🇱Netherlands boazpoolman

    I hate to come by and just say "same issue here", but that's about the gist of it.

    If I can assist with resolving the issue (with some guidance of the maintainer) feel free to reach out!

    For now we've just locked the `guzzlehttp/guzzle` library to 7.8.

Production build 0.71.5 2024