如何获取 新浪网 的Content-Length???高手帮忙啊,急急急

新封神演义 2006-08-22 02:04:44
新浪的请求头:
GET / HTTP/1.1
Accept: */*
Accept-Language: zh-cn
Accept-Encoding: gzip, deflate
If-Modified-Since: Tue, 22 Aug 2006 05:57:16 GMT; length=204198
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)
Host: www.sina.com.cn
Connection: Keep-Alive

然后返回头:
HTTP/1.0 200 OK
Date: Tue, 22 Aug 2006 06:01:12 GMT
Server: Apache/2.0.54 (Unix)
Last-Modified: Tue, 22 Aug 2006 06:00:21 GMT
ETag: "e206c9-30392-f11a8740"
Accept-Ranges: bytes
X-Powered-By: mod_xlayout_jh/0.0.1vhs.markII.remix
Cache-Control: max-age=60
Expires: Tue, 22 Aug 2006 06:02:12 GMT
Vary: Accept-Encoding
Content-Encoding: gzip
Content-Type: text/html
Age: 39
X-Cache: HIT from xa-177.sina.com.cn
Connection: close

返回头中没有Content-Length,我怎样才能获取网页的长度呢????我是用的SOCKET编程
...全文
193 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
vicky_jam 2006-08-22
  • 打赏
  • 举报
回复
如果 http://www.yahoo.com/ 这样滴话
应该 返回 302
转到其他滴页面了
softrain 2006-08-22
  • 打赏
  • 举报
回复
服务器关闭连接就表示数据发送完毕了.如果是同步接收数据,当recv返回0就是数据全部都送过来了.
yebeans 2006-08-22
  • 打赏
  • 举报
回复
http://www.yahoo.com/
我也没有找到LENGTH,不过感觉设置一个超时值就可以了吧~时间到了就不接收了~IE不也是经常刷半个页面出来~
新封神演义 2006-08-22
  • 打赏
  • 举报
回复
谢谢楼上,

还有更多网页,加了index.html仍然不能得到Content-Length,比如http://www.yahoo.com/index.html

这个问题很恼火。

我查了IE的发送和接收包,也没有Content-Length,不知道IE是怎样获取页面的。
firefox也是这样
yebeans 2006-08-22
  • 打赏
  • 举报
回复
~估计是GET为空的原因~(我设置为空虽然能下载~但也是没有长度。)
所以要指明index.html~这是我的请求和接受
up:
GET /index.html HTTP/1.1
Host:www.sina.com
Accept:*/*
User-Agent:Mozilla/4.0 (compatible; MSIE 6.00; Windows 2003)
Connection:Keep-Alive


down:
HTTP/1.0 200 OK
Date: Sat, 19 Aug 2006 00:53:32 GMT
Server: Apache/2.0.54 (Unix)
Last-Modified: Fri, 24 Feb 2006 09:48:38 GMT
ETag: "e20295-87-6645d100"
Accept-Ranges: bytes
X-Powered-By: mod_xlayout_jh/0.0.1vhs.markII.remix
Cache-Control: max-age=60
Expires: Sat, 19 Aug 2006 00:54:32 GMT
Vary: Accept-Encoding
Content-Length: 6814 《这里就有了
Content-Type: text/html
X-Cache: HIT from xa-175.sina.com.cn
Cneonction: close
Connection: Keep-Alive


18,363

社区成员

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

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