Use comma rather than semicolon to split header values (#698)

This commit is contained in:
Joe Nelson
2016-08-21 15:26:00 -07:00
committed by GitHub
parent 6f737056a2
commit 7278507c42
5 changed files with 8 additions and 7 deletions
+1
View File
@@ -20,6 +20,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
### Changed
- Use HTTP 400 for raise\_exception - @begriffs
- Remove non-OpenAPI schema description - @begriffs
- Use comma rather than semicolon to separate Prefer header values - @begriffs
## [0.3.2.0] - 2016-06-10
+1 -1
View File
@@ -176,7 +176,7 @@ userApiRequest schema req reqBody =
hasPrefer val = any (\(h,v) -> h == "Prefer" && val `elem` split v) hdrs
where
split :: BS.ByteString -> [Text]
split = map T.strip . T.split (==';') . toS
split = map T.strip . T.split (==',') . toS
singular = hasPrefer "plurality=singular"
representation
| hasPrefer "return=representation" = Full
+1 -1
View File
@@ -164,7 +164,7 @@ makeGetParams cs =
makePostParams :: Text -> [Param]
makePostParams tn =
[ makePreferParam ["return=representation", "return=representation;plurality=singular",
[ makePreferParam ["return=representation", "return=representation,plurality=singular",
"return=minimal", "return=none"]
, (mempty :: Param)
& name .~ "body"
+4 -4
View File
@@ -403,7 +403,7 @@ spec = do
_ <- post "/addresses" [json| { id: 97, address: "A Street" } |]
p <- request methodPatch
"/addresses?id=eq.97"
[("Prefer", "return=representation;plurality=singular")]
[("Prefer", "return=representation,plurality=singular")]
[json| { address: "B Street" } |]
liftIO $ simpleBody p `shouldBe` [str|{"id":97,"address":"B Street"}|]
it "raises an error when attempting to update multiple entities with plurality=singular" $ do
@@ -411,19 +411,19 @@ spec = do
_ <- post "/addresses" [json| { id: 99, address: "yyy" } |]
p <- request methodPatch
"/addresses?id=gt.0"
[("Prefer", "return=representation;plurality=singular")]
[("Prefer", "return=representation,plurality=singular")]
[json| { address: "zzz" } |]
liftIO $ simpleStatus p `shouldBe` status400
it "can provide a singular representation when creating one entity" $ do
p <- request methodPost
"/addresses"
[("Prefer", "return=representation;plurality=singular")]
[("Prefer", "return=representation,plurality=singular")]
[json| [ { id: 100, address: "xxx" } ] |]
liftIO $ simpleBody p `shouldBe` [str|{"id":100,"address":"xxx"}|]
it "raises an error when attempting to create multiple entities with plurality=singular" $ do
p <- request methodPost
"/addresses"
[("Prefer", "return=representation;plurality=singular")]
[("Prefer", "return=representation,plurality=singular")]
[json| [ { id: 100, address: "xxx" }, { id: 101, address: "xxx" } ] |]
liftIO $ simpleStatus p `shouldBe` status400
+1 -1
View File
@@ -286,7 +286,7 @@ spec = do
}
it "can combine multiple prefer values" $
request methodGet "/items?id=eq.5" [("Prefer","plurality=singular ; future=new; count=none")] ""
request methodGet "/items?id=eq.5" [("Prefer","plurality=singular , future=new, count=none")] ""
`shouldRespondWith` ResponseMatcher {
matchBody = Just [json| {"id":5} |]
, matchStatus = 200