哭着喊着说:神啊,救救我吧~~~~~~IE可以下载,为什么idhttp不能下载? ( 积分: 200 )

  • 主题发起人 主题发起人 fion
  • 开始时间 开始时间
F

fion

Unregistered / Unconfirmed
GUEST, unregistred user!
直接在IE输入链接地址“http://61.135.131.152/Songs/English/Band_Group/Five/(1999) Invincible/04-WE WILL ROCK YOU.mp3?wxc”,IE可以直接下载音乐文件04-WE WILL ROCK YOU.mp3,但是我使用IdHttp却下不了:其间会产生HTTP/1.1 302 Found(页面临时转向),根据Location就转到http://61.135.131.152/Songs/English/Band_Group/Five/music1.htm,最后下载的是music1.htm,郁闷啊~~~~~~~~哭着喊着拜托那位大哥救救我...

var Stream:TMemoryStream;
const URL:String:='http://61.135.131.152/Songs/English/Band_Group/Five/(1999) Invincible/04-WE WILL ROCK YOU.mp3?wxc';
begin
Stream:=TMemoryStream.Create;
IdHttp.ReadTimeout:=12000;
IdHttp.Request.ContentType:='application/x-www-form-urlencoded';
IdHttp.HandleRedirects:=True
IdHttp.Get(URL,Stream);
end;
 
直接在IE输入链接地址“http://61.135.131.152/Songs/English/Band_Group/Five/(1999) Invincible/04-WE WILL ROCK YOU.mp3?wxc”,IE可以直接下载音乐文件04-WE WILL ROCK YOU.mp3,但是我使用IdHttp却下不了:其间会产生HTTP/1.1 302 Found(页面临时转向),根据Location就转到http://61.135.131.152/Songs/English/Band_Group/Five/music1.htm,最后下载的是music1.htm,郁闷啊~~~~~~~~哭着喊着拜托那位大哥救救我...

var Stream:TMemoryStream;
const URL:String:='http://61.135.131.152/Songs/English/Band_Group/Five/(1999) Invincible/04-WE WILL ROCK YOU.mp3?wxc';
begin
Stream:=TMemoryStream.Create;
IdHttp.ReadTimeout:=12000;
IdHttp.Request.ContentType:='application/x-www-form-urlencoded';
IdHttp.HandleRedirects:=True
IdHttp.Get(URL,Stream);
end;
 
呵呵,  如果你不要求速度快的话,
可以有 wininet.dll中的函数
InternetOpen
InternetReadFile来下载
绝对稳定,但是速度超慢,与IE一样,
Idhttp这种东西就不要用了,又慢又不稳定

最好自己写,我就自己写了一个,快速,可以多个线程调用, 每个调用线程又会启动多个线程下载,
 不过,我自己的项目 ,只需要下小文件,我将所有的都保存在内存中的

 对于大文件需要合并临时文件,我没做。


 
 
可是我已经在IdHttp上做了很多工作了啊,泣求高手帮助~~~~~~~~~~
 
顶上去,大富翁的高手们来帮帮忙啊
 
建议你看看HTTP的RFC,可能是你没有使用RefURL,或者是Cookie的问题。
 
楼上说的对,Get之前加上这句试试:
IdHttp.Request.Referer := URL;
 
这是因为网页地址被重定向了,设IdHTTP1的HandleRedirects属性为True,保你解决问题。给分!^_^
 
呵呵,不好意思,看错了。
 
马上试试alter和utop的法子,深切感谢大家 的参与讨论。如果不行还哭~~~~~呵呵
 
IdHttp.Request.Referer:=URL;之后异常:404 not found[:(]就是这个地址“http://61.135.131.152/Songs/English/Band_Group/Five/(1999) Invincible/04-WE WILL ROCK YOU.mp3?wxc”,直接放在IE地址栏可以下载的,为什么我不可以,种族歧视啊~~~~~~~~
 
flashget也不行,一样的问题...
 
flashget是可以的,兄台的URL可能拷贝失误了[:)]。但是我用idhttp下载的就是music1.htm,flashget下载的就是想要的文件04-WE WILL ROCK YOU.mp3,谁来救命啊~~~~~
Wed Nov 16 12:00:17 2005 正在连接 61.135.131.152 [IP=61.135.131.152:80]
Wed Nov 16 12:00:17 2005 已连接.
Wed Nov 16 12:00:17 2005 GET /Songs/English/Band_Group/Five/(1999)%20Invincible/04-WE%20WILL%20ROCK%20YOU.mp3?wxc HTTP/1.1
Wed Nov 16 12:00:17 2005 Host: 61.135.131.152
Wed Nov 16 12:00:17 2005 Accept: */*
Wed Nov 16 12:00:17 2005 Referer: http://61.135.131.152/Songs/English/Band_Group/Five/(1999) Invincible
Wed Nov 16 12:00:17 2005 User-Agent: Mozilla/4.0 (compatible; MSIE 5.00; Windows 98)
Wed Nov 16 12:00:17 2005 Pragma: no-cache
Wed Nov 16 12:00:17 2005 Cache-Control: no-cache
Wed Nov 16 12:00:17 2005 Connection: close
Wed Nov 16 12:00:18 2005 HTTP/1.1 302 Found
Wed Nov 16 12:00:18 2005 Date: Wed, 16 Nov 2005 04:00:35 GMT
Wed Nov 16 12:00:18 2005 Server: Apache/2.0.49 (Unix) DAV/2 mod_utf8/1.4
Wed Nov 16 12:00:18 2005 Location: http://61.135.130.93/Songs/English/Band_Group/Five/(1999) Invincible/04-WE WILL ROCK YOU.mp3?wxc
Wed Nov 16 12:00:18 2005 Content-Length: 379
Wed Nov 16 12:00:18 2005 Connection: close
Wed Nov 16 12:00:18 2005 Content-Type: text/html; charset=iso-8859-1
Wed Nov 16 12:00:18 2005 重定向到 http://61.135.130.93/Songs/English/Band_Group/Five/(1999) Invincible/04-WE WILL ROCK YOU.mp3?wxc
Wed Nov 16 12:00:18 2005 正在连接 61.135.130.93 [IP=61.135.130.93:80]
Wed Nov 16 12:00:18 2005 已连接.
Wed Nov 16 12:00:18 2005 GET /Songs/English/Band_Group/Five/(1999)%20Invincible/04-WE%20WILL%20ROCK%20YOU.mp3?wxc HTTP/1.1
Wed Nov 16 12:00:18 2005 Host: 61.135.130.93
Wed Nov 16 12:00:18 2005 Accept: */*
Wed Nov 16 12:00:18 2005 Referer: http://61.135.130.93/Songs/English/Band_Group/Five/(1999) Invincible
Wed Nov 16 12:00:18 2005 User-Agent: Mozilla/4.0 (compatible; MSIE 5.00; Windows 98)
Wed Nov 16 12:00:18 2005 Pragma: no-cache
Wed Nov 16 12:00:18 2005 Cache-Control: no-cache
Wed Nov 16 12:00:18 2005 Connection: close
Wed Nov 16 12:00:18 2005 HTTP/1.1 200 OK
Wed Nov 16 12:00:18 2005 Date: Wed, 16 Nov 2005 04:00:37 GMT
Wed Nov 16 12:00:18 2005 Server: Apache/2.0.49 (Unix) mod_utf8/1.3
Wed Nov 16 12:00:18 2005 Last-Modified: Tue, 09 Aug 2005 10:45:23 GMT
Wed Nov 16 12:00:18 2005 ETag: "aac005-2b1915-dc7296c0"
Wed Nov 16 12:00:18 2005 Accept-Ranges: bytes
Wed Nov 16 12:00:18 2005 Content-Length: 2824469
Wed Nov 16 12:00:18 2005 Connection: close
Wed Nov 16 12:00:18 2005 Content-Type: audio/mpeg
Wed Nov 16 12:00:18 2005 开始接受数据!
Wed Nov 16 12:00:20 2005 User Cancel at 14520.
 
为什么啊~~~~???
 
郁闷,看看哪天才有高手出来
 
估计是Cookie或者Session的问题,Idhttp应该是一个新的请求,没有继承IE中的Cookie或者Session。
解决办法目前只有放弃IdHTTP吧,或许有其他达人可以解决。
 
有时间的话用 Ethereal 查查IE 和 Indy的 http通讯过程有啥区别吧,最近俺没空~
 
人气好冷落啊
 
后退
顶部