I created a WebBroker application using the Wizard. I changed the default action's code so it looks like this:
procedure TWebModule1.WebModule1DefaultHandlerAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
i: Integer;
begin
i := Request.ContentLength;
Response.Content :=
'<html>' +
'<head><title>DataSnap Server</title></head>' +
'<body>DataSnap Server x' +
Request.ContentFields.Text + 'x' + IntToStr(i) + 'x' +
'</body>' +
'</html>';
end;
I deployed the dll under IIS (6.2 - Server 2012) and tested the dll using a webbrowser.
http://localhost/MapServer/Mapserver.dll/?param1=hello
Just for good measure I tried
http://localhost/MapServer/Mapserver.dll/?param1="hello"
The browser outputs
DataSnap Server xx0x
in both cases.
It appears the Request.ContentFields
is not being populated by the call from the browser.
Is this issue specific to a particular version of Delphi and/or IIS? What am I not understanding?
I have tried both Seattle and Berlin, the result is the same. Thanks
P.S. I also used the wizard to make a stand-alone WebBroker. It doesn't have this problem.
After some really deep Google searching, I found the answer: (Note that while the Embarcadero documentation states that Request.ContentFields
contains the contents of fields "when the MethodType is mtPost", the practically useless documentation for Request.QueryFields
says nothing about mtGet
)
procedure TWebModule1.WebModule1DefaultHandlerAction(Sender: TObject;
Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
i: Integer;
begin
i := Length(Request.QueryFields.Text);
Response.Content :=
'<html>' +
'<head><title>DataSnap Server</title></head>' +
'<body>DataSnap Server x' +
Request.QueryFields.Text + 'x' + IntToStr(i) + 'x' +
'</body>' +
'</html>';
end;