- /* and nothing than SPACE or NUL after HTTP/X.x */
- if (!php_http_version_parse(&info->http.version, http)
- || (http[lenof("HTTP/X.x")] && (!PHP_HTTP_IS_CTYPE(space, http[lenof("HTTP/X.x")])))) {
+ if (!php_http_version_parse(&info->http.version, http)) {
+ if (free_info) {
+ php_http_info_free(&info);
+ }
+ return NULL;
+ }
+
+ /* clumsy fix for changed libcurl behaviour in 7.49.1, see https://github.com/curl/curl/issues/888 */
+ off = &http[lenof("HTTP/X")];
+ if (info->http.version.major < 2) {
+ off += 2;
+ }
+
+ /* and nothing than SPACE or NUL after HTTP/X(.x) */
+ if (*off && (!PHP_HTTP_IS_CTYPE(space, *off))) {