Advertisement

10.10.2006 at 11:46PM PDT, ID: 22020179
[x]
Attachment Details

Indy IdHTTP Component - Error when Calling Get Method for Https URL

Asked by davidwc in Delphi Programming

Tags: indy, idhttp

I'm trying to automate the task of downloading a file from a https web site.  I'm just starting out and using the Indy IdHTTP component to try to send a Get request to the URL.  My problem is that I get the following error:

"An existing connection was forcibly closed by the remote host" when the Get method is called.  I've done a considerable amount of research on the web in the process of getting to this point and have taken into account the following factors:

Setting the Linger Socket Option
Assigning a IdSSLIOHandlerSocketBase to the IdHTTP.IOHandler
Downloading the required SSL dll's and saving them into my application root directory

The relevant parts of my code are below:

It is the ReturnedPage:= https.Get(URL); line that generates the error.
................................


  TMyIdSSLIOHandlerSocketBase = class(TIdSSLIOHandlerSocketBase)
  protected
    FLinger: Boolean;
    procedure DoAfterBind; override;
    procedure SetLinger(Value: Boolean);
    procedure SetLingerOpt;
  public
    property Linger: Boolean read FLinger write SetLinger;
    function Clone :  TIdSSLIOHandlerSocketBase; override;
    procedure StartSSL; override;
  end;

........................


procedure TMainForm.Button1Click(Sender: TObject);
var
  https: TIdHTTP;
  URL: string;
  ReturnedPage: string;
  SSLIOHandler: TMyIdSSLIOHandlerSocketBase;
begin
  SSLIOHandler:= TMyIdSSLIOHandlerSocketBase.Create;
  SSLIOHandler.Linger := true;
  URL := 'https://advisers.macquarie.com.au/security/login.html';
  https := TIdHTTP.Create(nil);
  try
    https.IOHandler := SSLIOHandler;
    TMyIdSSLIOHandlerSocketBase(https.IOHandler).URIToCheck := URL;
    ReturnedPage:= https.Get(URL);
    MessagesMemo.Text := ReturnedPage;
  finally
    https.Free;
    SSLIOHandler.Free;
  end;
end;

{ TMyIdSSLIOHandlerSocketBase }

function TMyIdSSLIOHandlerSocketBase.Clone: TIdSSLIOHandlerSocketBase;
begin
  inherited
end;

procedure TMyIdSSLIOHandlerSocketBase.StartSSL;
begin
  inherited
end;

procedure TMyIdSSLIOHandlerSocketBase.DoAfterBind;
begin
  SetLingerOpt;
  inherited;
end;

procedure TMyIdSSLIOHandlerSocketBase.SetLinger(Value: Boolean);
begin
  if FLinger <> Value then
  begin
      FLinger := Value;
      SetLingerOpt;
  end;
end;

procedure TMyIdSSLIOHandlerSocketBase.SetLingerOpt;
begin
  if BindingAllocated then
  begin
    if FLinger then
      FBinding.SetSockOpt(SocketOptionLevel.Socket, SocketOptionName.Linger, 1)
    else
      FBinding.SetSockOpt(SocketOptionLevel.Socket, SocketOptionName.DontLinger, 1);
  end;
end;

Regards,

David Compton

Start Free Trial
[+][-]10.11.2006 at 01:42AM PDT, ID: 17705229

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 7-day free trial to view this Assisted Solution or ask the Experts your question.

 
[+][-]10.11.2006 at 04:22AM PDT, ID: 17705873

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.11.2006 at 04:27AM PDT, ID: 17705895

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.11.2006 at 05:11AM PDT, ID: 17706120

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.11.2006 at 10:08AM PDT, ID: 17708647

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.11.2006 at 11:03AM PDT, ID: 17709155

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.11.2006 at 11:22AM PDT, ID: 17709316

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.11.2006 at 11:54PM PDT, ID: 17713341

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.12.2006 at 03:16AM PDT, ID: 17713958

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.12.2006 at 08:57AM PDT, ID: 17716483

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.12.2006 at 02:26PM PDT, ID: 17719522

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.12.2006 at 03:08PM PDT, ID: 17719807

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]10.12.2006 at 03:17PM PDT, ID: 17719875

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.12.2006 at 03:36PM PDT, ID: 17719996

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Delphi Programming
Tags: indy, idhttp
Sign Up Now!
Solution Provided By: cobi100
Participating Experts: 3
Solution Grade: B
 
 
[+][-]10.12.2006 at 03:57PM PDT, ID: 17720116

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]10.12.2006 at 04:34PM PDT, ID: 17720304

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32