curlHTTP测试常⽤参数总结
curl HTTP 测试常⽤参数总结
-X:指定 HTTP 请求⽅法,如:
-XPOST HTTP 请求为 POST
-XDELETE HTTP 请求为 DELETE
该参数如果不指定,如果请求中不带消息体,默认使⽤ GET ⽅法,否则使⽤ POST ⽅法,⽰例:curl -XDELETE 127.0.0.1:8080
-d:指定消息体,如:
curl 127.0.0.1:8080 -d "Hello World"
-v:显⽰ HTTP 交互的详细过程,如:
[root@123 ~]# curl -v  127.0.0.1:8080
* About to connect() to 127.0.0.1 port 8080 (#0)
*  Trying 127.0.
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.29.0
> Host: 127.0.0.1:8080
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: openresty/1.9.3.1
< Date: Tue, 29 Dec 2015 03:48:10 GMT
< Content-Type: text/html
< Content-Length: 612
< Last-Modified: Sun, 29 Nov 2015 15:21:26 GMT
< Connection: keep-alive
< ETag: "565b17f6-264"
< Accept-Ranges: bytes
<
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="/"&</a>.<br/>
Commercial support is available at
<a href="nginx/">nginx</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
</html>
* Connection #0 to host 127.0.0.1 left intact
-i:不加这个参数,只会显⽰响应中的消息体,添加这个参数,会显⽰响应中的响应⾏,响应头和消息体,如:
[root@123 ~]# curl -i 127.0.0.1:8080
HTTP/1.1 200 OK
Server: openresty/1.9.3.1
Date: Tue, 29 Dec 2015 02:06:27 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Sun, 29 Nov 2015 15:21:26 GMT
Connection: keep-alive
ETag: "565b17f6-264"
Accept-Ranges: bytes
curl命令发送post请求带参数<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
body {
width: 35em;
margin: 0 auto;
font-family: Tahoma, Verdana, Arial, sans-serif;
}
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>
<p>For online documentation and support please refer to
<a href="/"&</a>.<br/>
Commercial support is available at
<a href="nginx/">nginx</a>.</p>
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
-I:不显⽰消息体,如:
[root@123 ~]# curl -I 127.0.0.1:8080
HTTP/1.1 200 OK
Server: openresty/1.9.3.1
Date: Tue, 29 Dec 2015 02:07:34 GMT
Content-Type: text/html
Content-Length: 612
Last-Modified: Sun, 29 Nov 2015 15:21:26 GMT
Connection: keep-alive
ETag: "565b17f6-264"
Accept-Ranges: bytes
-H:指定⼀个请求头,如:
curl -H "Test: HelloWorld" 127.0.0.1:8080
使⽤该命令,在发出的请求中会多⼀个 HTTP 请求头:Test: HelloWorld
-0:使⽤ HTTP/1.0 发送请求,如:
curl -O 127.0.0.1:8080
-L:会对重定向进⾏处理,与 -o 参数配合使⽤,功能类似于 wget:
-L:会对重定向进⾏处理,与 -o 参数配合使⽤,功能类似于 wget:
curl -L  github/coreos/etcd/releases/download/v2.2.2/etcd-v2.2. -o etcd-v2.2.
-k:不安全的 HTTPS,客户端不⽤验证站点的证书,如:
curl -k 127.0.0.1:8443
对于安全连接,还有以下参数 –ssl,–sslv2 或 -2,–sslv3 或 -3,–tlsv1 或 -l,–tlsv1.0,–tlsv1.1,–tlsv1.2

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。