[fpc-devel] Indy IdHTTP

ABorka fpc-devel at aborka.com
Sun May 24 04:32:26 CEST 2009


Hi,

I came across some strange thing while making a simple program using 
Indy 10.

If I use an IdHTTP object to load a web page that redirects to another 
one, the new destination URL is not passed properly through the event 
handler.
Whether this is an indy or fpc problem, I'm not sure.

Here is the event handler in a way that it should work:

Declaration in Indy:
   TIdHTTPOnRedirectEvent = procedure(Sender: TObject; var dest: string; 
var NumRedirect: Integer; var Handled: boolean; var VMethod: 
TIdHTTPMethod) of object;

In FPC/Lazarus:
procedure TForm1.IdHTTP1Redirect(Sender: TObject; var dest: String;  var 
NumRedirect: Integer; var Handled: Boolean;  var VMethod: IdHTTPMethod);
begin
   ShowMessage('Redirected to:' + dest);
end;


However, it seems that the parameter "dest" is passing a pointer to a 
pointer and not just a pointer to the string (displaying only some 
strange characters instead of the redirecting URL).

Therefore, the following works properly (while it should not):

procedure TForm1.IdHTTP1Redirect(Sender: TObject; var dest: String;  var 
NumRedirect: Integer; var Handled: Boolean;  var VMethod: IdHTTPMethod);
var p:pchar;
begin
   asm
     pushad
     lea esi, dest
     mov eax, [esi]
     mov eax, [eax]
     mov p, eax
     popad
   end;
   ShowMessage('Redirected to:' + p);{dest}
end;

Am I missing something or there is a problem somewhere?
Indy and FPC both was compiled from the latest source available (as well 
as Lazarus)

Thanks for any thoughts,

AB

PS: I did not post this on the indy support forums because it seems that 
there are no questions answered (or even posted) in the past two years 
there (the latest indy source is form 2007 Nov).




More information about the fpc-devel mailing list