Answers:
Linux提供了一个很好的小命令,使我们的生活变得更加轻松。
得到:
使用JSON:
curl -i -H "Accept: application/json" -H "Content-Type: application/json" http://hostname/resource
使用XML:
curl -H "Accept: application/xml" -H "Content-Type: application/xml" -X GET http://hostname/resource
开机自检:
对于过帐数据:
curl --data "param1=value1¶m2=value2" http://hostname/resource
对于文件上传:
curl --form "fileupload=@filename.txt" http://hostname/resource
RESTful HTTP发布:
curl -X POST -d @filename http://hostname/resource
用于登录站点(身份验证):
curl -d "username=admin&password=admin&submit=Login" --dump-header headers http://localhost/Login
curl -L -b headers http://localhost/
-H
当使用-X POST