Installed RadSudio 10.1 Berlin.
First encountered with Indy. I can not understand what is wrong.
Does not want to work out the code.
All on an event on one button hung up for check of work with components.
You get an error in both versions:
Project Project1.exe raised exception class EIdUnknownProtocol with message 'Unknown Protocol'
IdTCPClient1.Connect; - passes without errors.
Get gives an error to any site. What's wrong?
The first variation without special settings:
procedure TForm1.Button1Click(Sender: TObject); var IdTCPClient1 : TIdTCPClient; IdHTTP1 : TIdHTTP; IdCookieManager1 : TIdCookieManager; begin IdTCPClient1 := TIdTCPClient.Create(nil); IdHTTP1 := TIdHTTP.Create(IdTCPClient1); IdCookieManager1 := TIdCookieManager.Create(IdTCPClient1); //---- //Настраиваем компонент. IdHTTP1.HandleRedirects := True; IdHTTP1.AllowCookies := True; IdTCPClient1.Port := 80; IdTCPClient1.Host := 'mail.ru'; //---- try IdTCPClient1.Connect; Memo1.Text := IdHTTP1.Get(IdTCPClient1.Host); finally IdTCPClient1.Disconnect; IdCookieManager1.Free; IdHTTP1.Free; IdTCPClient1.Free; end; end; The second option - the same error crashes:
procedure TForm1.Button1Click(Sender: TObject); var IdTCPClient1 : TIdTCPClient; IdHTTP1 : TIdHTTP; IdCookieManager1 : TIdCookieManager; begin IdTCPClient1 := TIdTCPClient.Create(nil); IdHTTP1 := TIdHTTP.Create(IdTCPClient1); IdCookieManager1 := TIdCookieManager.Create(IdTCPClient1); //---- //Настраиваем компонент. IdHTTP1.HandleRedirects := True; IdHTTP1.AllowCookies := True; IdHTTP1.Request.UserAgent := 'Mozilla/5.0 (Windows NT 5.1) AppleWebKit/537.22 (KHTML, like Gecko) Chrome/25.0.1364.97 Safari/537.22'; IdHTTP1.Request.Accept := 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'; IdHTTP1.Request.AcceptLanguage := 'ru-RU,ru;q=0.8,en-US;q=0.6,en;q=0.4'; IdHTTP1.Request.AcceptCharSet := 'windows-1251,utf-8;q=0.7,*;q=0.3'; IdTCPClient1.Port := 80; IdTCPClient1.Host := 'mail.ru'; //---- try IdTCPClient1.Connect; Memo1.Text := IdHTTP1.Get(IdTCPClient1.Host); finally IdTCPClient1.Disconnect; IdCookieManager1.Free; IdHTTP1.Free; IdTCPClient1.Free; end; end; When I put ' http://mail.ru ' - then already on IdTCPClient1.Connect; the error takes off:
Project Project1.exe raised exception class EIdSocketError with message 'Socket Error # 11001 Host not found.