HTTPserver source 10.1.5 compiled with Indy 10.5.5 not working

Giganews Newsgroups
Subject: HTTPserver source 10.1.5 compiled with Indy 10.5.5 not working
Posted by:  Henk van den Boogaard (henk…@boogaard-berging.nl)
Date: Fri, 29 Oct 2010

Hello,

I have made a small testprog in D2010 Indy 10.5.0

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms,
  Dialogs, StdCtrls, IdBaseComponent, IdComponent, IdTCPConnection,
IdTCPClient,
  IdHTTP;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Memo1: TMemo;
    IdHTTP1: TIdHTTP;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}
{$O-}
procedure TForm1.Button1Click(Sender: TObject);
var
  Strm: TStringStream;
begin
  Strm := TStringStream.Create;
  try
    Strm.position := 0;
    Strm.LoadFromFile('1.XML');
    Strm.position := 0;
    IdHTTP1.Request.ContentType := 'text/xml';
    Memo1.Lines.Add(IdHTTP1.Post('http://localhost:82', Strm));
  finally
    Strm.Free;
  end;
end;

end.

I have found a example HTTPserver with sourcecode and a compiled exe.

(* IPN Notification Example

  The program uses the port numer 82 so the IPN handler URL must be
set as following:
  http://yourdomanin:82

  Indy version 10.1.5
*)

unit HttpForm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms,
  Dialogs, IdBaseComponent, IdComponent, IdTCPServer, IdHTTPServer,
  StdCtrls, StrUtils, IdContext, IdCustomHTTPServer,
  IdCustomTCPServer, IdIOHandler, IdIOHandlerSocket, IdIOHandlerStack,
IdSSL,
  IdSSLOpenSSL, IdHTTP, IdTCPConnection, IdTCPClient;

type
  TForm1 = class(TForm)
    IdHTTPServer1: TIdHTTPServer;
    Memo1: TMemo;
    http1: TIdHTTP;
    OpenSSL: TIdSSLIOHandlerSocketOpenSSL;
    procedure IdHTTPServer1CommandGet(AContext: TIdContext;
      ARequestInfo: TIdHTTPRequestInfo; AResponseInfo:
TIdHTTPResponseInfo);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses IdHTTPHeaderInfo;

{$R *.dfm}

procedure TForm1.IdHTTPServer1CommandGet(AContext: TIdContext;
  ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
var
  strWrite : TStringList;
  strRead  : String;
begin

  Memo1.Lines.Add('Notification:');
  Memo1.Lines.Add(ARequestInfo.FormParams);

  Memo1.Lines.Add('Answer:');
  strWrite := TStringList.Create;
  try
    strWrite.Add(ARequestInfo.FormParams+'&cmd=_notify-validate');
    Memo1.Lines.Add(ARequestInfo.FormParams+'&cmd=_notify-validate');
    Http1.Request.UserAgent := 'application/x-www-form-urlencoded';
    Http1.ReadTimeout := 0;
    Http1.IOHandler := OpenSSL;
    // If you are in live
    // strRead := Http1.Post('https://www.paypal.com/cgi-bin/webscr',
strWrite);
    // If you are in sandbox
    strRead :=
Http1.Post('https://www.sandbox.paypal.com/cgi-bin/webscr', strWrite);
    Memo1.Lines.Add(strRead);
  except
    on E: Exception do
    begin
      showmessage('Error encountered during POST: ' + E.Message);
    end;
  end;
  strWrite.Free;

end;

end.

When sending the file '1.XML' I see in the compiled version (with Indy
10.1.5) my data from '1.XML' in the memo.
If I compile de program with Indy 10.5.0 I do not see the data from
'1.XML'.

Can someone tell me why?

Greetings,
Henk van den Boogaard

--

Replies