Skip to content

Commit d4788fb

Browse files
authored
Merge pull request #1173 from haskell-servant/http-media-0.8-master
Http media 0.8 master
2 parents 94e00d3 + 6d90d48 commit d4788fb

File tree

9 files changed

+34
-18
lines changed

9 files changed

+34
-18
lines changed

servant-client-core/servant-client-core.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ library
7777
, base64-bytestring >= 1.0.0.1 && < 1.1
7878
, exceptions >= 0.10.0 && < 0.11
7979
, free >= 5.1 && < 5.2
80-
, http-media >= 0.7.1.3 && < 0.8
80+
, http-media >= 0.7.1.3 && < 0.9
8181
, http-types >= 0.12.2 && < 0.13
8282
, network-uri >= 2.6.1.0 && < 2.7
8383
, safe >= 0.3.17 && < 0.4
@@ -105,7 +105,7 @@ test-suite spec
105105
build-depends:
106106
deepseq >= 1.4.2.0 && < 1.5
107107
, hspec >= 2.6.0 && < 2.8
108-
, QuickCheck >= 2.12.6.1 && < 2.13
108+
, QuickCheck >= 2.12.6.1 && < 2.14
109109

110110
build-tool-depends:
111111
hspec-discover:hspec-discover >= 2.6.0 && <2.8

servant-client-ghcjs/servant-client-ghcjs.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ library
4545
, exceptions >=0.8 && <0.11
4646
, ghcjs-base >=0.2.0.0 && <0.3.0.0
4747
, ghcjs-prim >=0.1.0.0 && <0.2.0.0
48-
, http-media >=0.6.2 && <0.8
48+
, http-media >=0.6.2 && <0.9
4949
, http-types >=0.12 && <0.13
5050
, monad-control >=1.0.0.4 && <1.1
5151
, mtl >=2.2.2 && <2.3

servant-client/servant-client.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ library
6969
build-depends:
7070
base-compat >= 0.10.5 && < 0.11
7171
, http-client >= 0.5.13.1 && < 0.7
72-
, http-media >= 0.7.1.3 && < 0.8
72+
, http-media >= 0.7.1.3 && < 0.9
7373
, http-types >= 0.12.2 && < 0.13
7474
, exceptions >= 0.10.0 && < 0.11
7575
, kan-extensions >= 5.2 && < 5.3
@@ -125,7 +125,7 @@ test-suite spec
125125
, hspec >= 2.6.0 && < 2.8
126126
, HUnit >= 1.6.0.0 && < 1.7
127127
, network >= 2.8.0.0 && < 3.1
128-
, QuickCheck >= 2.12.6.1 && < 2.13
128+
, QuickCheck >= 2.12.6.1 && < 2.14
129129
, servant == 0.16.*
130130
, servant-server == 0.16.*
131131
, tdigest >= 0.2 && < 0.3

servant-docs/servant-docs.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ library
6363
, case-insensitive >= 1.2.0.11 && < 1.3
6464
, control-monad-omega >= 0.3.1 && < 0.4
6565
, hashable >= 1.2.7.0 && < 1.3
66-
, http-media >= 0.7.1.3 && < 0.8
66+
, http-media >= 0.7.1.3 && < 0.9
6767
, http-types >= 0.12.2 && < 0.13
6868
, lens >= 4.17 && < 4.18
6969
, string-conversions >= 0.4.0.1 && < 0.5

servant-http-streams/servant-http-streams.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ library
6767
base-compat >= 0.10.5 && < 0.11
6868
, case-insensitive
6969
, http-streams >= 0.8.6.1 && < 0.9
70-
, http-media >= 0.7.1.3 && < 0.8
70+
, http-media >= 0.7.1.3 && < 0.9
7171
, io-streams >= 1.5.0.1 && < 1.6
7272
, http-types >= 0.12.2 && < 0.13
7373
, http-common >= 0.8.2.0 && < 0.9
@@ -119,7 +119,7 @@ test-suite spec
119119
, hspec >= 2.6.0 && < 2.8
120120
, HUnit >= 1.6.0.0 && < 1.7
121121
, network >= 2.8.0.0 && < 3.1
122-
, QuickCheck >= 2.12.6.1 && < 2.13
122+
, QuickCheck >= 2.12.6.1 && < 2.14
123123
, servant == 0.16.*
124124
, servant-server == 0.16.*
125125
, tdigest >= 0.2 && < 0.3

servant-server/servant-server.cabal

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ library
8888
base-compat >= 0.10.5 && < 0.11
8989
, base64-bytestring >= 1.0.0.1 && < 1.1
9090
, exceptions >= 0.10.0 && < 0.11
91-
, http-media >= 0.7.1.3 && < 0.8
91+
, http-media >= 0.7.1.3 && < 0.9
9292
, http-types >= 0.12.2 && < 0.13
9393
, network-uri >= 2.6.1.0 && < 2.8
9494
, monad-control >= 1.0.2.3 && < 1.1
@@ -165,7 +165,7 @@ test-suite spec
165165
, directory >= 1.3.0.0 && < 1.4
166166
, hspec >= 2.6.0 && < 2.8
167167
, hspec-wai >= 0.9.0 && < 0.10
168-
, QuickCheck >= 2.12.6.1 && < 2.13
168+
, QuickCheck >= 2.12.6.1 && < 2.14
169169
, should-not-typecheck >= 2.1.0 && < 2.2
170170
, temporary >= 1.3 && < 1.4
171171
, wai-extra >= 3.0.24.3 && < 3.1

servant/servant.cabal

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ library
110110
, bifunctors >= 5.5.3 && < 5.6
111111
, case-insensitive >= 1.2.0.11 && < 1.3
112112
, deepseq >= 1.4.2.0 && < 1.5
113-
, http-media >= 0.7.1.3 && < 0.8
113+
, http-media >= 0.7.1.3 && < 0.9
114114
, http-types >= 0.12.2 && < 0.13
115115
, mmorph >= 1.1.2 && < 1.2
116116
, network-uri >= 2.6.1.0 && < 2.7
117-
, QuickCheck >= 2.12.6.1 && <2.13
117+
, QuickCheck >= 2.12.6.1 && < 2.14
118118
, string-conversions >= 0.4.0.1 && < 0.5
119119
, tagged >= 0.8.6 && < 0.9
120120
, vault >= 0.3.1.2 && < 0.4
@@ -161,6 +161,7 @@ test-suite spec
161161
, base-compat
162162
, aeson
163163
, bytestring
164+
, http-media
164165
, mtl
165166
, servant
166167
, string-conversions
@@ -170,7 +171,7 @@ test-suite spec
170171
-- Additonal dependencies
171172
build-depends:
172173
hspec >= 2.6.0 && < 2.8
173-
, QuickCheck >= 2.12.6.1 && < 2.13
174+
, QuickCheck >= 2.12.6.1 && < 2.14
174175
, quickcheck-instances >= 0.3.19 && < 0.4
175176

176177
build-tool-depends:

servant/src/Servant/Types/SourceT.hs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ instance Functor m => Semigroup (SourceT m a) where
102102
-- fromStepT (Effect (Just Stop))
103103
instance Functor m => Monoid (SourceT m a) where
104104
mempty = fromStepT mempty
105+
mappend = (<>)
105106

106107
-- | Doesn't generate 'Error' constructors. 'SourceT' doesn't shrink.
107108
instance (QC.Arbitrary a, Monad m) => QC.Arbitrary (SourceT m a) where
@@ -179,6 +180,7 @@ instance Functor m => Semigroup (StepT m a) where
179180
--
180181
instance Functor m => Monoid (StepT m a) where
181182
mempty = Stop
183+
mappend = (<>)
182184

183185
-- | Doesn't generate 'Error' constructors.
184186
instance (QC.Arbitrary a, Monad m) => QC.Arbitrary (StepT m a) where

servant/test/Servant/API/ContentTypesSpec.hs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
{-# LANGUAGE CPP #-}
12
{-# LANGUAGE DataKinds #-}
23
{-# LANGUAGE DeriveGeneric #-}
34
{-# LANGUAGE MultiParamTypeClasses #-}
@@ -20,7 +21,7 @@ import Data.Either
2021
import Data.Function
2122
(on)
2223
import Data.List
23-
(maximumBy)
24+
(sortBy)
2425
import qualified Data.List.NonEmpty as NE
2526
import Data.Maybe
2627
(fromJust, isJust, isNothing)
@@ -134,17 +135,29 @@ spec = describe "Servant.API.ContentTypes" $ do
134135
== Just ("application/json;charset=utf-8", encode x)
135136

136137
it "respects the Accept spec ordering" $ do
137-
let highest a b c = maximumBy (compare `on` snd)
138+
let highest a b c = last $ sortBy (compare `on` snd)
139+
-- when qualities are same, http-media-0.8 picks first; 0.7 last.
140+
#if MIN_VERSION_http_media(0,8,0)
141+
[ ("text/plain;charset=utf-8", c)
142+
, ("application/json;charset=utf-8", b)
143+
, ("application/octet-stream", a)
144+
]
145+
#else
138146
[ ("application/octet-stream", a)
139147
, ("application/json;charset=utf-8", b)
140148
, ("text/plain;charset=utf-8", c)
141149
]
150+
#endif
142151
let acceptH a b c = addToAccept (Proxy :: Proxy OctetStream) a $
143-
addToAccept (Proxy :: Proxy JSON) b $
144-
addToAccept (Proxy :: Proxy PlainText ) c ""
152+
addToAccept (Proxy :: Proxy JSON) b $
153+
addToAccept (Proxy :: Proxy PlainText ) c $
154+
""
145155
let val a b c i = handleAcceptH (Proxy :: Proxy '[OctetStream, JSON, PlainText])
146156
(acceptH a b c) (i :: Int)
147-
property $ \a b c i -> fst (fromJust $ val a b c i) == fst (highest a b c)
157+
property $ \a b c i ->
158+
let acc = acceptH a b c
159+
in counterexample (show acc) $
160+
fst (fromJust $ val a b c i) === fst (highest a b c)
148161

149162
describe "handleCTypeH" $ do
150163

0 commit comments

Comments
 (0)