@@ -75,14 +75,15 @@ insert (path,pp) m = M.alter ins path m
7575-- Learning strategy is implemented in the first argument.
7676-- Learning information is kept for 30 seconds.
7777pushOnReferer :: MakePushPromise -> Middleware
78−pushOnReferer func app req sendResponse = app req $ \res -> do
79− let !path = rawPathInfo req
80− m <- reaperRead cacheReaper
81− case M.lookup path m of
82− Nothing -> case requestHeaderReferer req of
83− Nothing -> return ()
84− Just referer -> case res of
85− ResponseFile (Status 200 "OK") _ file Nothing -> do
78+pushOnReferer func app req sendResponse = app req push
79+ where
80+ push res@(ResponseFile (Status 200 "OK") _ file Nothing) = do
81+ let !path = rawPathInfo req
82+ m <- reaperRead cacheReaper
83+ case M.lookup path m of
84+ Nothing -> case requestHeaderReferer req of
85+ Nothing -> return ()
86+ Just referer -> do
8687 (mauth,refPath) <- parseUrl referer
8788 when (isNothing mauth
8889 || requestHeaderHost req == mauth) $ do
@@ -91,12 +92,13 @@ pushOnReferer func app req sendResponse = app req $ \res -> do
9192 case mpp of
9293 Nothing -> return ()
9394 Just pp -> reaperAdd cacheReaper (refPath,pp)
94− _ -> return ()
95− Just pset -> do
96− let !ps = S.toList pset
97− !h2d = defaultHTTP2Data { http2dataPushPromise = ps}
98− setHTTP2Data req (Just h2d)
99− sendResponse res
95+ Just pset -> do
96+ let !ps = S.toList pset
97+ !h2d = defaultHTTP2Data { http2dataPushPromise = ps}
98+ setHTTP2Data req (Just h2d)
99+ sendResponse res
100+ push res = sendResponse res
101+
100102
101103-- | Learn if the file to be pushed is CSS (.css) or JavaScript (.js) file
102104-- AND the Referer: ends with \"/\" or \".html\" or \".htm\".