File: ResponseHeaderSpec.hs

package info (click to toggle)
haskell-warp 3.0.0.5-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 300 kB
  • ctags: 2
  • sloc: haskell: 2,890; makefile: 8
file content (28 lines) | stat: -rw-r--r-- 886 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
{-# LANGUAGE OverloadedStrings #-}

module ResponseHeaderSpec (main, spec) where

import Data.ByteString
import qualified Network.HTTP.Types as H
import Network.Wai.Handler.Warp.ResponseHeader
import Test.Hspec

main :: IO ()
main = hspec spec

spec :: Spec
spec = describe "composeHeader" $ do
    it "composes a HTTP header" $
        composeHeader H.http11 H.ok200 headers `shouldReturn` composedHeader

headers :: H.ResponseHeaders
headers = [
    ("Date", "Mon, 13 Aug 2012 04:22:55 GMT")
  , ("Content-Lenght", "151")
  , ("Server", "Mighttpd/2.5.8")
  , ("Last-Modified", "Fri, 22 Jun 2012 01:18:08 GMT")
  , ("Content-Type", "text/html")
  ]

composedHeader :: ByteString
composedHeader = "HTTP/1.1 200 OK\r\nDate: Mon, 13 Aug 2012 04:22:55 GMT\r\nContent-Lenght: 151\r\nServer: Mighttpd/2.5.8\r\nLast-Modified: Fri, 22 Jun 2012 01:18:08 GMT\r\nContent-Type: text/html\r\n\r\n"