curl icon indicating copy to clipboard operation
curl copied to clipboard

HTTP/2 failures

Open InteliClic opened this issue 7 years ago • 2 comments

Hello! Seems there is a problem with HTTP/2 request. The pattern in the preg regex isn't able to detect the new HTTP/2 response. Maybe the pattern needs to be updated or a check for which version was sent to check the response.

InteliClic avatar Nov 08 '18 22:11 InteliClic

I also experienced the same thing.

cristarra avatar Nov 09 '18 05:11 cristarra

Hello! Seems there is a problem with HTTP/2 request. The pattern in the preg regex isn't able to detect the new HTTP/2 response. Maybe the pattern needs to be updated or a check for which version was sent to check the response.

@InteliClic I tried to solve it by adding a little code to the Curl Response library file to curl_response.php

add this code on curl_response.php

$response = str_replace("HTTP/2", "HTTP/2.0", $response);

after

$pattern = '#HTTP/\d\.\d.*?$.*?\r\n\r\n#ims';

Like this

$pattern = '#HTTP/\d\.\d.*?$.*?\r\n\r\n#ims';

// Hack Lib with replace for http/2 response
$response = str_replace("HTTP/2", "HTTP/2.0", $response);
               
// Extract headers from response 
preg_match_all($pattern, $response, $matches);

I hope it can help you without having to make many changes to change the library in your code.

cristarra avatar Nov 10 '18 04:11 cristarra