Skip to content

Commit

Permalink
Merge PR #32
Browse files Browse the repository at this point in the history
  • Loading branch information
kazu-yamamoto committed Nov 29, 2021
2 parents 2658f4d + 0a1f64c commit 872f361
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
12 changes: 6 additions & 6 deletions http2.cabal
Expand Up @@ -206,7 +206,7 @@ Test-Suite hpack
HPACKSpec
JSON
Build-Depends: base >= 4.9 && < 5
, aeson
, aeson >= 2
, base16-bytestring >= 1.0
, bytestring
, directory
Expand All @@ -230,7 +230,7 @@ Test-Suite frame
JSON
Build-Depends: base >= 4.9 && < 5
, Glob >= 0.9
, aeson
, aeson >= 2
, aeson-pretty
, base16-bytestring >= 1.0
, bytestring
Expand Down Expand Up @@ -293,7 +293,7 @@ Executable hpack-encode
Other-Modules: HPACKEncode
JSON
Build-Depends: base >= 4.9 && < 5
, aeson
, aeson >= 2
, aeson-pretty
, array
, base16-bytestring >= 1.0
Expand All @@ -320,7 +320,7 @@ Executable hpack-debug
Other-Modules: HPACKDecode
JSON
Build-Depends: base >= 4.9 && < 5
, aeson
, aeson >= 2
, array
, base16-bytestring >= 1.0
, bytestring
Expand All @@ -345,7 +345,7 @@ Executable hpack-stat
Main-Is: hpack-stat.hs
Other-Modules: JSON
Build-Depends: base >= 4.9 && < 5
, aeson
, aeson >= 2
, aeson-pretty
, array
, bytestring
Expand Down Expand Up @@ -373,7 +373,7 @@ Executable frame-encode
Other-Modules: Case
JSON
Build-Depends: base >= 4.9 && < 5
, aeson
, aeson >= 2
, aeson-pretty
, base16-bytestring >= 1.0
, bytestring
Expand Down
2 changes: 1 addition & 1 deletion test-frame/JSON.hs
Expand Up @@ -14,7 +14,7 @@ import Data.Aeson.Types
import Data.ByteString (ByteString)
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as B8
import Data.HashMap.Strict (union)
import Data.Aeson.KeyMap (union)
import Data.Maybe (fromJust)
import Data.Text (Text)
import qualified Data.Text as T
Expand Down
7 changes: 4 additions & 3 deletions test-hpack/JSON.hs
Expand Up @@ -14,7 +14,8 @@ import Control.Monad (mzero)
import Data.Aeson
import Data.ByteString (ByteString)
import qualified Data.ByteString.Char8 as B8
import qualified Data.HashMap.Strict as H
import qualified Data.Aeson.KeyMap as H
import qualified Data.Aeson.Key as Key
import Data.Text (Text)
import qualified Data.Text as T
import Data.Vector ((!))
Expand Down Expand Up @@ -83,13 +84,13 @@ instance {-# OVERLAPPING #-} FromJSON Header where
parseJSON (Array a) = pure (toKey (a ! 0), toValue (a ! 1)) -- old
where
toKey = toValue
parseJSON (Object o) = pure (textToByteString k, toValue v) -- new
parseJSON (Object o) = pure (textToByteString (Key.toText k), toValue v) -- new
where
(k,v) = head $ H.toList o
parseJSON _ = mzero

instance {-# OVERLAPPING #-} ToJSON Header where
toJSON (k,v) = object [ byteStringToText k .= byteStringToText v ]
toJSON (k,v) = object [ Key.fromText (byteStringToText k) .= byteStringToText v ]

textToByteString :: Text -> ByteString
textToByteString = B8.pack . T.unpack
Expand Down

0 comments on commit 872f361

Please sign in to comment.