码迷,mamicode.com
首页 > Web开发 > 详细

curl的超时时间设置

时间:2015-10-17 19:24:19      阅读:481      评论:0      收藏:0      [点我收藏+]

标签:linux   curl   超时设置   



curl的超时时间设置


使用curl时,有两个超时时间:一个是连接超时时间,另一个是数据传输的最大允许时间。

 

连接超时时间: --connect-timeout 

    例:

    curl --connect-timeout 1 "http://localhost/index.html"

    出错提示形如:

    curl: (28) connect() timed out!

    

    不能连接提示如:

    curl:(7) couldn‘t connect to host


数据传输的最大允许时间用: -m 

    例:

    curl --connect-timeout 1 -m 20 "http://localhost/index.html"

    

    数据传输的最大允许时间超时的话,出错提示形如:

    curl: (28) Operation timed out after 2000 milliseconds with 0 bytes received

    
用途:

    可用在判断某资源是否可以访问,例如lvs的健康状态监测

curl的超时时间设置

标签:linux   curl   超时设置   

原文地址:http://dengxi.blog.51cto.com/4804263/1703731

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!