- compServer res
- = case getHeader (C8.pack "Server") res of
- Nothing -> return $ setHeader (C8.pack "Server") (cnfServerSoftware conf) res
- Just _ -> return res
-
- compDate res
- = case getHeader (C8.pack "Date") res of
- Nothing -> do date <- getCurrentDate
- return $ setHeader (C8.pack "Date") date res
- Just _ -> return res
-
-
-cache :: IORef (ClockTime, ByteString)
-cache = unsafePerformIO $
- newIORef (TOD 0 0, undefined)
-{-# NOINLINE cache #-}
-
-getCurrentDate :: IO ByteString
-getCurrentDate = do now@(TOD curSec _) <- getClockTime
- (TOD cachedSec _, cachedStr) <- readIORef cache
-
- if curSec == cachedSec then
- return cachedStr
- else
- do let dateStr = C8.pack $ formatHTTPDateTime now
- writeIORef cache (now, dateStr)
- return dateStr
\ No newline at end of file
+ compServer res'
+ = case getHeader "Server" res' of
+ Nothing → return $ setHeader "Server" (cnfServerSoftware conf) res'
+ Just _ → return res'
+
+ compDate res'
+ = case getHeader "Date" res' of
+ Nothing → do date ← getCurrentDate
+ return $ setHeader "Date" date res'
+ Just _ → return res'
+
+getCurrentDate ∷ IO Ascii
+getCurrentDate = HTTP.toAscii <$> getCurrentTime