From abc9ef16f9b5d545c73b5a74530fcc3ba2205134 Mon Sep 17 00:00:00 2001 From: Ansgar Becker Date: Sun, 15 Sep 2019 19:08:40 +0200 Subject: [PATCH] Issue #746: prefer AnsiString over Byte data type for buffering http request result. --- source/apphelpers.pas | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/apphelpers.pas b/source/apphelpers.pas index 54e4a977..45e2c730 100644 --- a/source/apphelpers.pas +++ b/source/apphelpers.pas @@ -3214,7 +3214,7 @@ procedure THttpDownload.SendRequest(Filename: String); var NetHandle: HINTERNET; UrlHandle: HINTERNET; - Buffer: array[1..4096] of Byte; + Buffer: array[0..4095] of AnsiChar; Head: array[1..1024] of Char; BytesInChunk, HeadSize, Reserved, TimeOutSeconds: Cardinal; LocalFile: File; @@ -3273,7 +3273,8 @@ begin if DoStore then begin BlockWrite(LocalFile, Buffer, BytesInChunk) end else begin - SetString(ContentChunk, PChar(@Buffer[1]), BytesInChunk); + SetString(ContentChunk, PChar(@Buffer[0]), BytesInChunk); + //ContentChunk := String(@Buffer[0]); FLastContent := FLastContent + ContentChunk; end; Inc(FBytesRead, BytesInChunk);