title: PHP Curl - Received HTTP/0.9 when not allowed
body: <p>I stumbled over a weird behavior when I try to send a post HTTP/2.0 request to apples push service:</p>
  
  <pre><code>        $http2ch = curl_init();
          curl_setopt($http2ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0);
          curl_setopt($http2ch, CURLOPT_URL, 'https://api.push.apple.com/3/device/megauniquedevicetokendummy');
          curl_setopt($http2ch, CURLOPT_PORT, 443);
          curl_setopt($http2ch, CURLOPT_HTTPHEADER, $httpHeader);
          curl_setopt($http2ch, CURLOPT_POST, true);
          curl_setopt($http2ch, CURLOPT_POSTFIELDS, $body);
          curl_setopt($http2ch, CURLOPT_RETURNTRANSFER, true);
          curl_setopt($http2ch, CURLOPT_TIMEOUT, 30);
          curl_setopt($http2ch, CURLOPT_HEADER, 1);
  
         $result = curl_exec($http2ch);
         if ($result === false) {
             throw new \Exception("Curl failed: " . curl_error($http2ch) . " | " . curl_getinfo($http2ch, CURLINFO_HTTP_CODE));
         }
  </code></pre>
  
  <p>The exception is thrown with the Message:
  Curl failed: <strong>Received HTTP/0.9 when not allowed</strong> | 0</p>
  
  <p>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?</p>
  
  <p>I am on PHP 7.2 and curl version 7.66.0.</p>