Article

From:
To:
Remy Lebeau (TeamB)
Subject:
Re: Converting Delphi 2007 Indy 10.2.3 to Delphi 2009 Indy 10.5.5[Edit]
Newsgroup:
embarcadero.public.delphi.internet.winsock

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

> {quote:title=Remy Lebeau (TeamB) wrote:}{quote}
> <James Nagle> wrote in message news:✉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.
FYI: Phrase searches are enclosed in either single or double quotes
 
 
Originally created by
Tamarack Associates
Fri, 15 Nov 2024 07:39:25 UTC
Copyright © 2009-2024
HREF Tools Corp.