curl -XGET http://baidu.com和 curl -XPOST http://baidu.com的Tcp流区别,PUT创建新的实体。

jackxiang 2017-6-24 12:21 | |
curl -XGET http://baidu.com

GET / HTTP/1.1
User-Agent: curl/7.29.0
Host: baidu.com
Accept: */*

HTTP/1.1 200 OK
Date: Fri, 31 Mar 2017 03:56:42 GMT
Server: Apache
Last-Modified: Tue, 12 Jan 2010 13:48:00 GMT
ETag: "51-47cf7e6ee8400"
Accept-Ranges: bytes
Content-Length: 81
Cache-Control: max-age=86400
Expires: Sat, 01 Apr 2017 03:56:42 GMT
Connection: Keep-Alive
Content-Type: text/html

<html>
<meta http-equiv="refresh" content="0;url=http://www.baidu.com/">
</html>




curl -XPOST http://baidu.com


POST / HTTP/1.1
User-Agent: curl/7.29.0
Host: baidu.com
Accept: */*

HTTP/1.1 200 OK
Date: Fri, 31 Mar 2017 03:59:50 GMT
Server: Apache
Last-Modified: Tue, 12 Jan 2010 13:48:00 GMT
ETag: "51-47cf7e6ee8400"
Accept-Ranges: bytes
Content-Length: 81
Cache-Control: max-age=86400
Expires: Sat, 01 Apr 2017 03:59:50 GMT
Connection: Keep-Alive
Content-Type: text/html

<html>
<meta http-equiv="refresh" content="0;url=http://www.baidu.com/">
</html>




Post加个参数:
curl -XPOST http://baidu.com -d"say=hello"

POST / HTTP/1.1
User-Agent: curl/7.29.0
Host: baidu.com
Accept: */*
Content-Length: 9
Content-Type: application/x-www-form-urlencoded

say=helloHTTP/1.1 200 OK
Date: Fri, 31 Mar 2017 04:03:47 GMT
Server: Apache
Last-Modified: Tue, 12 Jan 2010 13:48:00 GMT
ETag: "51-47cf7e6ee8400"
Accept-Ranges: bytes
Content-Length: 81
Cache-Control: max-age=86400
Expires: Sat, 01 Apr 2017 04:03:47 GMT
Connection: Keep-Alive
Content-Type: text/html

<html>
<meta http-equiv="refresh" content="0;url=http://www.baidu.com/">
</html>




Get里加个参数:
curl -XGET http://baidu.com?say=hello

GET /?say=hello HTTP/1.1
User-Agent: curl/7.29.0
Host: baidu.com
Accept: */*

HTTP/1.1 200 OK
Date: Fri, 31 Mar 2017 04:05:06 GMT
Server: Apache
Last-Modified: Tue, 12 Jan 2010 13:48:00 GMT
ETag: "51-47cf7e6ee8400"
Accept-Ranges: bytes
Content-Length: 81
Cache-Control: max-age=86400
Expires: Sat, 01 Apr 2017 04:05:06 GMT
Connection: Keep-Alive
Content-Type: text/html

<html>
<meta http-equiv="refresh" content="0;url=http://www.baidu.com/">
</html>





curl -XPUT http://baidu.com?say=hello
curl: (52) Empty reply from server
Head头:

PUT /?say=hello HTTP/1.1
User-Agent: curl/7.29.0
Host: baidu.com
Accept: */*



加点参数看看,其-d参数和Post一样的位置:
curl -XPUT http://baidu.com?say=hello -d'{"title":"new version of elasticsearch released!","content":"Ver 1.0 released today!","tags":["announce","elasticsearch","release"]}'
curl: (52) Empty reply from server

PUT /?say=hello HTTP/1.1
User-Agent: curl/7.29.0
Host: baidu.com
Accept: */*
Content-Length: 132
Content-Type: application/x-www-form-urlencoded

{"title":"new version of elasticsearch released!","content":"Ver 1.0 released today!","tags":["announce","elasticsearch","release"]}




curl -XDELETE http://baidu.com/blog/article/1
curl: (52) Empty reply from server

DELETE /blog/article/1 HTTP/1.1
User-Agent: curl/7.29.0
Host: baidu.com
Accept: */*

作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/9243/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!

评论列表
发表评论

昵称

网址

电邮

打开HTML 打开UBB 打开表情 隐藏 记住我 [登入] [注册]