Perl を使用しWWW::Mechanize
て、400KB (約 20 秒) のチャンクで提供される MP3 ファイルをダウンロードしています。
ファイル ハンドルでデータを保存するとbinmode
、各チャンクが到着するたびに追加され、最初のチャンクだけが正しく再生されます。残りはそうではありません。
使用していないときはbinmode
、ファイル全体を再生することはできません。
これは私のプログラムです
use WWW::Mechanize;
$agent = WWW::Mechanize->new( cookie_jar => {} );
@links = ("http://thehost.com/chunk1","http://thehost.com/chunk2","http://thehost.com/chunk3");
foreach (@links){
$agent->get($_);
my $filename = 'test.mp3';
open(my $fh, '>>', $filename) or die "Could not open file '$filename' $!";
binmode $fh;
print $fh $agent->content;
close $fh;
}
私は何を間違っていますか?
アップデート
これらは、返される HTTP ヘッダーです。
Cache-Control: public
Connection: close
Date: Tue, 28 Oct 2014 18:38:37 GMT
Pragma:
Server: Apache
Content-Length: 409600
Content-Type: application/octet-stream
Expires: Sat, 24 Oct 2015 12:08:00 GMT
Access-Control-Allow-Origin: *
Client-Date: Tue, 28 Oct 2014 18:38:28 GMT
Client-Peer: **.**.***.***:80
Client-Response-Num: 1