phpcurlphp-curlquichttp3

Does PHP cURL extension in version 7.4.2 support cURL with HTTP/3


Can I curl a website that supports HTTP/3, with curl, using HTTP/3 instead of HTTP/2, HTTP/1.1 or HTTP/1.0. Is this possible? If so, how to do this?


Solution

  • Yes it is indeed possible to get going but you need tweaks and manual hands-on to make it work:

    1. Make sure your PHP uses a libcurl built to support HTTP/3

    2. Provide the necessary HTTP3 symbol for your PHP program, perhaps like the example below (as CURL/PHP itself doesn't know about HTTP/3 yet)

    3. Make sure that the QUIC/h3 libraries you build curl to use support the same HTTP/3 draft version as the test server you intend to try out

    4. HTTP/3 and QUIC are not done yet, expect rough edges and glitches. Enable verbose and keep attention to details

    Happy http3ing!

    if (!defined('CURL_HTTP_VERSION_3')) {
      define('CURL_HTTP_VERSION_3', 30);
    }
        
    $ch = curl_init("https://cloudflare-quic.com/");
    curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_3);
    curl_exec($ch);