curl

curl:command line tool and library for transferring data with URLs.

  • 下载、Documentation Overview;
  • curl: (1) Protocol "http not supported or disabled in libcurl;
  • timeout https://ec.haxx.se/usingcurl-timeouts.html
    Does curl have a timeout?

libcurl error codes curl 命令执行返回码

  • CURLE_WRITE_ERROR (23)
  • CURLE_SSL_CERTPROBLEM (58)
    problem with the local client certificate.
    这个错误有时会出现,不明白原因;难道是在 linux、windows、mac os 之间传输 cert 文件导致的?
    Getting (58) unable to use client certificate (no key found or wrong pass phrase?) from curl
  • CURLE_SSL_CACERT_BADFILE (77)
    Problem with reading the SSL CA cert (path? access rights?)
    通常是密钥文件的访问权限设置太宽泛导致。需要设置成 600 即可,而 644 是不行的。

Options

  • -I/--head:Fetch the HTTP-header only! 只返回 HTTP 头;
  • -s/--silent
    Silent or quiet mode. Don’t show progress meter or error messages. Makes Curl mute.

curl man page

curl --cert /bin/sapi/sapiclient.crt --key /bin/sapi/sapiclient.key --cacert /bin/sapi/sapica.crt --connect-timeout 30 --max-time 60 "https://${serverdomain}/aps/sapiloader_up_tsinfo?
    sn=${sn}&oemcode=${oemcode}&dev_model=${dev_model}&status=${1}&code=${2}&info=\"${3}\""                                                                          
curl -k --connect-timeout 5 --max-time 10 -F '[email protected];' "https://${logserverdomain}/aps/up_romdlog?sn=${sn}&oemcode=${oemcode}&dev_model=${dev_model}"

下载文件

$ curl -v -o x -k https://download.superhcloud.com/upload/loader/RG020ET-CA/sapipack.RG020ET-CA.201812251534_2.5.122111.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0*   Trying 120.27.217.226...
* TCP_NODELAY set
* Connected to download.superhcloud.com (120.27.217.226) port 443 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* Cipher selection: ALL:!EXPORT:!EXPORT40:!EXPORT56:!aNULL:!LOW:!RC4:@STRENGTH
* successfully set certificate verify locations:
*   CAfile: C:/Program Files/Git/mingw64/ssl/certs/ca-bundle.crt
  CApath: none
* TLSv1.2 (OUT), TLS header, Certificate Status (22):
} [5 bytes data]
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
} [512 bytes data]
* TLSv1.2 (IN), TLS handshake, Server hello (2):
{ [111 bytes data]
* NPN, negotiated HTTP1.1
{ [5 bytes data]
* TLSv1.2 (IN), TLS handshake, Certificate (11):
{ [843 bytes data]
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
{ [205 bytes data]
* TLSv1.2 (IN), TLS handshake, Server finished (14):
{ [4 bytes data]
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
} [70 bytes data]
* TLSv1.2 (OUT), TLS change cipher, Client hello (1):
} [1 bytes data]
* TLSv1.2 (OUT), TLS handshake, Next protocol (67):
} [36 bytes data]
* TLSv1.2 (OUT), TLS handshake, Finished (20):
} [16 bytes data]
* TLSv1.2 (IN), TLS change cipher, Client hello (1):
{ [1 bytes data]
* TLSv1.2 (IN), TLS handshake, Finished (20):
{ [16 bytes data]
* SSL connection using TLSv1.2 / ECDHE-RSA-AES256-GCM-SHA384
* ALPN, server did not agree to a protocol
* Server certificate:
*  subject: C=CN; ST=BEIJING; O=ZJZY; OU=ZJZY; CN=download.superhcloud.com
*  start date: Jan  1 00:18:54 1970 GMT
*  expire date: Dec  7 00:18:54 2069 GMT
*  issuer: C=CN; ST=BEIJING; L=beijing; O=ZJZY; OU=zjzy; CN=superhcloud.com
*  SSL certificate verify result: unable to get local issuer certificate (20), continuing anyway.
} [5 bytes data]
> GET /upload/loader/RG020ET-CA/sapipack.RG020ET-CA.201812251534_2.5.122111.tar.gz HTTP/1.1
> Host: download.superhcloud.com
> User-Agent: curl/7.60.0
> Accept: */*
>
{ [5 bytes data]
  0     0    0     0    0     0      0      0 --:--:-- --:--:-- --:--:--     0< HTTP/1.1 200 OK
< Server: nginx
< Date: Tue, 25 Dec 2018 12:56:40 GMT
< Content-Type: application/octet-stream
< Content-Length: 355783
< Last-Modified: Tue, 25 Dec 2018 07:34:52 GMT
< Connection: keep-alive
< ETag: "5c21dd9c-56dc7"
< Accept-Ranges: bytes
<
{ [16133 bytes data]
100  347k  100  347k    0     0   397k      0 --:--:-- --:--:-- --:--:--  397k
* Connection #0 to host download.superhcloud.com left intact

你可能感兴趣的:(curl)