Answers for "curl get error code"

PHP
9

curl return code only

curl -s -o /dev/null -w "%{http_code}" http://www.example.org/
Posted by: Guest on August-01-2020
0

curl error handling

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $your_url);
curl_setopt($ch, CURLOPT_FAILONERROR, true); // Required for HTTP error codes to be reported via our call to curl_error($ch)
//...
curl_exec($ch);
if (curl_errno($ch)) {
    $error_msg = curl_error($ch);
}
curl_close($ch);

if (isset($error_msg)) {
    // TODO - Handle cURL error accordingly
}
Posted by: Guest on May-17-2021
1

get status code of curl

curl -o /dev/null -s -w "%{http_code}\n" http://localhost
Posted by: Guest on January-15-2021
1

curl get return code

curl -I http://www.example.org
Posted by: Guest on March-18-2021

Browse Popular Code Answers by Language