/bin/bashurl="http://192.168.0.10:8000/api/test"curl -X POST ${url} -H 'Content-Type: application/json' -d '{"param1": "1234", "param2": "qwert"}' 简单场景下也还行,但参数很多,而且参数值很长的话,看起来不清晰,也不美观。因为data参数用的单引号,在bash语法中无法引用变量,所以可以稍...
$ curl -d '@data.txt' https://google.com/login 上面命令读取data.txt文件的内容,作为数据体向服务器发送。 –data-urlencode –data-urlencode参数等同于-d,发送 POST 请求的数据体,区别在于会自动将发送的数据进行 URL 编码。 $ curl --data-urlencode 'comment=hello world' https://google.com/login ...
$ curl --data-urlencode 'comment=hello world' google.com/login 5. -e 设置 HTTP 的标头 Referer 字段 通过-e 参数用来设置 HTTP 的标头 Referer,表示请求的来源。 #将Referer标头设为google.com?q=example $ curl -e 'google.com?q=example' https://www.example.com # 通过-H参数可以通过直接...
$ curl --data-urlencode"name=Alan Walker"http://example.com multipart formposts 如果一个HTTP POST具有如下形式的表单: Name:File: 用户可以在Name中填写名字,在File中选择一个文件,然后单击Submit按钮提交数据。 为了可以在curl中模拟这个请求,我们可以使用-F或–form选项来指定数据: $curl-Fperson=annonymous...
$ curl -d'@data.txt'https://google.com/login 上面命令读取data.txt文件的内容,作为数据体向服务器发送。 --data-urlencode 自动将发送的数据进行 URL 编码 --data-urlencode参数等同于-d,发送 POST 请求的数据体,区别在于会自动将发送的数据进行 URL 编码。
--next --data sendthis http://example.com/2 --next head http://example.com/3 1. 配置文件 如果选项过多,导致命令很难输入,或者超过了系统命令最大长度的限制,我们可以使用配置文件(config file)来指定curl的选项。 通过使用-K或--config选项来告诉curl从指定的文件中读取选项,比如: ...
data-ascii 以ascii的方式post数据--data-binary 以二进制的方式post数据--negotiate 使用HTTP身份验证--digest 使用数字身份验证--disable-eprt 禁止使用EPRT或LPRT--disable-epsv 禁止使用EPSV-D/--dump-header 把header信息写入到该文件中--egd-file 为随机数据(SSL)设置EGD socket路径--tcp-nodelay 使用TCP_...
curl--data-urlencode'comment=hello world'https://wangchujiang.com/login # 上面代码中,发送的数据hello world之间有一个空格,需要进行URL编码。 读取本地文本文件的数据,向服务器发送 代码语言:javascript 复制 curl-d'@data.txt'https://wangchujiang.com/upload ...
$ curl -X POST--data-urlencode "date=April 1" example.com/form.cgi 六、HTTP动词 curl 默认的 HTTP 动词是 GET,使用 -X 参数可以支持其他动词。 代码语言:javascript 代码运行次数:0 复制Cloud Studio 代码运行 $ curl -X POST www.example.com $ curl -X DELETE www.example.com 七、User Agent字段...
--form-string <name=string>模拟用户按下提交表单(值为字符串)curl --form-string "data"https://one.more -G, --get将POST数据放在URL中并发起GET请求curl --get -d "name=onemore"https://one.more --haproxy-protocol发送HAProxy PROXY v1的headercurl --haproxy-protocolhttps://one.more ...