GREAT unit, I love Free Pascal!<div><br></div><div>Two errors, with:</div><div><br></div><div>================</div><div><div>program project1;</div><div><br></div><div>{$mode objfpc}{$H+}</div><div><br></div><div>uses</div>
<div> fphttpclient;</div><div><br></div><div>var</div><div> S: string;</div><div>begin</div><div> with TFPHttpClient.Create(nil) do</div><div> try</div><div> S := Get(ParamStr(1));</div><div> finally</div><div>
Free;</div><div> end;</div><div> WriteLn('Got : ', S);</div><div>end.</div><div class="gmail_extra">================</div><div class="gmail_extra"><br></div><div class="gmail_extra">I got:</div><div class="gmail_extra">
<br></div><div class="gmail_extra">================</div><div class="gmail_extra"><div class="gmail_extra">C:\Users\silvioprog\Desktop\test>project1.exe<br></div><div class="gmail_extra">An unhandled exception occurred at $004115F1:</div>
<div class="gmail_extra">EHTTPClient: Invalid protocol : ""</div><div class="gmail_extra"> $004115F1</div><div class="gmail_extra"> $0041189E</div><div class="gmail_extra"> $004118FE</div><div class="gmail_extra">
$0040167F main, line 13 of project1.lpr</div></div><div class="gmail_extra">================</div><div class="gmail_extra"><br></div><div class="gmail_extra">With:</div><div class="gmail_extra"><br></div><div class="gmail_extra">
================</div><div class="gmail_extra"><div class="gmail_extra">program project1;</div><div class="gmail_extra"><br></div><div class="gmail_extra">{$mode objfpc}{$H+}</div><div class="gmail_extra"><br></div><div class="gmail_extra">
uses</div><div class="gmail_extra"> fphttpclient;</div><div class="gmail_extra"><br></div><div class="gmail_extra">var</div><div class="gmail_extra"> S: string;</div><div class="gmail_extra">begin</div><div class="gmail_extra">
with TFPHttpClient.Create(nil) do</div><div class="gmail_extra"> try</div><div class="gmail_extra"> S := Get('<a href="http://silvioprog.com.br">http://silvioprog.com.br</a>');</div><div class="gmail_extra">
finally</div><div class="gmail_extra"> Free;</div><div class="gmail_extra"> end;</div><div class="gmail_extra"> WriteLn('Got : ', S);</div><div class="gmail_extra">end.</div></div><div class="gmail_extra">
================</div><div class="gmail_extra"><br></div><div class="gmail_extra">I got:</div><div class="gmail_extra"><br></div><div class="gmail_extra">================</div><div class="gmail_extra"><div class="gmail_extra">
C:\Users\silvioprog\Desktop\test>project1.exe<br></div><div class="gmail_extra">An unhandled exception occurred at $0040FE72:</div><div class="gmail_extra">EAccessViolation: Access violation</div><div class="gmail_extra">
$0040FE72</div><div class="gmail_extra"> $00410042</div><div class="gmail_extra"> $00411576</div><div class="gmail_extra"> $004117CE</div><div class="gmail_extra"> $0041182E</div><div class="gmail_extra"> $0040166D main, line 13 of project1.lpr</div>
</div><div class="gmail_extra">================</div><div class="gmail_extra"><br></div><div class="gmail_extra">What I'm is wrong?</div><div class="gmail_extra"><br></div><div class="gmail_extra">My environment:</div>
<div class="gmail_extra"><br></div><div class="gmail_extra">Lazarus 1.1 r38836 FPC 2.7.1 i386-win32-win32/win64<br><br><div class="gmail_quote">2012/11/23 Michael Van Canneyt <span dir="ltr"><<a href="mailto:michael@freepascal.org" target="_blank">michael@freepascal.org</a>></span><br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div class="im"><br>
<br>
On Fri, 23 Nov 2012, luciano de souza wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
Hello listers,<br>
Using Synapse, the developer has very good features to deal with the<br>
HTTP protocol. But imagine you want only to do a "get" in a URL and<br>
take a string back. I imagine it can be done with the standard units<br>
of Freepascal. Is it true? How could I do it with FPC 2.7.1?<br>
</blockquote>
<br></div>
very simple:<br>
<br>
uses fphttpclient;<br>
<br>
Var<br>
S : String;<br>
<br>
begin<br>
With TFPHttpClient.Create(Nil) do<br>
try<br>
S:=Get(ParamStr(1));<br>
finally<br>
Free;<br>
end;<br>
Writeln('Got : ',S);<br>
end.<br>
<br>
home: >fpc -S2 th.pp<br>
/usr/bin/ld: warning: link.res contains output sections; did you forget -T?<br>
home: >th <a href="http://www.freepascal.org/" target="_blank">http://www.freepascal.org/</a><br>
Got : <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><br>
<html><br>
<!-- Web Page Design by James Koster - <a href="http://www.jameskoster.co.uk" target="_blank">http://www.jameskoster.co.uk</a> and Marko Mihel?i? - <a href="http://www.mcville.net--" target="_blank">http://www.mcville.net--</a>><br>
<br>
<head><br>
<br>
I cut off the rest.<span class=""><font color="#888888"><br>
<br>
Michael.</font></span></blockquote></div>-- <br>Silvio Clécio<br>My public projects - <a href="http://github.com/silvioprog" target="_blank">github.com/silvioprog</a><br>
</div></div>