我已在c
中创建了一个响应curl
请求的简单服务器。我现在要做的是使用普通sockets
发出相同的请求,而不需要抽象库。
所以现在我正在尝试翻译这个curl命令:
λ server → curl -v --data "value=2" localhost:5000/19
* Hostname was NOT found in DNS cache
* Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 5000 (#0)
> POST /19 HTTP/1.1
> User-Agent: curl/7.38.0
> Host: localhost:5000
> Accept: */*
> Content-Length: 7
> Content-Type: application/x-www-form-urlencoded
>
* upload completely sent off: 7 out of 7 bytes
...
...
-v
详细论证提供的翻译是否完整?
在请求中,我只能看到传入的路径19
。参数"value=2"
在哪里?
此外,阵营Content-Length
设置为7
。这也很奇怪,因为身体似乎是空的。我在这里弄错了什么?
答案 0 :(得分:0)
我在这里弄错了什么?
您未能阅读curl
手册:
-v/--verbose
Makes the fetching more verbose/talkative. Mostly useful for
debugging. A line starting with '>' means "header data" sent by
curl, '<' means "header data" received by curl that is hidden in
normal cases, and a line starting with '*' means additional info
provided by curl.
…
If you think this option still doesn't give you enough details,
consider using --trace or --trace-ascii instead.
所以,
curl --trace-ascii - --data "value=2" localhost:5000/19
显示正文数据。