gpt4 book ai didi

c - 翻译 curl -v --data 命令

转载 作者:塔克拉玛干 更新时间:2023-11-01 21:27:52 25 4
gpt4 key购买 nike

我已经在 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。这也很奇怪,因为 body 似乎是空的。我在这里弄错了什么?

最佳答案

What am I getting wrong here?

你没有阅读 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

显示正文数据。

关于c - 翻译 curl -v --data 命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34075741/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com