[fpc-pascal] A simple HTTP request with FPC standard units

Leonardo M. Ramé martinrame at yahoo.com
Fri Nov 23 21:14:44 CET 2012



----- Original Message -----
> From: Michael Van Canneyt <michael at freepascal.org>
> To: FPC-Pascal users discussions <fpc-pascal at lists.freepascal.org>
> 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 <silvioprog at gmail.com>
>>>  To: FPC-Pascal users discussions 
> <fpc-pascal at lists.freepascal.org> 
>>>  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 <silvioprog at gmail.com>
>>> 
>>>  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  -  fpc-pascal at lists.freepascal.org
> 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




More information about the fpc-pascal mailing list