curl使用

curl -H "Content-Type:application/json" -X POST --data '{"name":"zhangsan"}' http://127.0.0.1:9000/helloWorld

curl命令用法:

curl [options...] <url>

常用参数有:

--connect-timeout <seconds>:连接超时时间。

--cookie <name=string/file>:指定cookie。可以一个个指定,也可以指定文件。

-d或者--data <data>:指定http post body。

--data-ascii <data>:指定http post ascii data。

--data-binary <data>:指定http post binary data。

--data-urlencode <name=data/name@filename>:指定http post urlencoded data。

-F或者--form <name=content>:指定http post multipart data。

--form-string <name=string>:指定http post multipart data。

-H/--header <line>:指定请求头。

--libcurl <file> Dump libcurl equivalent code of this command line

-m/--max-time <seconds>:整个request的超时时间,包括连接时间和数据传输时间。

--noproxy:指定哪些host不用代理,多个host用逗号分隔。

-o/--output <file>:将响应输出到指定文件中,默认是输出到当前窗口中。

-x/--proxy <host[:port]>:在指定host和port上用代理。

-X/--request <command>:指定是get请求还是post请求。

--retry <num>:请求异常时的重试次数。

--retry-delay <seconds>:每次重试,中间歇息多少秒。

-A/--user-agent <string>:指定user-agent。

原文地址:https://www.cnblogs.com/koushr/p/13845834.html