Respond with 200 or 206 in ranged responses

This commit is contained in:
Joe Nelson
2014-09-07 09:38:30 -07:00
parent 7c93c788fa
commit 7802fa5b7e
6 changed files with 183 additions and 28 deletions
+11 -4
View File
@@ -1,15 +1,22 @@
{-# LANGUAGE OverloadedStrings, QuasiQuotes #-}
{-# LANGUAGE OverloadedStrings #-}
module Feature.RangeSpec where
import Test.Hspec
import Test.Hspec.Wai
import Network.HTTP.Types
import SpecHelper
spec :: Spec
spec = around appWithFixture $ do
describe "GET /view" $
spec = around appWithFixture $
describe "GET /items" $ do
context "without range headers" $
context "with response under server size limit" $
it "returns whole range with status 200" $
get "/auto_incrementing_pk" `shouldRespondWith` 206
get "/items" `shouldRespondWith` 200
context "with range headers" $
context "of acceptable range" $
it "succeeds with partial content" $
request methodGet "/items"
(rangeHdrs $ ByteRangeFromTo 0 1) ""
`shouldRespondWith` 206