Expose Content-Range response header (and others) in CORS

Fixes #148
This commit is contained in:
Joe Nelson
2015-02-16 19:35:25 -08:00
parent 92daa7d11a
commit 337b49f386
2 changed files with 12 additions and 0 deletions
+4
View File
@@ -45,6 +45,10 @@ corsPolicy req = case lookup "origin" headers of
Just origin -> Just defaultCorsPolicy {
corsOrigins = Just ([origin], True)
, corsRequestHeaders = "Authentication":accHeaders
, corsExposedHeaders = Just [
"Content-Encoding", "Content-Location", "Content-Range", "Content-Type"
, "Date", "Server", "Transfer-Encoding", "Range-Unit"
]
}
Nothing -> Nothing
where
+8
View File
@@ -53,6 +53,14 @@ spec = around withApp $ describe "CORS" $ do
r <- request methodOptions "/" preflightHeaders ""
liftIO $ simpleBody r `shouldBe` ""
describe "regular request" $
it "exposes necesssary response headers" $ do
r <- request methodGet "/items" [("Origin", "http://example.com")] ""
liftIO $ simpleHeaders r `shouldSatisfy` matchHeader
"Access-Control-Expose-Headers"
"Content-Encoding, Content-Location, Content-Range, Content-Type, \
\Date, Server, Transfer-Encoding, Range-Unit"
describe "postflight request" $
it "allows INFO body through even with CORS request headers present" $ do
r <- request methodOptions "/items" normalCors ""