<div dir="ltr">2013/4/18 Jeppe Græsdal Johansen <span dir="ltr"><<a href="mailto:jeppe@j-software.dk" target="_blank">jeppe@j-software.dk</a>></span><br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


  
    
  
  <div text="#000000" bgcolor="#FFFFFF">
    <div>Den 18-04-2013 07:03, silvioprog skrev:<br>
    </div><div><div class="h5">
    <blockquote 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>Thanks,</div>
        <div>
          <div><br>
          </div>
          -- <br>
          Silvio Clécio<br>
          My public projects - <a href="http://github.com/silvioprog" target="_blank">github.com/silvioprog</a>
        </div>
      </div>
      <br>
    </blockquote></div></div>
    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<div class="im"><br>
          inherited Create(False);<br>
          FreeOnTerminate := True;<br></div>
        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 href="http://silvioprog.com.br/" target="_blank">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></div></blockquote></div><div class="gmail_extra"><br></div>Worked fine, thank you! :)<br clear="all"><div><br></div>-- <br>Silvio Clécio<br>My public projects - <a href="http://github.com/silvioprog" target="_blank">github.com/silvioprog</a>
</div></div>