In Delphi 11.2 (and all Unicode Delphi versions), the function ReceiveData
uses WinApi Function HTTPQueryInfo
, which calls the WideString variant HTTPQueryInfoW
.
The 4th parameter of HTTPQueryInfoW
“amount of written bytes” is the same as for HTTPQueryInfoA
. Your code uses this Size
to set Length
of string
, in Unicode Delphi of UnicodeString
. Which results in partially random strings, with a lots of broken letters.
IndyComponents use {$IFDEF UNICODE} div 2{$ENDIF})
on same spot.
Example:
...
if (l_status >= 300) and (l_status <> HTTP_500_code) then begin
l_index := 0;
l_size := const_MaxStatusText;
SetLength(l_statusText, l_size);
if HTTPQueryInfo(aRequest, HTTP_QUERY_STATUS_TEXT, @l_statusText[1], l_size, l_index) then begin
SetLength(l_statusText, l_size {$IFDEF FIX_IT} div SizeOf(Char) {$ENDIF});
raise EROWinInetHttpException.CreateFmt('%s (%d)', [l_statusText, l_status], GetLastError);
end;
end;