将 https://example.com 替换为需要检查的网址。这些示例会向目标地址发起网络请求。
Linux · Bash
发出 HEAD 请求,只查看响应头;部分服务不支持 HEAD。
curl --head --connect-timeout 10 --max-time 30 https://example.com发出 GET 请求,显示响应头和正文;HTTP 400 及以上时返回失败状态。--fail-with-body 需要 curl 7.76.0 或更新版本。
curl --include --fail-with-body --connect-timeout 10 --max-time 30 https://example.comWindows · PowerShell
显式使用 curl.exe,避免旧版 Windows PowerShell 中 curl 别名指向其他命令。
curl.exe --head --connect-timeout 10 --max-time 30 https://example.comcurl.exe --include --fail-with-body --connect-timeout 10 --max-time 30 https://example.com这些命令不会自动跟随重定向。需要跟随时再添加 --location,并确认目标地址。
参考:curl 官方参数手册。