You are not logged in.
Arnaud could you add text/xml too?
From the RFC (3023), under section 3, XML Media Types:
If an XML document -- that is, the unprocessed, source XML document -- is readable by casual users, text/xml is preferable to application/xml. MIME user agents (and web user agents) that do not have explicit support for text/xml will treat it as text/plain, for example, by displaying the XML MIME entity as plain text. Application/xml is preferable when the XML MIME entity is unreadable by casual users.
Thank you once again!
Thanks Arnaud! ![]()
Sometimes certain client applications are not within our control, and the vendor that did the original application insisted on using XML and not changing it.
The kinds written in Java by people in the early 2000s.
Arnaud, does this mean there is no way to implement a 'switch' for response type?
Or perhaps I should create a helper function which looks for the Http Accept parameter if it exists, and return the response type accordingly? e.g.
function ReturnContent(Ctx, Model): TServiceCustomAnswer;
begin
if AcceptParameter = 'xml' then
Result.Content := XMLify(Model)
else Result.Content := JSONify(Model);
end;
function TServiceDevice.GetStatus(const IP: string): TServiceCustomAnswer;
begin
Model := GetDeviceStatus(IP);
Result := ReturnContent(Ctx, Model);
end;Or should I create a subclass of TServiceContainerClient to perform some 'magic'?
PS: By the way how do I 'subscribe' to a thread so that I get notified when someone replies? For instance even though I started this thread, I didn't get any e-mail notifications when you posted your reply.
I understand ab's intentions in using JSON (speed, memory, etc), however there are client applications that can only process XML response.
In .Net's WebAPI framework, the response serializer automatically switches depending on the http Accept parameter (application/json, application/xml, text/json, text/xml).
Is there a way that we could do this in mORMot? Perhaps registering a new serializer/deserializer class? Or is returning TServiceCustomAnswer the only viable solution?
Thanks!
Line 844 of SynCrtSock.pas
ULONGLONG = Int64;Should it be
ULONGLONG = UInt64;instead?
Update: Oops sorry, did not notice your reply. Yea it works if we convert it to Hex. It only fails to work if we print out the value as integer.
And thanks for the prompt response Arnaud!
A quick one... ULONGLONG should be UInt64 and not Int64?
Arnaud/mpv, would it be possible to publish fServerSessionID and fUrlGroupID as public read-only properties? I have patched my code, but would be great if it is in the official source to make it easier for me to update sources.
The reason the properties are useful is that I need to query the performance stats within the programme itself... or did I miss something?
Thanks!
Hi Arnaud, thanks for the reply.
Yup, had a look at the UrlDecode* functions. I reckon the easiest way out is to use UrlDecodeNextNameValue and assign the pair to a StringList/Dictionary eh? Or perhaps to take the parameter portion of the URI, remove the '?', perform a string replace of all & into CRLF, and assign it directly to a StringList? I guess both a do-able.
The reason I asked this is because I would like to allow for optional parameters and to pre-assign default values to those that are not set.
Thanks again Arnaud, for the fantastic framework!
Before trying to reinvent the wheel and doing manual parsing of Ctxt.URL, is there a ready function or property that (pre)parses GET parameters into, say, a TStringList?
Thanks!