Skip to content
Advertisement

PHP Curl – Received HTTP/0.9 when not allowed

I stumbled over a weird behavior when I try to send a post HTTP/2.0 request to apples push service:

JavaScript

The exception is thrown with the Message: Curl failed: Received HTTP/0.9 when not allowed | 0

I explicitly told curl to use HTTP/2.0 on the second line of the code snipped above. Does anyone have any idea what that error message means and why curl uses such an old HTTP version?

I am on PHP 7.2 and curl version 7.66.0.

Advertisement

Answer

I figured it out. Make sure that curl is compiled with nghttp2.

If you are unsure, you can check it on your terminal using curl --version

If you dont find nghttp2/{version} you need to compile curl again with nghttp2.

curl --version example where nghttp2 is missing:

JavaScript

curl --version example where nghttp2 is available:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement