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