关于winsock发送http的post请求问题

windeer 2007-09-08 11:44:48
我想做一个客户端软件,有这样的功能.

我发送讲求到服务端的asp或者php页面,然后我需要接收他的响应,分析页面返回给我的数据,再做一些处理.

因为我发送的数据量可能有些大,所以我用到了post.
我的post的请求头是这样的:

"POST /test.asp HTTP/1.1
Host:192.168.1.135
Accept:*/*
User-Agent:yoocun /1.0
Connection:Keep-Alive
Content-Type:application/x-www-form-urlencoded
Content_Length:14

id=1&type=http

"
注:因为是做测试,所以用了简单的数据

test.asp是我用来做测试的页面,里面代码如下:
<html>
<body>

<%
dim id2
dim type2

id2 = request("id")
type2 = request("type")

response.write id2
response.write type2

%>

sdkfjhsldfj;sldfks;dlfsldfk
</body>
</html>

我希望得到如下的结果:
<html>
<body>

1http

sdkfjhsldfj;sldfks;dlfsldfk
</body>
</html>

可是我收到的总是不是这样的结果,不知道原因在哪里?

以下是我收到的回应:

"HTTP/1.1 200 OK
Server: Microsoft-IIS/5.1
Date: Sat, 08 Sep 2007 03:27:12 GMT
Content-Length: 68
Content-Type: text/html
Set-Cookie: ASPSESSIONIDCSASCSBC=NBPNKGABGDMDJPKIJHLPNJGF; path=/
Cache-control: private

"

"<html>
<body>



sdkfjhsldfj;sldfks;dlfsldfk
</body>
</html>HTTP/1.1 400 Bad Request
Server: Microsoft-IIS/5.1
Date: Sat, 08 Sep 2007 03:41:42 GMT
Content-Type: text/html
Content-Length: 87

<html><head><title>Error</title></head><body>The parameter is incorrect. </body></html>"

回应是分两次接收的,asp的代码好像没有执行.那位大哥知道原因,相烦指点下!
在这里谢谢先!
...全文
414 3 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
dyw 2007-09-09
  • 打赏
  • 举报
回复
用asp弄个表单程序,把你那两个字段写上,提交到test.asp看看POST格式,对照一下。
windeer 2007-09-09
  • 打赏
  • 举报
回复
没有人知道原因吗?
windeer 2007-09-08
  • 打赏
  • 举报
回复
另外补以一点,我用get发送,请求包如下:
"GET /test.asp?id=1&type=http HTTP/1.1
Host:192.168.1.135
Accept:*/*
User-Agent:Mozilla/4.0 (compatible; MSIE 5.00; Windows 98)
Connection:Keep-Alive

"
可以得到我想要的结果.

18,363

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 网络编程
c++c语言开发语言 技术论坛(原bbs)
社区管理员
  • 网络编程
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧