Или попробовать libcurl и поиграться с CURLOPT_PROGRESSFUNCTION
CURLOPT_PROGRESSFUNCTION
Function pointer that should match the curl_progress_callback prototype found in <curl/curl.h>. This function gets called by libcurl instead of its internal equivalent with a frequent interval during operation (roughly once per second) no matter if data is being transfered or not. Unknown/unused argument values passed to the callback will be set to zero (like if you only download data, the upload size will remain 0). Returning a non-zero value from this callback will cause libcurl to abort the transfer and return CURLE_ABORTED_BY_CALLBACK. /* Возвращая не нулевое значение, функция обратного вызова заставляет libcurl прервать закачку и вернуть CURLE_ABORTED_BY_CALLBACK */
If you transfer data with the multi interface, this function will not be called during periods of idleness unless you call the appropriate libcurl function that performs transfers.
CURLOPT_NOPROGRESS must be set to 0 to make this function actually get called.
Вот небольшой пример:
(
http://svn.shamangrad.net/mxlib/trunk/xml/ )
Код: Выделить всё
function write_data(Buffer: Pointer; Size, nmemb: Cardinal; RPC: TMXRPC): Cardinal; cdecl;
begin
Result := RPC.FContent.Write(Buffer^, Size * nmemb);
end;
function TMXRPC.Invoke(const Method: UTF8String): Boolean;
var
code: CURLcode;
req: AnsiString;
begin
Inc(FQueryCount);
code := curl_easy_setopt(FCURL, CURLOPT_URL, pchar(FGateURL));
assert(code = CURLE_OK, 'curl_easy_setopt(CURLOPT_URL) fault');
code := curl_easy_setopt(FCURL, CURLOPT_WRITEFUNCTION, @write_data);
assert(code = CURLE_OK, 'curl_easy_setopt(CURLOPT_WRITEFUNCTION) fault');
code := curl_easy_setopt(FCURL, CURLOPT_WRITEDATA, Pointer(Self));
assert(code = CURLE_OK, 'curl_easy_setopt(CURLOPT_WRITEDATA) fault');
code := curl_easy_setopt(FCURL, CURLOPT_POST, 1);
assert(code = CURLE_OK, 'curl_easy_setopt(CURLOPT_POST) fault');
EncodeRequest(method);
req := FContent.DataString;
FContent.Position := 0;
FContent.Size := 0;
code := curl_easy_setopt(FCURL, CURLOPT_POSTFIELDS, pchar(req));
assert(code = CURLE_OK, 'curl_easy_setopt(CURLOPT_POSTFIELDSIZE) fault');
code := curl_easy_setopt(FCURL, CURLOPT_POSTFIELDSIZE, length(req));
assert(code = CURLE_OK, 'curl_easy_setopt(CURLOPT_POSTFIELDSIZE) fault');
code := curl_easy_perform(FCURL);
Result := code = CURLE_OK;
assert(Result, 'curl_easy_perform() fault');
if Result then
begin
ParseResponse;
end;
end;
Добавлено спустя 3 минуты 7 секунд:Кстати у wget-а вроде тоже есть своя библиотека, можно и её попробовать заюзать, но libcurl кросплатформна. Поэтому если качалка окажется популярной её можно будет и на другие платформы портировать
Добавлено спустя 1 минуту 32 секунды:Забыл линк дать:
http://curl.haxx.se/libcurl/