As I need to solve Local access Service Issue I try to migrate my project to
DA: 10.0.0.1495 , delphi: 10.4.1
to New Envirnoment:
DA: 10.0.0.1569 , delphi: 11.2
My Issue is on CustomResponseEvent
lMessage:= (ROJSONMessage1 as IROMessageCloneable).Clone;
b := StringToUTF8Bytes(MyJson.Text);
aRequestStream.Size := 0;
aRequestStream.Write(b[0], Length(b));
aResponseStream.Position := 0;
aRequestStream.Position := 0;
codesite.Send('Stream Size:',Length(b).ToString); // body
ROHttpApiDispatcher1.Process(aTransport, aTransport as IROHTTPRequest, aResponse, aRequestStream, aResponseStream);
aHandled := True;
As My requestStream is large like Stream Size: = 143451,
As I will encode the data add a new data member in json( MyJson.Text) and pass to the HttApi to process to have dynamic json passing to api function to handle the logic.
On delphi 10.4.1 and 10.0.0.1495 , it can process without any issue.
When in delphi 11.2 and DA: 10.0.0.1569 , I hit Argument out of range error.
I trace the stack: the error is in
procedure TROJSONValue.LoadFromStream(Source: TStream; aUTF8Stream: Boolean);
var
l_stream: TMemoryStream;
l_bytes: TBytes;
l_string: JSON_String;
l_position: Int64;
l_bomSize: Integer;
begin
l_position := Source.Position;
try
if aUTF8Stream then begin
if (Source.Size = Source.Position) then raise EReadError.CreateRes(@SReadError);
l_stream := TMemoryStream.Create;
try
SetLength(l_bytes, Source.Size - Source.Position);
if Length(l_bytes) > 0 then
Source.Read(l_bytes[0], Length(l_bytes));
l_bomSize := 0;
if Length(l_bytes) > 2 then
if (l_bytes[0] = $EF) and (l_bytes[1] = $BB) and (l_bytes[2] = $BF) then
l_bomSize := 3;
l_string := UTF8BytesToString(@l_bytes[l_bomSize], Length(l_bytes) - l_bomSize);
SetLength(l_bytes, 0);
l_stream.Size := Length(l_string) * SizeOf(JSON_Char);
Move(Pointer(l_string)^, l_stream.Memory^, l_stream.Size);
l_string := ‘’;
IntLoadFromStream(l_stream);<< error line
finally
FreeOrDisposeOf(l_stream);
end;
end
else begin
IntLoadFromStream(Source);
end;
except
Source.Position := l_position;
raise;
end;
end;
The error is triggered by IntLoadFromStream(l_stream). From the call stack, seems handling the array data trigger that error.
The attached picture having the calling stack.
Please advise .
