Access to TWebRequest.Content throws a ERangeError exception in an ISAPI DLL but not in a console application

115 Views Asked by At

I'm writing an ISAPI dll that handles POST requests from an IoT device.
In parallel I have written a console application that shares the same TWebModule.

The action that handles the requests needs to access the request content (TWebRequest.Content) because it is not parsed correcly by default.

Everything works fine when the program is built as a console application. However a ERangeError exception is thrown when I want to access the TWebRequest.Content in the ISAPI dll.

Here is an example of the Content property :

-----------------------------7d624e177018a
Content-Disposition: form-data; name="Date_Time"

06/09/2021 11:14:03
-----------------------------7d624e177018a
Content-Disposition: form-data; name="f"; filename="IV.txt"
Content-Type: application/octet-stream

"TagId";"TagName";"Value";"AlStatus";"AlType";"Quality"
4;"AAA";0;0;0;65472
5;"AAB";0;0;0;65472
35;"TEST_Index";0;0;0;65472
36;"Signal";21;0;0;65472

-----------------------------7d624e177018a--

Here is a sample procedure that reproduces the problem:

procedure TWebModule1.WebModule1WebActionItem1Action(Sender: TObject;
  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
begin   
  Response.Content:= Request.Content;   // Throws a ERangeError exception in ISAPI dll   
end;

What am I missing ?

0

There are 0 best solutions below