diff --git a/src/compiler/api/GF/Server.hs b/src/compiler/api/GF/Server.hs index c311da678..342494ed6 100644 --- a/src/compiler/api/GF/Server.hs +++ b/src/compiler/api/GF/Server.hs @@ -117,8 +117,8 @@ handle logLn documentroot state0 cache execute stateVar conn = do -- use/change the cwd. Access files by absolute paths only. let path = translatePath rpath in case (takeDirectory path,takeFileName path,takeExtension path) of - (_ ,_ ,".pgf") -> PS.pgfMain logLn conn cache [("PATH_TRANSLATED",path)] rq - (_ ,_ ,".ngf") -> PS.pgfMain logLn conn cache [("PATH_TRANSLATED",path)] rq + (_ ,_ ,".pgf") -> PS.pgfMain logLn conn cache path rq + (_ ,_ ,".ngf") -> PS.pgfMain logLn conn cache path rq (dir,"grammars.cgi",_ ) -> addDate (grammarList dir query) _ -> serveStaticFile conn rpath path _ -> addDate (return $ resp400 upath) diff --git a/src/server/PGFService.hs b/src/server/PGFService.hs index bcee72094..41f9799e0 100644 --- a/src/server/PGFService.hs +++ b/src/server/PGFService.hs @@ -25,7 +25,6 @@ import System.IO.Error(isDoesNotExistError) import System.FilePath(takeExtension) import System.Mem(performGC) import Network.HTTP -import Network.FastCGI hiding (Connection, writeHeaders) import Numeric(showHex) @@ -62,8 +61,8 @@ newCache' root rd = do clean c = do threadDelay 2000000000 -- 2000 seconds, i.e. ~33 minutes expireCache (24*60*60) c -- 24 hours -pgfMain :: (String -> IO ()) -> Connection -> Caches -> Env -> Request -> IO () -pgfMain logLn conn cache env rq = +pgfMain :: (String -> IO ()) -> Connection -> Caches -> FilePath -> Request -> IO () +pgfMain logLn conn cache path rq = case fromMaybe "grammar" (lookup "command" query) of "download" | ext == ".pgf" -> do tpgf <- getFile (readCache' (pgfCache cache)) path @@ -77,8 +76,6 @@ pgfMain logLn conn cache env rq = handleErrors logLn (pgfCommand (qsem cache) command query tpgf) >>= respondHTTP conn _ -> respondHTTP conn (Response 415 "Bad Request" [] "Extension must be .pgf or .ngf") where - path = fromMaybe "" (lookup "PATH_TRANSLATED" env `mplus` - lookup "SCRIPT_FILENAME" env) ext = takeExtension path query = rqQuery rq