C/C++教程

实用的curl命令整理

本文主要是介绍实用的curl命令整理,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

1.绑定固定IP和端口http请求测试及响应。

kevin@192 GitHubOfkevinsu % curl -I "http://static.kivensu.club/" -x 124.222.20.242:80
HTTP/1.1 200 OK
Server: nginx
Date: Mon, 07 Feb 2022 14:38:54 GMT
Content-Type: text/html
Content-Length: 30
Last-Modified: Thu, 27 Jan 2022 10:29:28 GMT
Connection: keep-alive
ETag: "61f27408-1e"
Accept-Ranges: bytes

2.绑定固定IP和端口http请求测试及响应过程。

kevin@192 GitHubOfkevinsu % curl -v "http://static.kivensu.club/" -x 124.222.20.242:80
*   Trying 124.222.20.242:80...
* Connected to 124.222.20.242 (124.222.20.242) port 80 (#0)
> GET http://static.kivensu.club/ HTTP/1.1
> Host: static.kivensu.club
> User-Agent: curl/7.77.0
> Accept: */*
> Proxy-Connection: Keep-Alive
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Server: nginx
< Date: Mon, 07 Feb 2022 14:42:13 GMT
< Content-Type: text/html
< Content-Length: 30
< Last-Modified: Thu, 27 Jan 2022 10:29:28 GMT
< Connection: keep-alive
< ETag: "61f27408-1e"
< Accept-Ranges: bytes
<
Welcome to My home!EveryBody.
* Connection #0 to host 124.222.20.242 left intact

3.耗时。

kevin@192 GitHubOfkevinsu % curl --trace-ascii output.txt --trace-time "http://static.kivensu.club/"
Welcome to My home!EveryBody.
kevin@192 GitHubOfkevinsu % ls
output.txt

4.指定UA。

kevin@192 GitHubOfkevinsu % curl -I "http://static.kivensu.club/" -x 124.222.20.242:80 --user-agent "Mozilla/5.0"
HTTP/1.1 200 OK
Server: nginx
Date: Mon, 07 Feb 2022 14:47:46 GMT
Content-Type: text/html
Content-Length: 30
Last-Modified: Thu, 27 Jan 2022 10:29:28 GMT
Connection: keep-alive
ETag: "61f27408-1e"
Accept-Ranges: bytes

6.指定cookie文件。

kevin@192 GitHubOfkevinsu % curl -I "http://static.kivensu.club/" -x 124.222.20.242:80 --cookie-jar cookie_file
HTTP/1.1 200 OK
Server: nginx
Date: Mon, 07 Feb 2022 14:49:52 GMT
Content-Type: text/html
Content-Length: 30
Last-Modified: Thu, 27 Jan 2022 10:29:28 GMT
Connection: keep-alive
ETag: "61f27408-1e"
Accept-Ranges: bytes

7.Post传参请求。

kevin@192 GitHubOfkevinsu % curl "http://static.kivensu.club/" -x 124.222.20.242:80 -H "Content-Type:application/json" -X Post -d '{"id":1,"name":"admin"}'
<html>
<head><title>400 Bad Request</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<hr><center>nginx</center>
</body>
</html>

8.Range分片请求。

kevin@192 GitHubOfkevinsu % curl -v "http://static.kivensu.club/" -x 124.222.20.242:80 -r 0-6
*   Trying 124.222.20.242:80...
* Connected to 124.222.20.242 (124.222.20.242) port 80 (#0)
> GET http://static.kivensu.club/ HTTP/1.1
> Host: static.kivensu.club
> Range: bytes=0-6
> User-Agent: curl/7.77.0
> Accept: */*
> Proxy-Connection: Keep-Alive
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 206 Partial Content
< Server: nginx
< Date: Mon, 07 Feb 2022 14:55:46 GMT
< Content-Type: text/html
< Content-Length: 7
< Last-Modified: Thu, 27 Jan 2022 10:29:28 GMT
< Connection: keep-alive
< ETag: "61f27408-1e"
< Content-Range: bytes 0-6/30
<
* Connection #0 to host 124.222.20.242 left intact
Welcome%

9.绑定IP+固定端口https请求测试访问。

kevin@192 GitHubOfkevinsu % curl -sv "https://124.222.20.242:8904" -k
*   Trying 124.222.20.242:8904...
* Connected to 124.222.20.242 (124.222.20.242) port 8904 (#0)
* ALPN, offering h2
* ALPN, offering http/1.1
* successfully set certificate verify locations:
*  CAfile: /etc/ssl/cert.pem
*  CApath: none
* TLSv1.2 (OUT), TLS handshake, Client hello (1):
* TLSv1.2 (IN), TLS handshake, Server hello (2):
* TLSv1.2 (IN), TLS handshake, Certificate (11):
* TLSv1.2 (IN), TLS handshake, Server key exchange (12):
* TLSv1.2 (IN), TLS handshake, Server finished (14):
* TLSv1.2 (OUT), TLS handshake, Client key exchange (16):
* TLSv1.2 (OUT), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (OUT), TLS handshake, Finished (20):
* TLSv1.2 (IN), TLS change cipher, Change cipher spec (1):
* TLSv1.2 (IN), TLS handshake, Finished (20):
* SSL connection using TLSv1.2 / ECDHE-RSA-CHACHA20-POLY1305
* ALPN, server accepted to use http/1.1
* Server certificate:
*  subject: CN=static.kivensu.club
*  start date: Feb  7 00:00:00 2022 GMT
*  expire date: Feb  7 23:59:59 2023 GMT
*  issuer: C=US; O=DigiCert Inc; OU=www.digicert.com; CN=Encryption Everywhere DV TLS CA - G1
*  SSL certificate verify ok.
> GET / HTTP/1.1
> Host: 124.222.20.242:8904
> User-Agent: curl/7.77.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< Server: nginx
< Date: Mon, 07 Feb 2022 15:12:30 GMT
< Content-Type: text/html
< Content-Length: 46
< Last-Modified: Mon, 07 Feb 2022 07:47:40 GMT
< Connection: keep-alive
< ETag: "6200ce9c-2e"
< Accept-Ranges: bytes
<
This is https test page!
So Please attention!
* Connection #0 to host 124.222.20.242 left intact
这篇关于实用的curl命令整理的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!