Browse Source

* Some small fixes after testing: avoid AV when SQL logging requested and no connection available. Allow CORS on customview

git-svn-id: trunk@41805 -
michael 6 years ago
parent
commit
d5a1e71c5e
1 changed files with 5 additions and 2 deletions
  1. 5 2
      packages/fcl-web/src/restbridge/sqldbrestbridge.pp

+ 5 - 2
packages/fcl-web/src/restbridge/sqldbrestbridge.pp

@@ -900,7 +900,10 @@ function TSQLDBRestDispatcher.CreateCustomViewResource: TSQLDBRestResource;
 begin
   Result:=TCustomViewResource.Create(Nil);
   Result.ResourceName:=FStrings.GetRestString(rpCustomViewResourceName);
-  Result.AllowedOperations:=[roGet];
+  if rdoHandleCORS in DispatchOptions then
+    Result.AllowedOperations:=[roGet,roOptions,roHead]
+  else
+    Result.AllowedOperations:=[roGet,roHead];
 end;
 
 function TSQLDBRestDispatcher.CreateMetadataResource: TSQLDBRestResource;
@@ -1658,7 +1661,7 @@ begin
            DoLog(rloConnection,IO,'Using connection to Host: %s; Database: %s',[Conn.HostName,Conn.DatabaseName])
          else
            DoLog(rloConnection,IO,'Resource %s does not require connection',[IO.ResourceName]);
-      if MustLog(rloSQL) then
+      if assigned(Conn) and MustLog(rloSQL) then
         begin
         Conn.LogEvents:=LogSQLOptions;
         Conn.OnLog:[email protected];