zoukankan      html  css  js  c++  java
  • curl base

    下载

    指定下载文件名,已存在同名文件被覆盖

    curl -o filename.ext downloadlink
    

    继续现有下载

    curl -O -C downloadlink
    

    检测下载文件是否存在,不下载

    curl -I https://www.booleanworld.com/
    

    自动重定向

    curl -L http://example.com
    

    最多700次重定向

    curl -L --max-redirs 700 example.com
    

    无限次

    curl -L --max-redirs -1 example.com
    

    cURL can only follow redirects if the server replied with a HTTP redirect, which means that the server used a 3XX status code, and it used the Location header to indicate the new URL

    查看res http header

    curl -i http://example.com
    

    verbose mode

    curl -v http://example.com
    
    • the output contains request data (marked with >)

    • response headers (marked with <)

    • other details about the request, such as the IP used and the SSL handshake process (marked with *).

    忽略res body

    curl -vo /dev/null https://www.booleanworld.com/ # Linux/MacOS
    curl -vo NUL https://www.booleanworld.com/ # Windows
    

    忽略进度条以及错误

    curl -svo /dev/null https://www.booleanworld.com/ # Linux/MacOS
    curl -svo NUL https://www.booleanworld.com/ # Windows
    

    忽略进度条,保留错误

    curl -sSvo /dev/null https://www.booleanworld.com/ # Linux/MacOS
    curl -sSvo NUL https://www.booleanworld.com/ # Windows
    

    只忽略进度条,其他信息保存到文件

    curl -sSvo file.html https://www.booleanworld.com/
    

    处理错误

    访问网站出错时,curl返回0

    curl https://www.booleanworld.com/404 -sSo file.txt
    

    访问网站出错时,curl返回非0

    curl https://www.booleanworld.com/404 -fsSo file.txt
    

    检测协议版本

    curl -v --tlsv1.2 https://www.booleanworld.com/
    
    curl -v --sslv3 https://www.booleanworld.com/
    
    --sslv<version> 
    --tlsv<version>
    --http1.0
    --http1.1
    --http2
    

    时间

    curl https://www.baidu.com/ -sSo /dev/null -w 'namelookup:	%{time_namelookup}
    connect:	%{time_connect}
    appconnect:	%{time_appconnect}
    pretransfer:	%{time_pretransfer}
    redirect:	%{time_redirect}
    starttransfer:	%{time_starttransfer}
    total:		%{time_total}
    '
    
    namelookup — The time required for DNS resolution.
    connect — The time required to establish the TCP connection.
    appconnect — This is the time taken to establish connections for any layers between TCP and the application layer, such as SSL/TLS. In our case, the application layer is HTTP. Also, if there is no such intermediate layer (such as when there is a direct HTTP request), this time will always be 0.
    pretransfer — This is the time taken from the start to when the transfer of the file is just about to begin.
    redirect — This is the total time taken to process any redirects.
    starttransfer — Time it took from the start to when the first byte is about to be transferred.
    total — The total time taken for cURL to complete the entire process.
    
  • 相关阅读:
    springmvc的控制器是不是单例模式,如果是,有什么问题,怎么解决?
    数据库中的锁机制
    在inux中安装redis的时候,会出现下面的这个异常
    使用SecureCRT操作linux系统时候的简单设置
    装饰者设计模式
    java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone.
    事务
    2.6.1 测试架构师
    测试专家讲述通往测试架构师之路
    什么是软件测试架构师
  • 原文地址:https://www.cnblogs.com/Searchor/p/13717694.html
Copyright © 2011-2022 走看看