<James Nagle> wrote in message news:✉forums.codegear.com...
> In 2007 and before this worked perfectly. In 2009, it is not.
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)