0

I'm working with cURL in PHP. I want to limit the timeout with CURLOPT_TIMEOUT and CURLOPT_CONNECTTIMEOUT. Is this a correct configuration?

<?php 
        $curl = curl_init();
        $url = "example.com";
        curl_setopt_array($curl, array(
            CURLOPT_URL => $url,
            CURLOPT_RETURNTRANSFER => true,  // Capture response.
            CURLOPT_ENCODING => "",  // Accept gzip/deflate/whatever.
            CURLOPT_MAXREDIRS => 10,
            CURLOPT_TIMEOUT => 2,
            CURLOPT_CONNECTTIMEOUT => 1,
            CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
            CURLOPT_CUSTOMREQUEST => "GET",
            CURLOPT_HTTPHEADER => array(
                "authorization: example"
            ),
        ));
        $response = curl_exec($curl);
        curl_close($curl);
?>

0 Answers0