1{-# LANGUAGE OverloadedStrings #-}
3module FileSpec (main, spec) where
5import Network.HTTP.Types
6import Network.Wai.Handler.Warp.File
7import Network.Wai.Handler.Warp.FileInfoCache
8import Network.Wai.Handler.Warp.Header
15testFileRange :: String
16 -> RequestHeaders -> FilePath
19testFileRange desc reqhs file ans = it desc $ do
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'
28 describe "conditionalRequest" $ do
30 "gets a file size from file system"
32 $ WithBody ok200 [("Content-Length","16"),("Accept-Ranges","bytes")] 0 16
34 "gets a file size from file system and handles Range and returns Partical Content"
35 [("Range","bytes=2-14")] "attic/hex"
36 $ WithBody status206 [("Content-Range","bytes 2-14/16"),("Content-Length","13"),("Accept-Ranges","bytes")] 2 13
38 "truncates end point of range to file size"
39 [("Range","bytes=10-20")] "attic/hex"
40 $ WithBody status206 [("Content-Range","bytes 10-15/16"),("Content-Length","6"),("Accept-Ranges","bytes")] 10 6
42 "gets a file size from file system and handles Range and returns OK if Range means the entire"
43 [("Range:","bytes=0-15")] "attic/hex"
44 $ WithBody status200 [("Content-Length","16"),("Accept-Ranges","bytes")] 0 16
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list