[fpc-pascal] TJSONRPCModule: access the request from an handler.

Luca Olivetti luca at ventoso.org
Fri Sep 9 16:02:07 CEST 2022


El 9/9/22 a les 15:50, Michael Van Canneyt ha escrit:

> The solution is much more simple.
> 
> Override HandleRequest() in the module.
> Save the request in a variable and call inherited.

Much simpler indeed! Thank you.
In my case I just save the remote address, but in your example below I 
suppose you redefined FRequest (and FResponse) to hide the private one 
in the ancestor, but what I don't understand is the C:=C+C and the need 
to set FRequest and FResponse to nil.

> 
> I have code that needs to work with 3.2.2 and I do this:
> 
> ---
> procedure TUserRPCModule.HandleRequest(ARequest: TRequest; AResponse: 
> TResponse);
> 
> Var
>    C : String;
> 
> begin
>    FRequest:=aRequest;
>    FResponse:=aResponse;
>    try
>      C:=FRequest.Content;
>      C:=C+C;
>      inherited HandleRequest(ARequest, AResponse);
>    finally
>      FRequest:=Nil;
>      FResponse:=Nil;
>    end;
> end;

Bye
-- 
Luca



More information about the fpc-pascal mailing list