You are not logged in.
Pages: 1
Small extension for the functions StatusCodeToText(), StatusCodeToReason() and StatusCodeToShort() from unit mormot.core.os to output messages in your own language.
Extend the functions as follows:
const
HTTP_CODE: array[0..44] of Word = (
HTTP_SUCCESS,
HTTP_NOCONTENT, ...
type
PHttpStatusCodeMessages = ^THttpStatusCodeMessages;
THttpStatusCodeMessages = array[0..High(HTTP_CODE)] of RawUtf8;
function StatusCodeToText(Code: cardinal; StatusCodeMessages: PHttpStatusCodeMessages = Nil): PRawUtf8;
var
i: PtrInt;
begin
if StatusCodeMessages = Nil then
StatusCodeMessages := @HTTP_REASON;
...
With a customised message definition, the message can be displayed in your own language:
const
HTTP_REASON_DE: THttpStatusCodeMessages = (
'OK', // HTTP_SUCCESS - should be first
'Kein Inhalt', // HTTP_NOCONTENT
'Temporäre Weiterleitung', // HTTP_TEMPORARYREDIRECT
...
);
ShowMessage(Utf8ToString(StatusCodeToText(HTTP_NOCONTENT, @HTTP_REASON_DE)^));
The return for StatusCodeToShort could be a little too short with TShort47, TShort64 would be better.
With best regards
Thomas
Offline
I would not change the global function StatusCodeToText() which should return the standard English text - and is used as such e.g. in THttpServerRequest.SetupResponse for the HTTP response text.
My guess is that you want to refine the default output message of the web servers.
Customize the error text returned to the client by HTTP server(s):
https://github.com/synopse/mORMot2/commit/434219866
Customize the error text returned to the client by the REST server:
https://github.com/synopse/mORMot2/commit/657ba10ab
Offline
Pages: 1