Useful site for HTTP(S) testing: https://httpstat.us/
Example 1:
curl --connect-timeout 5 -m 10 https://httpstat.us/200?sleep=7000 > test.curl
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 6 0 6 0 0 0 0 --:--:-- 0:00:07 --:--:-- 1
echo $?
0
Example 2:
curl --connect-timeout 5 -m 10 https://httpstat.us/200?sleep=10000 > test.curl
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- 0:00:10 --:--:-- 0
curl: (28) Operation timed out after 10001 milliseconds with 0 out of -1 bytes received
echo $?
28
Notes about timeouts in curl:
https://unix.stackexchange.com/questions/94604/does-curl-have-a-timeout/94612