[Lazarus] Get binary (byte by byte) from a HTTP host
José Mejuto
joshyfun at gmail.com
Tue Jan 18 10:41:38 CET 2011
Hello Lazarus-List,
Tuesday, January 18, 2011, 4:13:13 AM, you wrote:
s> Not works, Document property always is empty in OnMonitor event. x(
You can not access Document from OnMonitor, you can only access Socked
properties/status.
Synapse is blocking, so :
1) HTTPSend prepare headers.
2) HTTPSend GET
3) HTTPSend access document.
Or in your code:
------------------------------------------------------
procedure TMainForm.StartButtonClick(Sender: TObject);
begin
if FileExistsUTF8(CFile) then
FFileStream := TFileStream.Create(CFile, fmOpenReadWrite)
else
FFileStream := TFileStream.Create(CFile, fmCreate);
try
FHTTPSend.Sock.MaxRecvBandwidth := 50;
FHTTPSend.Clear;
FHTTPSend.RangeEnd := FFileStream.Size;
FFileStream.Position := FFileStream.Size;
FHTTPSend.HTTPMethod('GET', CURL);
//Now you can acess Document
FFileStream.CopyFrom(FHTTPSend.Document, FHTTPSend.Document.Size);
finally
FFileStream.Free;
end;
end;
procedure TMainForm.OnMonitor(Sender: TObject; Writing: Boolean;
const Buffer: Pointer; Len: Integer);
begin
//Nothing...
//FHHTPSend information at this point is undefined.
end;
--------------------------------------------------------
s> Hm..., I think isn't possible resume download with Synapse, I tryed all but
s> without sucess.
What's the problem ? Paste headers sent and received headers. Resuming
is not supported by all web servers.
--
Best regards,
José
More information about the Lazarus
mailing list