Skip to content
Permalink
Browse files

Issue #746: Call SetString with UTF8String instead of String, as advi…

…sed on https://stackoverflow.com/q/57951463/4110077 . Hopefully nails the decoding issue.
  • Loading branch information...
ansgarbecker committed Sep 16, 2019
1 parent abc9ef1 commit a5c449837639fd1a4d286f2bf81f633064b04d7b
Showing with 7 additions and 8 deletions.
  1. +4 −5 source/apphelpers.pas
  2. +3 −3 source/main.pas
@@ -3214,14 +3214,14 @@ procedure THttpDownload.SendRequest(Filename: String);
var
NetHandle: HINTERNET;
UrlHandle: HINTERNET;
Buffer: array[0..4095] of AnsiChar;
Buffer: array[1..4096] of AnsiChar;
Head: array[1..1024] of Char;
BytesInChunk, HeadSize, Reserved, TimeOutSeconds: Cardinal;
LocalFile: File;
DoStore: Boolean;
UserAgent, OS: String;
HttpStatus: Integer;
ContentChunk: String;
ContentChunk: UTF8String;
begin
DoStore := False;
if MainForm.IsWine then
@@ -3273,9 +3273,8 @@ procedure THttpDownload.SendRequest(Filename: String);
if DoStore then begin
BlockWrite(LocalFile, Buffer, BytesInChunk)
end else begin
SetString(ContentChunk, PChar(@Buffer[0]), BytesInChunk);
//ContentChunk := String(@Buffer[0]);
FLastContent := FLastContent + ContentChunk;
SetString(ContentChunk, PAnsiChar(@Buffer[1]), BytesInChunk);
FLastContent := FLastContent + String(ContentChunk);
end;
Inc(FBytesRead, BytesInChunk);
if Assigned(FOnProgress) then
@@ -12860,8 +12860,8 @@ function TMainForm.HasDonated(ForceCheck: Boolean): TThreeStateBoolean;
end;
end;
CheckResult := CheckWebpage.LastContent;
LogSQL('Check success response: "'+CheckResult+'"');
rx.Expression := '^\d+$';
LogSQL('HTTP response: "'+CheckResult+'"', lcDebug);
rx.Expression := '^\d';
if rx.Exec(CheckResult) then begin
if CheckResult = '0' then
FHasDonatedDatabaseCheck := nbFalse
@@ -12870,7 +12870,7 @@ function TMainForm.HasDonated(ForceCheck: Boolean): TThreeStateBoolean;
end;
except
on E:Exception do begin
LogSQL(E.Message + sLineBreak + 'Check response: "'+CheckResult+'"', lcError);
LogSQL(E.Message + sLineBreak + 'HTTP response: "'+CheckResult+'"', lcError);
FHasDonatedDatabaseCheck := nbUnset; // Could have been set before, when ForceCheck=true
end;
end;

0 comments on commit a5c4498

Please sign in to comment.
You can’t perform that action at this time.