#1 2020-02-19 12:36:38

jaclas
Member
Registered: 2014-09-12
Posts: 215

Minor error in THttpApiServer.Execute() from SynCrtSock

I found error in OnBeforeBody event that results from using WITH and the name of a local variable such as object field.
The RemoteIP parameter is passed to the OnBeforeBody event as an empty string (this is the value of Context.RemoteIP field) even though the local variable contains the correct value.


procedure THttpApiServer.Execute;
[...]
var 
[...]
  RemoteIP: SockString;
  Context : THttpServerRequest;
[...]
[...]

begin
[...]
        if Assigned(OnBeforeBody) then begin
          with Context do                                                                                <-------------------- this 'with' cause a problem
            Err := OnBeforeBody(URL,Method,InHeaders,InContentType,RemoteIP,InContentLength,fUseSSL);    <--- RemoteIP is taken from Context object, not from local variable

  THttpServerRequest = class
  [...]
  public
  [...]  
    property RemoteIP: SockString read fRemoteIP write fRemoteIP;
  end;  

Last edited by jaclas (2020-02-19 12:40:06)

Offline

#2 2020-02-19 14:15:46

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,660
Website

Re: Minor error in THttpApiServer.Execute() from SynCrtSock

Offline

Board footer

Powered by FluxBB