免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 6528 | 回复: 11
打印 上一主题 下一主题

[C] 用curl如何在GET中加入数据 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-01-16 16:32 |只看该作者 |倒序浏览
10可用积分
想发一个GET命令如下,如何将Connection: close下面的数据<bbb>20081216190251653</bbb>发出去?谢谢。

GET http://www.aaa.com HTTP/1.1
Host: www.aaa.com
Authorization: Digest realm="",...
User-Agent: XDM-client/OMA1.0
Date: Thu,18 Dec 2008 5:54:13 GMT
Content-Type: application/xml
If-None-Match: "20081213112042193"
Content-Length: 30
Connection: close

<bbb>20081216190251653</bbb>

论坛徽章:
5
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:53:172015亚冠之水原三星
日期:2015-06-02 16:34:202015年亚冠纪念徽章
日期:2015-10-19 18:13:37程序设计版块每日发帖之星
日期:2015-11-08 06:20:00
2 [报告]
发表于 2009-01-16 16:33 |只看该作者
POST

论坛徽章:
0
3 [报告]
发表于 2009-01-16 16:35 |只看该作者
如果非要用GET行吗?

论坛徽章:
5
2015年辞旧岁徽章
日期:2015-03-03 16:54:152015年迎新春徽章
日期:2015-03-04 09:53:172015亚冠之水原三星
日期:2015-06-02 16:34:202015年亚冠纪念徽章
日期:2015-10-19 18:13:37程序设计版块每日发帖之星
日期:2015-11-08 06:20:00
4 [报告]
发表于 2009-01-16 16:37 |只看该作者
GET http://www.aaa.com HTTP/1.1
Host: www.aaa.com
Authorization: Digest realm="",...
User-Agent: XDM-client/OMA1.0
Date: Thu,18 Dec 2008 5:54:13 GMT
Content-Type: application/xml
If-None-Match: "20081213112042193"
Content-Length: 30
bbb: 20081216190251653
Connection: close

添加一个自定义字段不知道行不行,curl应该有这样的接口,你自己翻翻,header 字样的东西

论坛徽章:
0
5 [报告]
发表于 2009-01-16 16:38 |只看该作者
header不行,header只支持"***:****"格式

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
6 [报告]
发表于 2009-01-16 16:40 |只看该作者
你就不懂啥叫 HTTP GET。

论坛徽章:
0
7 [报告]
发表于 2009-01-16 16:43 |只看该作者
确实不懂,请明示

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
8 [报告]
发表于 2009-01-16 16:46 |只看该作者
原帖由 wysunxiaohua 于 2009-1-16 16:43 发表
确实不懂,请明示

HTTP GET,就是不能这么做。

论坛徽章:
0
9 [报告]
发表于 2009-01-16 16:50 |只看该作者
网上看到这段
> Essentially what I have to handle is someone performing a POST request but
> using the GET method instead. That is, a GET request with body data after
> the headers. The way I have it set up is to use the callbacks for reading
> data from a client that's normally called with POST requests, and I need
> those callbacks to be called if the are using GET instead of POSTs.


That's not a "legal" GET request as per the HTTP RFC then, as a GET has no
request body. Are you really sure of this?


But you can still make one with libcurl. Just make a regular POST and replace
the actual method keyword to "GET" with CURLOPT_CUSTOMREQUEST.

但不知怎么replace the actual method keyword to "GET" with CURLOPT_CUSTOMREQUEST.

论坛徽章:
0
10 [报告]
发表于 2009-01-16 16:53 |只看该作者
问题中的那个例子是我抓包抓到的,确实是GET
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP