@@ -31,9 +31,8 @@ module Servant.API.ResponseHeaders
3131 ) where
3232
3333import Data.ByteString.Char8 as BS (pack, unlines, init)
34−import Data.ByteString.Conversion (--ToByteString, toByteString',
35− FromByteString, fromByteString)
36−import Web.HttpApiData (ToHttpApiData,toHeader)
34+import Web.HttpApiData (ToHttpApiData,toHeader
35+ ,FromHttpApiData,parseHeader)
3736import qualified Data.CaseInsensitive as CI
3837import Data.Proxy
3938import GHC.TypeLits (KnownSymbol, symbolVal)
@@ -69,17 +68,17 @@ class BuildHeadersTo hs where
6968instance OVERLAPPING_ BuildHeadersTo '[] where
7069 buildHeadersTo _ = HNil
7170
72−instance OVERLAPPABLE_ ( FromByteString v, BuildHeadersTo xs, KnownSymbol h )
71+instance OVERLAPPABLE_ ( FromHttpApiData v, BuildHeadersTo xs, KnownSymbol h )
7372 => BuildHeadersTo ((Header h v) ': xs) where
7473 buildHeadersTo headers =
7574 let wantedHeader = CI.mk . pack $ symbolVal (Proxy :: Proxy h)
7675 matching = snd <$> filter (\(h, _) -> h == wantedHeader) headers
7776 in case matching of
7877 [] -> MissingHeader `HCons` buildHeadersTo headers
79− xs -> case fromByteString (BS.init $ BS.unlines xs) of
80− Nothing -> UndecodableHeader (BS.init $ BS.unlines xs)
78+ xs -> case parseHeader (BS.init $ BS.unlines xs) of
79+ Left _err -> UndecodableHeader (BS.init $ BS.unlines xs)
8180 `HCons` buildHeadersTo headers
82− Just h -> Header h `HCons` buildHeadersTo headers
81+ Right h -> Header h `HCons` buildHeadersTo headers
8382
8483-- * Getting
8584