TIdHTTP in Indy 10

I used Indy in Delphi for 6 days, and now I play with Indy 10. What I want to do is incredibly simple, but I don’t see an easy way to do this, so I'm missing something.

I want to do something like this:

Here is the actual code I'm using:

procedure TForm1.btnGetURLClick(Sender: TObject);
begin
  moHeader.Lines.Clear;
  moBody.Lines.Clear;
  try
    moBody.text := IdHttp1.Get(edURL.text);
  finally
  end;
end;   

When the request is complete, http_result must contain the HTML from the specified URL. This does not seem to work, so I feel that perhaps I should use the IOHandler property or the OnWork event for the component, however the use does not seem obvious to me, and I could not find any working examples with Google. I am sure that this is what has been done before, so any help would be appreciated.

: , , : 1. , ( - ?). 2. , . 3. , /os/Indy, . ( ).

, "Connection Closed Gracefully". , . TRY... , . , Indy Get.

, , , : http://screencast.com/t/NDMzNTQ5 , HTML memo.

+2
5

- synapse. , - :

uses
  ...,HTTPSEND;

var
  Result : TStrings;


  if HTTPGetText('http://www.google.com',Result) then
    // do something with result

Synapse - TCPIP. , Delphi 2009/2010. , (OmniThreadLibrary AsyncCalls, ).

+2

, TIdHTTP. HandleRedirects false, " HTTP/1.1 302 "

var
http_result:string;    
Begin
IdHTTP1.HandleRedirects:=True;
http_result := IdHTTP1.Get('http://www.google.com');

End;
+4

HandleRedirects true.

, GExperts . :

var
  IdHTTP: TIdHTTP;

IdHTTP := TIdHTTP.Create(Self);
with IdHTTP do
begin
  Name := 'IdHTTP';
  AllowCookies := True;
  HandleRedirects := True;
  HTTPOptions := [hoForceEncodeParams];
end;

, , .

+2

Iirc, , (onredirect ). indy9 iirc.

0

This question lingers for a while, so I close it. My solution was to just use Synapse, as one of the posters suggested. It runs on Windows / Linux / Mac OS with minimal modifications and works great in libraries / threads.

0
source

Source: https://habr.com/ru/post/1763760/


All Articles