【发布时间】:2019-09-13 01:59:59
【问题描述】:
我们如何在终端上用 curl 获取 POST 请求消息?
如果我是对的,这就是我们获得响应消息的方式:
$ curl -X POST -d "param1=value1¶m2=value2" 'http://example.com' -i
HTTP/1.1 200 OK
Date: Fri, 13 Sep 2019 01:51:22 GMT
Server: Apache/2.4.38 (Ubuntu)
Content-Length: 56
Content-Type: text/html; charset=UTF-8
Array
(
[param1] => value1
[param2] => value2
)
我们如何在下面得到这样的东西?
POST /path HTTP/1.1
Host: example.com
foo=bar&baz=bat
使用-v:
$ curl -X POST -d "param1=value1¶m2=value2" 'http://127.0.0.1' -v
* Expire in 0 ms for 6 (transfer 0x5591f30695c0)
* Trying 127.0.0.1...
* TCP_NODELAY set
* Expire in 200 ms for 4 (transfer 0x5591f30695c0)
* Connected to 127.0.0.1 (127.0.0.1) port 80 (#0)
> POST / HTTP/1.1
> Host: 127.0.0.1
> User-Agent: curl/7.64.0
> Accept: */*
> Content-Length: 27
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 27 out of 27 bytes
< HTTP/1.1 200 OK
< Date: Fri, 13 Sep 2019 01:41:44 GMT
< Server: Apache/2.4.38 (Ubuntu)
< Content-Length: 56
< Content-Type: text/html; charset=UTF-8
<
Array
(
[param1] => value1
[param2] => value2
)
* Connection #0 to host 127.0.0.1 left intact
但是看到没有请求消息。
【问题讨论】:
标签: curl request httprequest httpresponse