私は過去 2 日間、この問題の真相を断続的に突き止めようとしてきましたが、本当に行き詰っています。うまくいけば、賢い人々が私を助けてくれるでしょう。
問題は、渡された Web サイトから (Synapse ライブラリを使用して) ファイルをダウンロードするスレッドで呼び出す関数があることです。ただし、ファイルをプルダウンしないサイトがときどきあることがわかりましたが、wget または Firefox/IE では問題なくダウンロードされます。
調べてみると、気になるものを見つけました。関連するコードは次のとおりです。
uses
//[..]
HTTPSend,
blcksock;
//[..]
type
TMyThread = class(TThread)
protected
procedure Execute; override;
private
{ Private declarations }
fTheUrl: string;
procedure GetFile(const TheUrl: string);
public
property thrd_TheUrl: string read fTheUrl write fTheUrl;
end;
implementation
[..]
procedure TMyThread.GetFile(const TheUrl: string);
var
HTTP: THTTPSend;
success: boolean;
sLocalUrl: string;
IsSame : boolean;
begin
HTTP := THTTPSend.Create;
try
HTTP.UserAgent :=
'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 2.0.50727)';
HTTP.ProxyHost := 'MYPROXY.COM';
HTTP.ProxyPort := '80';
sLocalUrl :=
'http://web.archive.org/web/20071212205017/energizer.com/usbcharger/download/UsbCharger_setup_V1_1_1.exe';
IsSame := SameText(sLocalUrl, sTheUrl); //this equals True when I debug
///
///
/// THIS IS WHERE THE ISSUE BEGINS
/// I will comment out 1 of the following when debugging
///
HTTP.HTTPMethod('GET', sLocalUrl); // ----this works and WILL download the file
HTTP.HTTPMethod('GET', sTheUrl); // --- this always fails, and HTTP.ResultString contains "Not Found"
success := SysUtils.UpperCase(HTTP.ResultString) = 'OK';
if HTTP.ResultCode > 0 then
success := True; //this is here just to keep the value around while debugging
finally
HTTP.Free;
end;
end;
procedure TMyThread.Execute
begin
//fTheURL contains this value: http://web.archive.org/web/20071212205017/energizer.com/usbcharger/download/UsbCharger_setup_V1_1_1.exe
GetFile(fTheUrl);
end;
問題は、関数にローカル変数を割り当てて URL を直接指定すると、すべてが機能することです。ただし、変数を関数に渡すと失敗します。誰にもアイデアはありますか?
HTTP.HTTPMethod('GET', sLocalUrl); // ----this works and WILL download the file
HTTP.HTTPMethod('GET', sTheUrl); // --- this always fails, and HTTP.ResultString contains "Not Found"
SVN リポジトリの Synapseの最新バージョン(2 日前のバージョン) を使用しています。
注: ダウンロードしようとしているファイルはウイルスに感染していることがわかっています。私が作成しているプログラムは、分析のために悪意のあるファイルをダウンロードすることを目的としています。そのため、ダウンロードしたファイルを実行しないでください。
ただし、この URL b/c を使用しています。これは、問題を再現できる URL です。