<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Den 18-04-2013 07:03, silvioprog skrev:<br>
</div>
<blockquote
cite="mid:CAKq_V2J=DizQnZVAW-bVa+pgASoOeiGwnj_J=q7ZhT+QVsKCnw@mail.gmail.com"
type="cite">
<div dir="ltr">Hi,
<div><br>
</div>
<div>I tried to use TThread in a small sample, but it don't
works. The code is very simple, and I'm sending it in
attached.</div>
<div><br>
</div>
<div style="">Thanks,</div>
<div>
<div><br>
</div>
-- <br>
Silvio Clécio<br>
My public projects - <a moz-do-not-send="true"
href="http://github.com/silvioprog" target="_blank">github.com/silvioprog</a>
</div>
</div>
<br>
</blockquote>
Here's a version which I think should work everywhere. I think there
might be a bug in the fphttpclient code. If you don't pass the / at
the end of the URI it will crash inside the getserverurl function.<br>
<br>
<tt>program project1;<br>
<br>
{$mode objfpc}{$H+}<br>
<br>
uses<br>
{$IFDEF UNIX}{$IFDEF UseCThreads}<br>
cthreads,<br>
{$ENDIF}{$ENDIF}<br>
Classes,<br>
FPHTTPClient;<br>
<br>
type<br>
<br>
{ THTTPClientThread }<br>
<br>
THTTPClientThread = class(TThread)<br>
protected<br>
procedure Execute; override;<br>
public<br>
constructor Create;<br>
end;<br>
<br>
{ THTTPClientThread }<br>
<br>
constructor THTTPClientThread.Create;<br>
begin<br>
inherited Create(False);<br>
FreeOnTerminate := True;<br>
end;<br>
<br>
procedure THTTPClientThread.Execute;<br>
var<br>
VResult: TStringList;<br>
VHttp: TFPHTTPClient;<br>
begin<br>
VHttp := TFPHTTPClient.Create(nil);<br>
VResult := TStringList.Create;<br>
try<br>
VHttp.Get('<a class="moz-txt-link-freetext" href="http://silvioprog.com.br/">http://silvioprog.com.br/</a>', VResult);<br>
VResult.SaveToFile('OUT.TXT')<br>
finally<br>
VResult.Free;<br>
VHttp.Free;<br>
end;<br>
end;<br>
<br>
var Thread: THTTPClientThread;<br>
begin<br>
Thread := THTTPClientThread.Create;<br>
Thread.WaitFor;<br>
end.</tt><br>
</body>
</html>