on master help sign in
supporting Last-Modified.
commitb38899ba0fdfa41e39a8553a499a1c3cbc31c372 authorKazu Yamamoto <kazu@iij.ad.jp> dateFri 4 Dec 2015, 13:34 (11 years ago) parenteddf261
3 files changed+8−3
warp/Network/Wai/Handler/Warp/File.hs+3−1 warp/Network/Wai/Handler/Warp/Response.hs+1−1 warp/test/FileSpec.hs+4−1
warp/Network/Wai/Handler/Warp/File.hs+3−1
@@ -36,11 +36,13 @@ conditionalRequest :: I.FileInfo
3636 -> RspFileInfo
3737conditionalRequest finfo hs0 reqidx = case fromJust mx of
3838 nobody@(WithoutBody _) -> nobody
39− WithBody s _ off len -> let hs = addContentHeaders hs0 off len size
39+ WithBody s _ off len -> let hs = (H.hLastModified,date) :
40+ addContentHeaders hs0 off len size
4041 in WithBody s hs off len
4142 where
4243 mtime = I.fileInfoTime finfo
4344 size = I.fileInfoSize finfo
45+ date = I.fileInfoDate finfo
4446 mx = ifmodified reqidx size mtime
4547 <|> ifunmodified reqidx size mtime
4648 <|> ifrange reqidx size mtime
warp/Network/Wai/Handler/Warp/Response.hs+1−1
@@ -124,7 +124,7 @@ import qualified Paths_warp
124124-- by disk access or from the file infor cache.
125125-- If-Modified-Since, If-Unmodified-Since, If-Range and Range
126126-- are processed. Since a proper status is chosen, 'Status' is
127−-- ignored.
127+-- ignored. Last-Modified is inserted.
128128
129129sendResponse :: Settings
130130 -> Connection
warp/test/FileSpec.hs+4−1
@@ -18,7 +18,10 @@ testFileRange :: String
1818 -> Spec
1919testFileRange desc reqhs file ans = it desc $ do
2020 finfo <- getInfo file
21− conditionalRequest finfo [] (indexRequestHeader reqhs) `shouldBe` ans
21+ let WithBody s hs off len = ans
22+ hs' = ("Last-Modified",fileInfoDate finfo) : hs
23+ ans' = WithBody s hs' off len
24+ conditionalRequest finfo [] (indexRequestHeader reqhs) `shouldBe` ans'
2225
2326spec :: Spec
2427spec = do