[FZH] c语言直接实现HTTP的回复

hz hanks hankshz在gmail.com
星期五 十二月 24 14:57:26 UTC 2010


感觉和列表的主题不是非常密切,但是还是来弱问各位大牛~~

用c实现了一个守护进程(监听一个socket),但是现在客户端要求用http的post来直接访问,收到的内容如下:
POST / HTTP/1.1
Accept: image/gif, image/x-xbitmap, image/jpeg, image/pjpeg,
application/x-ms-application, application/vnd.ms-xpsdocument,
application/xaml+xml, application/x-ms-xbap, application/x-shockwave-flash,
application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword,
*/*
Accept-Language: zh-cn
Content-Type: multipart/form-data;
boundary=---------------------------7da1fa30220a96
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; GTB6.6;
SLCC1; .NET CLR 2.0.50727; .NET CLR 1.1.4322; .NET CLR 3.5.30729; .NET CLR
3.0.30618; InfoPath.1)
Host: 175.186.15.49:9000
Content-Length: 316
Connection: Keep-Alive
Cache-Control: no-cache
-----------------------------7da1fa30220a96
Content-Disposition: form-data; name="XML_POST"
<xml
encoding="utf-8"><insert><content>helloworld</content><uid>hwang</uid><imp>1</imp><option><speed>5</speed><volume>9</volume><tone>8</tone></option></insert></xml>

-----------------------------7da1fa30220a96--

现在解析出我要的xml包已经没有问题了,但是现在不知道如何进行回复,直接把我处理好的xml包写回socket中终端页面似乎没有反应,似乎是需要增加一个http的头,不知哪位大牛可以提供一个最简单的http头,只要让终端浏览器收到我的xml包即可。

简单的说就是我现在有一个对方的socket连接int socket_receive和我需要发送的数据char *xml,然后应该如何处理呢?

希望各位大牛不吝赐教~~先谢谢了~~


关于邮件列表 Chinese 的更多信息