Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2012-11

A simple HTTP request with FPC standard units

18 messages · 7 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

luciano de souza

Hello listers,
Using Synapse, the developer has very good features to deal with the HTTP protocol. But imagine you want only to do a "get" in a URL and take a string back. I imagine it can be done with the standard units of Freepascal. Is it true? How could I do it with FPC 2.7.1? Best regards,
Luciano

Reply by email

Michael Van Canneyt
to luciano de souza
luciano de souza wrote 5 lines
Hello listers, Using Synapse, the developer has very good features to deal with the HTTP protocol. But imagine you want only to do a "get" in a URL and take a string back. I imagine it can be done with the standard units of Freepascal. Is it true? How could I do it with FPC 2.7.1?

very simple:

uses fphttpclient;
Var
   S : String;
begin
   With TFPHttpClient.Create(Nil) do
     try
       S:=Get(ParamStr(1));
   finally
     Free;
   end;
   Writeln('Got : ',S);
end.

home: >fpc -S2 th.pp
/usr/bin/ld: warning: link.res contains output sections; did you forget -T? home: >th http://www.freepascal.org/
Got : <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html>
<!-- Web Page Design by James Koster - http://www.jameskoster.co.uk and Marko Mihel?i? - http://www.mcville.net-->

<head>

I cut off the rest.

Michael.

Reply by email

Luciano de Souza
to Michael Van Canneyt

Yes, when I ask for a simple way, I could not imagine something so simpler! Thank you. Your tip help me a lot.
The success of your answer is so that I add a question: is there also a FPC native unit dealing with SMTP?

Michael Van Canneyt wrote 45 lines
On Fri, 23 Nov 2012, luciano de souza wrote: > Hello listers, > Using Synapse, the developer has very good features to deal with the > HTTP protocol. But imagine you want only to do a "get" in a URL and > take a string back. I imagine it can be done with the standard units > of Freepascal. Is it true? How could I do it with FPC 2.7.1? very simple: uses fphttpclient; Var S : String; begin With TFPHttpClient.Create(Nil) do try S:=Get(ParamStr(1)); finally Free; end; Writeln('Got : ',S); end. home: >fpc -S2 th.pp /usr/bin/ld: warning: link.res contains output sections; did you forget -T? home: >th http://www.freepascal.org/ Got : <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <!-- Web Page Design by James Koster - http://www.jameskoster.co.uk and Marko Mihel?i? - http://www.mcville.net--> <head> I cut off the rest. Michael. _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

silvioprog
to Michael Van Canneyt: very simple: uses fphttpclient; Var S : String; begin With TFPHttpClient.Create(Nil) do…

GREAT unit, I love Free Pascal!

Two errors, with:

================
program project1;
{$mode objfpc}{$H+}
uses
  fphttpclient;
var
  S: string;
begin
  with TFPHttpClient.Create(nil) do
    try
      S := Get(ParamStr(1));
    finally
      Free;
    end;
  WriteLn('Got : ', S);
end.
================

I got:

================
C:\Users\silvioprog\Desktop\test>project1.exe
An unhandled exception occurred at $004115F1:
EHTTPClient: Invalid protocol : ""
$004115F1
$0041189E
$004118FE
$0040167F main, line 13 of project1.lpr
================

With:

================
program project1;
{$mode objfpc}{$H+}
uses
  fphttpclient;
var
  S: string;
begin
  with TFPHttpClient.Create(nil) do
    try
      S := Get('http://silvioprog.com.br');
    finally
      Free;
    end;
  WriteLn('Got : ', S);
end.
================

I got:

================
C:\Users\silvioprog\Desktop\test>project1.exe
An unhandled exception occurred at $0040FE72:
EAccessViolation: Access violation
$0040FE72
$00410042
$00411576
$004117CE
$0041182E
$0040166D main, line 13 of project1.lpr
================

What I'm is wrong?

My environment:

Lazarus 1.1 r38836 FPC 2.7.1 i386-win32-win32/win64

2012/11/23 Michael Van Canneyt

Show quoted text 41 lines
On Fri, 23 Nov 2012, luciano de souza wrote: Hello listers, > Using Synapse, the developer has very good features to deal with the > HTTP protocol. But imagine you want only to do a "get" in a URL and > take a string back. I imagine it can be done with the standard units > of Freepascal. Is it true? How could I do it with FPC 2.7.1? > very simple: uses fphttpclient; Var S : String; begin With TFPHttpClient.Create(Nil) do try S:=Get(ParamStr(1)); finally Free; end; Writeln('Got : ',S); end. home: >fpc -S2 th.pp /usr/bin/ld: warning: link.res contains output sections; did you forget -T? home: >th http://www.freepascal.org/ Got : <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <!-- Web Page Design by James Koster - http://www.jameskoster.co.uk and Marko Mihel?i? - http://www.mcville.net--> <head> I cut off the rest. Michael.
Silvio Clécio My public projects - github.com/silvioprog

Reply by email

silvioprog
to silvioprog

I solved the error. In:

fphttpclient.pas:line285
Function TFPCustomHTTPClient.GetServerURL(URI : TURI) : String;
Var
  D : String;
begin
  D:=URI.Path;
  If (D[1]'/') then
    D:='/'+D;
  If (D[Length(D)]'/') then
    D:=D+'/';
  Result:=D+URI.Document;
  if (URI.Params'') then
    Result:=Result+'?'+URI.Params;
end;

I changed to:

Function TFPCustomHTTPClient.GetServerURL(URI : TURI) : String;
Var
  D : String;
begin
  D:=URI.Path;
  If Length(D) = 0 then
    D := '/';
  If (D[Length(D)]'/') then
    D:=D+'/';
  Result:=D+URI.Document;
  if (URI.Params'') then
    Result:=Result+'?'+URI.Params;
end;

And worked fine:

==============
C:\Users\silvioprog\Desktop\test>project1.exe
Got : <!DOCTYPE html>
<!--[if lt IE 7 ]> <html lang="pt-br" class="no-js ie6"> <![endif]--> <!--[if IE 7 ]> <html lang="pt-br" class="no-js ie7"> <![endif]--> <!--[if IE 8 ]> <html lang="pt-br" class="no-js ie8"> <![endif]--> <!--[if IE 9 ]> <html lang="pt-br" class="no-js ie9"> <![endif]--> <!--[if (gt IE 9)|!(IE)]><!--><html lang="pt-br"
class="no-js"><!--<![endif]-->
<html>
<head>
<!--[if ie]><meta http-equiv="X-UA-Compatible"
content="IE=edge,chrome=1"><![end
if]-->
<title>silvioprog.com.br - Home</title>
<meta charset="UTF-8">
<meta name="author" content="Silvio Clecio - ">
<meta name="keywords" content="silvioprog, lazarus, freepascal, fpweb, cgi, laza
rus cgi, css, ajax, javascript, dom, desenvolvimento web, padroes web, internet
movel, mobilidade, microformats, xhtml, html5">
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content="Bem-vindo ao espaço do desenvolvedor livre!">

<meta name="generator" content="LazSolutions">
<link rel="author" href="humans.txt" type="text/plain"> <link rel="shortcut icon" href="favicon.ico">
<link rel="apple-touch-icon" href="apple-touch-icon.png"> <link rel="shortlink" href="http://tinyurl.com/silvioprog"> <!--<link rel="stylesheet" href="css/style.css">--> <!--[if lt IE 8]><script src="js/ie6update.js"></script><![endif]--> <!--<script src="js/jquery.min.js"></script>-->
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-17508381-4']);
  _gaq.push(['_setDomainName', '.com.br']);
  _gaq.push(['_trackPageview']);
  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript';

ga.a
sync = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : ' http://w
ww') + '.google-analytics.com/ga.js';

    var s = document.getElementsByTagName('script')[0];

s.parentNode.insertBefor
e(ga, s);

  })();

</script>
<style>
body { text-align: center;}
h1 { font-size: 50px; text-align: center }
span[frown] { transform: rotate(90deg); display:inline-block; color: #bbb; }
body { font: 20px Constantia, 'Hoefler Text', "Adobe Caslon Pro", Baskerville
, Georgia, Times, serif; color: #999; text-shadow: 2px 2px 2px rgba(200, 200, 20
0, 0.5); }
::-moz-selection{ background:#FF5E99; color:#fff; } ::selection { background:#FF5E99; color:#fff; }
article {display:block; text-align: left; width: 500px; margin: 0 auto; }

a { color: rgb(36, 109, 56); text-decoration:none; } a:hover { color: rgb(96, 73, 141) ; text-shadow: 2px 2px 2px rgba(36, 109, 56,
0.5); }
</style>
</head>
<body>
<article>
<h1>silvioprog.com.br</h1>
<div>
<p>Olá, caro visitante,</p>
<p>Estamos importando todo o material do programmer ObjectPascal para e
ste novo espaço, aguarde.</p>
<ul>
</ul>
</div>

</article>
</body>
</html>
==============

I'll open an issue in bugtracker, please wait me...

2012/11/23 silvioprog

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

Silvio Clécio
My public projects - github.com/silvioprog

Reply by email

silvioprog
to silvioprog

Done:

http://bugs.freepascal.org/view.php?id=23372

2012/11/23 silvioprog

Show quoted text 258 lines
I solved the error. In: fphttpclient.pas:line285 Function TFPCustomHTTPClient.GetServerURL(URI : TURI) : String; Var D : String; begin D:=URI.Path; If (D[1]'/') then D:='/'+D; If (D[Length(D)]'/') then D:=D+'/'; Result:=D+URI.Document; if (URI.Params'') then Result:=Result+'?'+URI.Params; end; I changed to: Function TFPCustomHTTPClient.GetServerURL(URI : TURI) : String; Var D : String; begin D:=URI.Path; If Length(D) = 0 then D := '/'; If (D[Length(D)]'/') then D:=D+'/'; Result:=D+URI.Document; if (URI.Params'') then Result:=Result+'?'+URI.Params; end; And worked fine: ============== C:\Users\silvioprog\Desktop\test>project1.exe Got : <!DOCTYPE html> <!--[if lt IE 7 ]> <html lang="pt-br" class="no-js ie6"> <![endif]--> <!--[if IE 7 ]> <html lang="pt-br" class="no-js ie7"> <![endif]--> <!--[if IE 8 ]> <html lang="pt-br" class="no-js ie8"> <![endif]--> <!--[if IE 9 ]> <html lang="pt-br" class="no-js ie9"> <![endif]--> <!--[if (gt IE 9)|!(IE)]><!--><html lang="pt-br" class="no-js"><!--<![endif]--> <html> <head> <!--[if ie]><meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"><![end if]--> <title>silvioprog.com.br - Home</title> <meta charset="UTF-8"> <meta name="author" content="Silvio Clecio - "> <meta name="keywords" content="silvioprog, lazarus, freepascal, fpweb, cgi, laza rus cgi, css, ajax, javascript, dom, desenvolvimento web, padroes web, internet movel, mobilidade, microformats, xhtml, html5"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="description" content="Bem-vindo ao espaço do desenvolvedor livre!"> <meta name="generator" content="LazSolutions"> <link rel="author" href="humans.txt" type="text/plain"> <link rel="shortcut icon" href="favicon.ico"> <link rel="apple-touch-icon" href="apple-touch-icon.png"> <link rel="shortlink" href="http://tinyurl.com/silvioprog"> <!--<link rel="stylesheet" href="css/style.css">--> <!--[if lt IE 8]><script src="js/ie6update.js"></script><![endif]--> <!--<script src="js/jquery.min.js"></script>--> <script type="text/javascript"> var _gaq = _gaq || []; _gaq.push(['_setAccount', 'UA-17508381-4']); _gaq.push(['_setDomainName', '.com.br']); _gaq.push(['_trackPageview']); (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.a sync = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : ' http://w ww') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefor e(ga, s); })(); </script> <style> body { text-align: center;} h1 { font-size: 50px; text-align: center } span[frown] { transform: rotate(90deg); display:inline-block; color: #bbb; } body { font: 20px Constantia, 'Hoefler Text', "Adobe Caslon Pro", Baskerville , Georgia, Times, serif; color: #999; text-shadow: 2px 2px 2px rgba(200, 200, 20 0, 0.5); } ::-moz-selection{ background:#FF5E99; color:#fff; } ::selection { background:#FF5E99; color:#fff; } article {display:block; text-align: left; width: 500px; margin: 0 auto; } a { color: rgb(36, 109, 56); text-decoration:none; } a:hover { color: rgb(96, 73, 141) ; text-shadow: 2px 2px 2px rgba(36, 109, 56, 0.5); } </style> </head> <body> <article> <h1>silvioprog.com.br</h1> <div> <p>Olá, caro visitante,</p> <p>Estamos importando todo o material do programmer ObjectPascal para e ste novo espaço, aguarde.</p> <ul> </ul> </div> </article> </body> </html> ============== I'll open an issue in bugtracker, please wait me... 2012/11/23 silvioprog > GREAT unit, I love Free Pascal! > > Two errors, with: > > ================ > program project1; > > {$mode objfpc}{$H+} > > uses > fphttpclient; > > var > S: string; > begin > with TFPHttpClient.Create(nil) do > try > S := Get(ParamStr(1)); > finally > Free; > end; > WriteLn('Got : ', S); > end. > ================ > > I got: > > ================ > C:\Users\silvioprog\Desktop\test>project1.exe > An unhandled exception occurred at $004115F1: > EHTTPClient: Invalid protocol : "" > $004115F1 > $0041189E > $004118FE > $0040167F main, line 13 of project1.lpr > ================ > > With: > > ================ > program project1; > > {$mode objfpc}{$H+} > > uses > fphttpclient; > > var > S: string; > begin > with TFPHttpClient.Create(nil) do > try > S := Get('http://silvioprog.com.br'); > finally > Free; > end; > WriteLn('Got : ', S); > end. > ================ > > I got: > > ================ > C:\Users\silvioprog\Desktop\test>project1.exe > An unhandled exception occurred at $0040FE72: > EAccessViolation: Access violation > $0040FE72 > $00410042 > $00411576 > $004117CE > $0041182E > $0040166D main, line 13 of project1.lpr > ================ > > What I'm is wrong? > > My environment: > > Lazarus 1.1 r38836 FPC 2.7.1 i386-win32-win32/win64 > > > 2012/11/23 Michael Van Canneyt > >> >> >> On Fri, 23 Nov 2012, luciano de souza wrote: >> >> Hello listers, >>> Using Synapse, the developer has very good features to deal with the >>> HTTP protocol. But imagine you want only to do a "get" in a URL and >>> take a string back. I imagine it can be done with the standard units >>> of Freepascal. Is it true? How could I do it with FPC 2.7.1? >>> >> >> very simple: >> >> uses fphttpclient; >> >> Var >> S : String; >> >> begin >> With TFPHttpClient.Create(Nil) do >> try >> S:=Get(ParamStr(1)); >> finally >> Free; >> end; >> Writeln('Got : ',S); >> end. >> >> home: >fpc -S2 th.pp >> /usr/bin/ld: warning: link.res contains output sections; did you forget >> -T? >> home: >th http://www.freepascal.org/ >> Got : <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> >> <html> >> <!-- Web Page Design by James Koster - http://www.jameskoster.co.uk and Marko Mihel?i? - >> http://www.mcville.net--> >> >> <head> >> >> I cut off the rest. >> >> Michael. > > --

Silvio Clécio
My public projects - github.com/silvioprog

Reply by email

Leonardo M. Ramé
to silvioprog
Show quoted text 41 lines
________________________________ From: silvioprog To: FPC-Pascal users discussions Sent: Friday, November 23, 2012 2:38 PM Subject: Re: [fpc-pascal] A simple HTTP request with FPC standard units Done: http://bugs.freepascal.org/view.php?id=23372 2012/11/23 silvioprog I solved the error. In: > > >fphttpclient.pas:line285 > >Function TFPCustomHTTPClient.GetServerURL(URI : TURI) : String; > > >Var >  D : String; > > >begin >  D:=URI.Path; >  If (D[1]'/') then >    D:='/'+D; >  If (D[Length(D)]'/') then >    D:=D+'/'; >  Result:=D+URI.Document; >  if (URI.Params'') then >    Result:=Result+'?'+URI.Params; >end; > >

The code needed to execute the function could be even smaller if this is changed to a class function. Instead of needing to create an instance, then using, then freeing, the whole thing could something like this:

...
begin
  s := TFPCustomHTTPClient.GetServerURL('http://a_site/a_page');
  writeln(s);
end;

Reply by email

Michael Van Canneyt
to Leonardo M. Ramé
Leonardo M. Ramé wrote 50 lines
> ________________________________ > From: silvioprog > To: FPC-Pascal users discussions > Sent: Friday, November 23, 2012 2:38 PM > Subject: Re: [fpc-pascal] A simple HTTP request with FPC standard units > > > Done: > > > http://bugs.freepascal.org/view.php?id=23372 > > > > > 2012/11/23 silvioprog > > I solved the error. In: >> >> >> fphttpclient.pas:line285 >> >> Function TFPCustomHTTPClient.GetServerURL(URI : TURI) : String; >> >> >> Var >>   D : String; >> >> >> begin >>   D:=URI.Path; >>   If (D[1]'/') then >>     D:='/'+D; >>   If (D[Length(D)]'/') then >>     D:=D+'/'; >>   Result:=D+URI.Document; >>   if (URI.Params'') then >>     Result:=Result+'?'+URI.Params; >> end; >> >> The code needed to execute the function could be even smaller if this is changed to a class function. Instead of needing to create an instance, then using, then freeing, the whole thing could something like this: ... begin   s := TFPCustomHTTPClient.GetServerURL('http://a_site/a_page');   writeln(s);
You mean probably
   s := TFPCustomHTTPClient.Get('http://a_site/a_page');

It could be done, but it will need to create an instance anyway. Although I suspect such a simple case is a minority.

Michael.

Reply by email

Leonardo M. Ramé
to Michael Van Canneyt

----- Original Message -----

Show quoted text 74 lines
From: Michael Van Canneyt To: FPC-Pascal users discussions Cc: Sent: Friday, November 23, 2012 5:07 PM Subject: Re: [fpc-pascal] A simple HTTP request with FPC standard units On Fri, 23 Nov 2012, Leonardo M. Ramé wrote: > > >> ________________________________ >> From: silvioprog >> To: FPC-Pascal users discussions >> Sent: Friday, November 23, 2012 2:38 PM >> Subject: Re: [fpc-pascal] A simple HTTP request with FPC standard units >> >> >> Done: >> >> >> http://bugs.freepascal.org/view.php?id=23372 >> >> >> >> >> 2012/11/23 silvioprog >> >> I solved the error. In: >>> >>> >>> fphttpclient.pas:line285 >>> >>> Function TFPCustomHTTPClient.GetServerURL(URI : TURI) : String; >>> >>> >>> Var >>>   D : String; >>> >>> >>> begin >>>   D:=URI.Path; >>>   If (D[1]'/') then >>>     D:='/'+D; >>>   If (D[Length(D)]'/') then >>>     D:=D+'/'; >>>   Result:=D+URI.Document; >>>   if (URI.Params'') then >>>     Result:=Result+'?'+URI.Params; >>> end; >>> >>> > > The code needed to execute the function could be even smaller if this is changed to a class function. Instead of needing to create an instance, then using, then freeing, the whole thing could something like this: > > ... > begin >   s := TFPCustomHTTPClient.GetServerURL('http://a_site/a_page'); >   writeln(s); You mean probably   s := TFPCustomHTTPClient.Get('http://a_site/a_page'); It could be done, but it will need to create an instance anyway. Although I suspect such a simple case is a minority. Michael. _______________________________________________ fpc-pascal maillist  -  http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Yes, I said this because the original poster wrote he needed the very little code to accomplish this.

 
Leonardo M. Ramé
http://leonardorame.blogspot.com

Reply by email

Michael Van Canneyt
to Leonardo M. Ramé
Leonardo M. Ramé wrote 13 lines
> You mean probably >   s := TFPCustomHTTPClient.Get('http://a_site/a_page'); > > It could be done, but it will need to create an instance anyway. > Although I suspect such a simple case is a minority. > > Michael. > _______________________________________________ > fpc-pascal maillist  -  > http://lists.freepascal.org/mailman/listinfo/fpc-pascal Yes, I said this because the original poster wrote he needed the very little code to accomplish this.

I implemented the class methods for all forms of Get/Post/Formpost, so now you can do:

s := TFPCustomHTTPClient.SimpleGet('http://a_site/a_page');

You can't get more simple than that.

Michael.

Reply by email

luciano de souza
to Michael Van Canneyt

Among its hundreds of units, the Freepascal always keeps surprises for us. FPHTTPClient was a pleasant surprise.
The talk has followed freely and perhaps my question has been skipped: is there Freepascal native routines to deal with SMTP protocol? In other words, is there a native way to send an e-mail with Freepascal?

2012/11/23, Michael Van Canneyt :

Show quoted text 27 lines
On Fri, 23 Nov 2012, Leonardo M. Ramé wrote: >> You mean probably >> s := TFPCustomHTTPClient.Get('http://a_site/a_page'); >> >> It could be done, but it will need to create an instance anyway. >> Although I suspect such a simple case is a minority. >> >> Michael. >> _______________________________________________ >> fpc-pascal maillist - >> http://lists.freepascal.org/mailman/listinfo/fpc-pascal > > > Yes, I said this because the original poster wrote he needed the very > little code to accomplish this. I implemented the class methods for all forms of Get/Post/Formpost, so now you can do: s := TFPCustomHTTPClient.SimpleGet('http://a_site/a_page'); You can't get more simple than that. Michael.
Luciano de Souza

Reply by email

Paul Breneman
to luciano de souza
luciano de souza wrote 5 lines
Among its hundreds of units, the Freepascal always keeps surprises for us. FPHTTPClient was a pleasant surprise. The talk has followed freely and perhaps my question has been skipped: is there Freepascal native routines to deal with SMTP protocol? In other words, is there a native way to send an e-mail with Freepascal?

Here is the most simple way I know of (but I'd be glad to learn of a more simple way):
http://www.turbocontrol.com/easyemail.htm

Regards, Paul Breneman www.dbReplication.com - VCL database replication components www.TurboControl.com - Hardware and software development services - Educational programming project for environment monitoring - Information on using FreePascal for embedded systems - Support information for the TurboPower open source libraries

Reply by email

silvioprog
to Michael Van Canneyt: very simple: uses fphttpclient; Var S : String; begin With TFPHttpClient.Create(Nil) do…

2012/11/23 Michael Van Canneyt

Show quoted text 41 lines
On Fri, 23 Nov 2012, luciano de souza wrote: Hello listers, > Using Synapse, the developer has very good features to deal with the > HTTP protocol. But imagine you want only to do a "get" in a URL and > take a string back. I imagine it can be done with the standard units > of Freepascal. Is it true? How could I do it with FPC 2.7.1? > very simple: uses fphttpclient; Var S : String; begin With TFPHttpClient.Create(Nil) do try S:=Get(ParamStr(1)); finally Free; end; Writeln('Got : ',S); end. home: >fpc -S2 th.pp /usr/bin/ld: warning: link.res contains output sections; did you forget -T? home: >th http://www.freepascal.org/ Got : <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <!-- Web Page Design by James Koster - http://www.jameskoster.co.uk and Marko Mihel?i? - http://www.mcville.net--> <head> I cut off the rest. Michael.

Really TFPHttpClient is a pleasant class. Now I updated EasyRSS plugin for use it.

Thank you again Michael! :)

Silvio Clécio My public projects - github.com/silvioprog

Reply by email

Michael Van Canneyt
to luciano de souza: Among its hundreds of units, the Freepascal always keeps surprises for us. FPHTTPClient…
luciano de souza wrote 5 lines
Among its hundreds of units, the Freepascal always keeps surprises for us. FPHTTPClient was a pleasant surprise. The talk has followed freely and perhaps my question has been skipped: is there Freepascal native routines to deal with SMTP protocol? In other words, is there a native way to send an e-mail with Freepascal?

There are no FPC-provided native freepascal routines for this, but I see Paul Breneman has provided an alternative.

Contributions are welcome.
It is mostly lack of time that keeps us from implementing these things. As far as I know, SMTP is a fairly simple protocol, probably it is not too hard to implement.

Michael.

Show quoted text 38 lines
2012/11/23, Michael Van Canneyt : > > > On Fri, 23 Nov 2012, Leonardo M. Ramé wrote: > >>> You mean probably >>> s := TFPCustomHTTPClient.Get('http://a_site/a_page'); >>> >>> It could be done, but it will need to create an instance anyway. >>> Although I suspect such a simple case is a minority. >>> >>> Michael. >>> _______________________________________________ >>> fpc-pascal maillist - >>> http://lists.freepascal.org/mailman/listinfo/fpc-pascal >> >> >> Yes, I said this because the original poster wrote he needed the very >> little code to accomplish this. > > I implemented the class methods for all forms of Get/Post/Formpost, so now > you can do: > > s := TFPCustomHTTPClient.SimpleGet('http://a_site/a_page'); > > You can't get more simple than that. > > Michael. -- Luciano de Souza _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

Luciano de Souza
to Michael Van Canneyt

Unfortunately, I don't have enough knowledlge even to start a task like that. But observing the firm journey of Freepascal, I am sure we will have it soon.

Michael Van Canneyt wrote 64 lines
On Fri, 23 Nov 2012, luciano de souza wrote: > Among its hundreds of units, the Freepascal always keeps surprises for > us. FPHTTPClient was a pleasant surprise. > The talk has followed freely and perhaps my question has been skipped: > is there Freepascal native routines to deal with SMTP protocol? In > other words, is there a native way to send an e-mail with Freepascal? There are no FPC-provided native freepascal routines for this, but I see Paul Breneman has provided an alternative. Contributions are welcome. It is mostly lack of time that keeps us from implementing these things. As far as I know, SMTP is a fairly simple protocol, probably it is not too hard to implement. Michael. > > > 2012/11/23, Michael Van Canneyt : >> >> >> On Fri, 23 Nov 2012, Leonardo M. Ramé wrote: >> >>>> You mean probably >>>> s := TFPCustomHTTPClient.Get('http://a_site/a_page'); >>>> >>>> It could be done, but it will need to create an instance anyway. >>>> Although I suspect such a simple case is a minority. >>>> >>>> Michael. >>>> _______________________________________________ >>>> fpc-pascal maillist - >>>> http://lists.freepascal.org/mailman/listinfo/fpc-pascal >>> >>> >>> Yes, I said this because the original poster wrote he needed the very >>> little code to accomplish this. >> >> I implemented the class methods for all forms of Get/Post/Formpost, >> so now >> you can do: >> >> s := TFPCustomHTTPClient.SimpleGet('http://a_site/a_page'); >> >> You can't get more simple than that. >> >> Michael. > > > -- > Luciano de Souza > _______________________________________________ > fpc-pascal maillist - > http://lists.freepascal.org/mailman/listinfo/fpc-pascal > _______________________________________________ fpc-pascal maillist - http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply by email

silvioprog
to Luciano de Souza

2012/11/24 Luciano de Souza

Show quoted text 25 lines
** Unfortunately, I don't have enough knowledlge even to start a task like that. But observing the firm journey of Freepascal, I am sure we will have it soon. Em 24-11-2012 06:52, Michael Van Canneyt escreveu: On Fri, 23 Nov 2012, luciano de souza wrote: Among its hundreds of units, the Freepascal always keeps surprises for us. FPHTTPClient was a pleasant surprise. The talk has followed freely and perhaps my question has been skipped: is there Freepascal native routines to deal with SMTP protocol? In other words, is there a native way to send an e-mail with Freepascal? There are no FPC-provided native freepascal routines for this, but I see Paul Breneman has provided an alternative. Contributions are welcome. It is mostly lack of time that keeps us from implementing these things. As far as I know, SMTP is a fairly simple protocol, probably it is not too hard to implement. Michael. Good afternoon guys.

I have some experience with the SMTP protocol. Reading the RFC, I can understand better its requirements and I will able to implement a TFPSMTPClient. What do you think about?

Silvio Clécio My public projects - github.com/silvioprog

Reply by email

Reinier Olislagers
to silvioprog
silvioprog wrote 16 lines
2012/11/24 Luciano de Souza < > > Contributions are welcome. It is mostly lack of time that keeps us > from implementing these things. > As far as I know, SMTP is a fairly simple protocol, probably it is > not too hard to implement. > > Michael. Good afternoon guys. I have some experience with the SMTP protocol. Reading the RFC, I can understand better its requirements and I will able to implement a TFPSMTPClient. What do you think about?

Nice idea ;)

AFAIR, the Synapse demo/contributed applications on their web/FTP site also has SMTP examples, which might be useful in taking inspiration from.

Reply by email

Tomas Hajny
to Reinier Olislagers
Reinier Olislagers wrote 7 lines
On 24-11-2012 17:30, silvioprog wrote: > 2012/11/24 Luciano de Souza >> >> Contributions are welcome. It is mostly lack of time that keeps us >> from implementing these things. >> As far as I know, SMTP is a fairly simple protocol, probably it is >> not too hard to implement.

.
.

Show quoted text 9 lines
> > I have some experience with the SMTP protocol. Reading the RFC, I can > understand better its requirements and I will able to implement a > TFPSMTPClient. What do you think about? > Nice idea ;) AFAIR, the Synapse demo/contributed applications on their web/FTP site also has SMTP examples, which might be useful in taking inspiration from.

As far as I know, lnet (available as an independent project in FPC svn repository - http://svn.freepascal.org/svn/fpcprojects/lnet/) also includes SMTP support.

Tomas

Reply by email