Converting Delphi 2007 Indy 10.2.3 to Delphi 2009 Indy 10.5.5 [Edit]

Hello,

I am currently attempting to port over a Delphi 2007 project that uses Indy 10.2.3 (very successfully) to Delphi 2009 and Indy 10.5.5 (I just got the latest development build this morning). I think I am running into an encoding issue, but am not sure. Specifically, IDHTTP with SSL calls an old CGI and the CGI returns a .zip file and I then save it to the disk. In 2007 and before this worked perfectly. In 2009, it is not. Here is the examples of the 2 different results (though cut way short in the post) I 
am getting back:

2007:
'PK'#3#4#$14#0#0#0#8#0'rLQ9žrPb€'#0#0#0'œ'#0#0#0#$C#0#0#0'_default.rtfEŒ1'#$F' '#$14'„w'#$13'ÿ'#3'³'#$13'´´‹«‹»ãKÌk'#$81'J ¯'#$D'`'#$1D#8'ÿ]Úĸ\î¾»\†'#$90'Œ'#0'¤h'#$F#$19'×I4]'#3'J'#$1B'ÃwõH“àm›Á,”Òà«á`ÈzöÀ×2ãµ”ó'#9'6«?Î’’ð'#$1E#5'¬'#$18'Ô1‹¢gµ'#$AD'9g¸Ààf'#$17#$13'†Äî·§ä'#$9D'ìË'#$F'kR'#$7F'XØ~ú'#5'PK'#3#4#$14#0#0#0#8#0'xTQ9Ö2Ì'#$1F'#'#$B#0#0'ê1'#0#0#$14#0#0#0'SOAP Note_Croson.rtfíZ{oÛ8'#$12'ÿ߀¿'#3#$81'üq»ÅÂ'#$11'õðc³X'...

2009:
'PK'#3#4#$14#0#0#0#8#0'rLQ9?rPb?'#0#0#0'?'#0#0#0#$C#0#0#0'_default.rtfE?1'#$F' '#$14'?w'#$13'ÿ'#3'³'#$13'´´?«?»ãKÌk'#$81'J ¯'#$D'`'#$1D#8'ÿ]Úĸ\î¾»\?'#$90'?'#0'¤h'#$F#$19'×I4]'#3'J'#$1B'ÃwõH?àm?Á,?Òà«á`ÈzöÀ×2ãµ?ó'#9'6«?Î??ð'#$1E#5'¬'#$18'Ô1?¢gµ'#$AD'9g¸Ààf'#$17#$13'?Äî·§ä'#$9D'ìË'#$F'kR'#$7F'XØ~ú'#5'PK'#3#4#$14#0#0#0#8#0'xTQ9Ö2Ì'#$1F'#'#$B#0#0'ê1'#0#0#$14#0#0#0'SOAP Note_Croson.rtfíZ{oÛ8'#$12'ÿß?¿'#3#$81'üq»ÅÂ'#$11'õðc³X'...

Notice that they are not the same... The 2007 version seems to have many characters the 2009 version can't display (I assume that is why it shows ?) which lead me to think of all the new Unicode stuff in 2009.

var
	sHttpResult : Ansistring;
	slPostData : TStringList;
begin
        IdSSL.CheckForDisconnect(False);
        IDHttp.CheckForGracefulDisconnect(False);
        IdSSL.ReadTimeout := 30000;
        {Guessing on the encoding here}
        IDHttp.IOHandler.DefStringEncoding := TIdTextEncoding.ASCII;
        IDSSl.DefStringEncoding := TIdTextEncoding.ASCII;
        application.ProcessMessages;
	slPostData:= TStringList.Create;
       {Fill in the TStringlist with the post data here}
       blah blah blah
       {Call to CGI/ISAPI works here, but results are different between the two versions}
       sHttpResult := IdHttp.Post(aHttpRequestData.sURL, slPostData);


Also, here is the relevant code in the ISAPI (compiled in Delphi 2007) that is being called:
       {Create File Stream to send to client}
       FileStream := TFileStream.Create(sFilename,fmShareDenyNone);
       Response.ContentStream := FileStream;
       Response.SendResponse;


Any ideas on how I could resolve this? *Thank you in advanced!*

I also posted this in the Atozed forum... I apologize if cross-posting like that is frowned upon.
0
James
4/3/2009 10:28:49 PM
embarcadero.delphi.winsock 1874 articles. 2 followers. Follow

2 Replies
1957 Views

Similar Articles

[PageSpeed] 13

<James Nagle> wrote in message news:101394@forums.codegear.com...

> In 2007 and before this worked perfectly. In 2009, it is not.

Yes, you are having Unicode<->Ansi conversion issues.  The way you are using 
Post(), TIdHTTP will decode the raw bytes to Unicode (using any number of 
charsets, none of which are suiable for binary data), and then you are 
assigning that Unicode string to an AnsiString, which will convert the 
Unicode data to the OS default Ansi codepage, which is also not suitable for 
binary data, either.

Why are you receiving a binary file as a String to begin with?  You should 
be using the overloaded version of Post() that has an AResponseContent 
output parameter instead.  That way, you receive the raw bytes unaltered and 
unprocessed.  For example:

{code:delphi}
var
    msHttpResult : TMemoryStream;
    slPostData : TStringList;
begin
    ...
    slPostData := TStringList.Create;
    try
        // Fill in the TStringlist with the post data here...
        msHttpResult := TMemoryStream.Create;
        try
            IdHttp.Post(aHttpRequestData.sURL, slPostData, msHttpResult);
            msHttpResult.Position := 0;
            // use msHttpResult as needed...
        finally
            msHttpResult.Free;
        end;
    finally
        slPostData.Free;
    end;
end;
{code}

-- 
Remy Lebeau (TeamB)
0
Remy
4/6/2009 1:43:48 AM
> {quote:title=Remy Lebeau (TeamB) wrote:}{quote}
> <James Nagle> wrote in message news:101394@forums.codegear.com...
> 
> > In 2007 and before this worked perfectly. In 2009, it is not.
> 
> Yes, you are having Unicode<->Ansi conversion issues.  The way you are using 
> Post(), TIdHTTP will decode the raw bytes to Unicode (using any number of 
> charsets, none of which are suiable for binary data), and then you are 
> assigning that Unicode string to an AnsiString, which will convert the 
> Unicode data to the OS default Ansi codepage, which is also not suitable for 
> binary data, either.
> 
> Why are you receiving a binary file as a String to begin with?  You should 
> be using the overloaded version of Post() that has an AResponseContent 
> output parameter instead.  That way, you receive the raw bytes unaltered and 
> unprocessed.  For example:
> 
> {code:delphi}
> var
>     msHttpResult : TMemoryStream;
>     slPostData : TStringList;
> begin
>     ...
>     slPostData := TStringList.Create;
>     try
>         // Fill in the TStringlist with the post data here...
>         msHttpResult := TMemoryStream.Create;
>         try
>             IdHttp.Post(aHttpRequestData.sURL, slPostData, msHttpResult);
>             msHttpResult.Position := 0;
>             // use msHttpResult as needed...
>         finally
>             msHttpResult.Free;
>         end;
>     finally
>         slPostData.Free;
>     end;
> end;
> {code}
> 
> -- 
> Remy Lebeau (TeamB)


Thank you Remy.  I appreciate your help.
0
James
4/7/2009 11:51:33 PM
Reply:

Similar Artilces:

Encoding issues with Delphi 2007 and Indy 10.5.5
Hi, I'm using the last snapshot of Indy 10 (Rev 3539) with Delphi 2007 under a French version of Windows Vista. I just discovered that some characters wasn't transferred correctly, probably since the Unicode update (AFAIK that worked fine with Indy 10.2.3). They are replaced by '?' on the other end of the connection. For instance, this code : procedure TForm2.Button1Click(Sender: TObject); begin IdTCPClient1.Connect; IdTCPClient1.IOHandler.WriteLn('£'); end; procedure TForm2.IdTCPServer1Execute(AContext: TIdContext); var S: string;...

Delphi 2009
Hello, I am using Delphi 2009 with a recent Indy 10.5.5 development snapshot. In my code I am using a TIDHttp with TIDSSLIOHandlerSocketOpenSSL. The Open SLL .dlls I am using is from the the indy website and are openssl-0.9.8k-i386-win32. The issue is, randomly, I am getting a socket error # 0 error. I never got this error with Delphi 2007 and Indy 10.2.3. Any help would be GREATLY appreciated! Thank you. The code looks something like this: var sHttpResult, sVar, sParam: string; ssHttpResult : TStringStream; slPostData : TStringList; begin IdSSL.CheckForDi...

how to compile and install indy 10.2.3 in delphi 2009
hi all. in my delphi 2007 application, indy 10.2.3 works very fine for me. however, when i update delphi to 2009, i found indy 10.2.5, which is the default indy version of delphi 2009, at least the following bugs: 1,TIdMultiPartFormDataStream does not support unicode any more, 2,TidHttp has bugs, 3,TidMessage has changed .. .. all of these have changed my application. so i wonder whether i can compile and install indy 10.2.3 in delphi 2009 to revive my application? or can i compile other compatible version which has little change with 10.2.3 in delphi 2009? (i have tried to compi...

Indy 10.5.8/Delphi 5 (SMTP) getting "... temporary failure"
Everything has been working fine for over a year, but now a customer is getting the above error. Actually, the program simply bombs on their system. That error only shows up when running inside Delphi. It never makes it outside of Indy code before bombing the program. Two things: this only happens after several e-mails are sent in a short period of time. Also, this was not a problem before, when the program ran MUCH slower, due to BDE/SQL speed issues. We are now using the Advantage database server, which makes everything run much faster. We know there is a problem if we go over 250 e-ma...

HOW TO INSTALL Indy 10.5.7 in Delphi 2007 IDe from * Tiburon.zip * distribu
Date 25/05/2010 By Davide Spano e-mail davide.spano@armfield.co.uk ********************************************************************************** HOW TO INSTALL Indy 10.5.7 in Delphi 2007 IDe from * Tiburon.zip * distribution ********************************************************************************** - 0 What version of Indy I have in my IDE? To find out.. Create a new VCL project with a form and drag whatever of the components that are in the IDE Indy tool palette section (TIdTCPClient or other) then right click and select About Internet Dir...

migrating from Delphi 6 With Indy 10 to XE7 with Indy 10
I updated the original Indy in D6 to version 10 several years ago. Now I want to migrate my application from D6 to XE7 and would like some feedback on the best route to take. I usually send data using readln and writeln statements. The data is typically XML format. Since migrating to XE7 will include potential unicode data what is the best approach to take when reading and writing data? Will writeln and readln work in these cases or should I be using a different strategy to send unicode data between the tidtcpclient and tidtcpserver applications? al wrote: > I usually send data ...

Indy 10 Installation Delphi 5
Hi, As a result of this POODLE thing, I have to upgrade our Delphi 5 program to use TLS instead of SSL3, so I was trying to upgrade from Indy 9 to Indy 10 (does some version of Indy 9 support TLSv1.2?). So after running the batch file that comes with the installation (Full_5.bat) and installing the component in Delphi 5. I go and drop a idIOhandlerSSL or whatever onto an empty form and get an error: "Stack overflow - save your work and restart Delphi" Anyone know how to get the installation to work? Thanks! Orren wrote: > As a result of this POODLE thing, I have t...

Indy E-Mail Problem (Indy 10, Delphi 2007)
Hello, we use Indy 10 with Delphi 2007 to get E-Mail using IMAP. We recieved an E-Mail which is not handled correctly. The E-Mail looks like this {code} Return-Path: <test@mail.com>; From: "Test Tester" <test@mail.com>; To: <test@mail.com>; Subject: Order Date: Wed, 7 Mar 2012 16:50:40 +0100 Message-ID: <15D526BEB8091D43859549D9E16E370FBA3123> MIME-Version: 1.0 Content-Type: text/html; charset=US-ASCII Content-Transfer-Encoding: quoted-printable X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQFk6K6fcF3...

Delphi 5 To Delphi 2009
I upgraded to Delphi 2009 from D5. The install says I can install Delphi and/or C++. Delphi installed OK but I see nothing of C++. What am I missing or does my upgrade not include C++? Thanks It depends on what you bought. If you bought Delphi 2009 only, that's what you get. If you bought Delphi 2009 and C++ Builder 2009 you get both. My guess is you got Delphi 2009 only. The simplest way to verify is look your invoice - it should say I would think. You could also go to members.embarcadero.com, login, then click on my registered products. There will be a textual description of...

C++ Builder/Delphi 2009 and IndyTiburon 10.5.5 error
Hello, i installing the latest IndyTiburon package r3641. 1. There are a problem with the genarated header file /core/IdWinsock2.hpp when i will use the components: [BCC Error] IdWinsock2.hpp(88):E2040 [BCC Error] IdWinsock2.hpp(89):E2040 [BCC Error] IdWinsock2.hpp(90):E2040 [BCC Error] IdWinsock2.hpp(91):E2040 static const Word IPPORT_REGISTERED_MIN = 0x400; static const Word IPPORT_REGISTERED_MAX = 0xbfff; static const Word IPPORT_DYNAMIC_MIN = 0xc000; static const Word IPPORT_DYNAMIC_MAX = 0xffff; I comment them out ! and it work fine ! But can i get any other Problem...

SEPA components for Delphi with Source Code (Delphi 5
Hi all, in the european union change next year the Bankingformat to the SEPA Format. All peoples and companies must change the bankingssoftware and the costumer data form acountnummers in the new IBAN and BIC numbers. See: http://www.arma-it.de/shop/artikelueber.php?wgruppeid=211&wgruppe_offen=211 Functions: - generate SEPA XML'S - Calc IBAN - BIC Database (DE,AT and CH) Questions: vertrieb@arma-it.de PS: Bankinssoftware for Develpoers (Germany only) http://www.arma-it.de/shop/artikelueber.php?wgruppeid=212&wgruppe_offen=212 El 26/10/13 21:38, A...

game with delphi 2009 multi player (Indy 10) [Edit]
I am developing a game for a lan-house with delphi 2009 and am using the Indy10. I have 10 rooms and each room has 5 player who can play in all rooms at the same time. I control this. What is the best way? I'm using TIdTCPServer and TIdTCPClient. Does anyone have any suggestions? TIdScheduler? or a simple example to understand me? Thank you staff Thank Loest Silva Edited by: Loester Silva on May 17, 2009 1:10 AM > {quote:title=Loester Silva wrote:}{quote} > I am developing a game for a lan-house with delphi 2009 and am using the Indy10. I have 10 rooms and each...

Indy 10 Delphi 5 support broken (SMTP and SSL)?
This message is in MIME format. Since your mail reader does not understand this format, some or all of this message may not be legible. --JivePart=_5f0e5.zeB8CwDOH5aMJzMl Content-Type: text/plain; charset="Utf-8" Simple test program for SMTP and gmail test, see embarcadero.public.delphi.thirdpartytools.general group. ain --JivePart=_5f0e5.zeB8CwDOH5aMJzMl Content-Type: application/octet-stream; name="smtpTest.zip" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename="smtpTest.zip" UEsDBBQAAAAIAMN8Jz+JAV9RhgAAALwAA...

Indy 10 Delphi 5 support broken (SMTP and SSL)?
Hi, I need to update an Delphi 5 program to send e-mails via gmail's SMTP interface. So installed few days old Indy 10 snapshot (from http://indy.fulgan.com/ZIP/ filename was Indy10_4675.zip). I also downloaded OpenSSL DLLs from there (http://indy.fulgan.com/SSL/openssl-1.0.0d-i386-win32-rev2.zip). But the program dissapears when trying to send mail. There is no error message, it is just gone, probably stack overflow... So I created simple test program and the same thing happens with it. However, when compiling the test program with Delphi 2010 it works OK! So it looks like t...

Web resources about - Converting Delphi 2007 Indy 10.2.3 to Delphi 2009 Indy 10.5.5 [Edit] - embarcadero.delphi.winsock

Facebook Begins Converting Users To HTTPS
Are you willing to sacrifice a little bit of speed for a lot more safety? Facebook is asking that very question with its announcement that it ...

Facebook No Longer Converting Groups Into Pages
Back when Facebook first launched Facebook Pages, many businesses and brands who had built up substantial audiences in their Facebook Groups ...

Vert - simply converting for iPhone, iPad, and iPod touch on the iTunes App Store
Get Vert - simply converting on the App Store. See screenshots and ratings, and read customer reviews.

Converting SIM Card to Micro SIM Card - Flickr - Photo Sharing!
Place new Micro SIM into the iPhone SIM card tray

Ayaan Hirsi Ali on Converting Muslims to Christianity - YouTube
Complete video at: http://fora.tv/2010/07/29/Nomad_From_Islam_to_America_with_Ayaan_Hirsi_Ali Ayaan Hirsi Ali explains her support of missionary ...

Click go fears of converting print files
Is there a way to convert a print queue item to a .RTF or .PDF file? I like to save or email them. - The Sydney Morning Herald

Sudanese woman ordered to hang under sharia law for converting to Christianity gives birth
Khartoum, Sudan: A Christian Sudanese woman sentenced to hang for apostasy has given birth in jail, a Western diplomat said on Tuesday.

Imams warn against radicalism to Aboriginal inmates converting to Islam
The prison system has enlisted the help of ASIO to crack down on radicalisation behind bars amid revelations that Aboriginals are converting ...

Converting the world's companies one by one - The Science Show - ABC Radio National (Australian Broadcasting ...
Image: Trucks carrying logs make their way up a road in Jambi, Indonesia. A vast area of the Sumatran forest, and orangutan habitat, is being ...

Converting Churches Into Homes Is The Latest Hollywood Trend
You don't have to be a believer to be moved by the beauty of a church.

Resources last updated: 12/22/2015 12:42:18 AM