Skip to content

assume a default content type of text/html when negotiating content #1024

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions src/Distribution/Server/Framework/Resource.hs
Original file line number Diff line number Diff line change
Expand Up @@ -521,14 +521,11 @@ negotiateContent :: (FilterMonad Response m, ServerMonad m)
negotiateContent def available = do
when (length available > 1) $
setHeaderM "Vary" "Accept"
maccept <- getHeaderM "Accept"
case maccept of
Nothing -> return def
Just accept ->
return $ fromMaybe def $ listToMaybe $ catMaybes
accept <- maybe "text/html" BS.unpack <$> getHeaderM "Accept"
return $ fromMaybe def $ listToMaybe $ catMaybes
[ simpleContentTypeMapping ct
>>= \f -> find (\x -> fst x == f) available
| let acceptable = parseContentAccept (BS.unpack accept)
| let acceptable = parseContentAccept accept
, ct <- acceptable ]
where
-- This is rather a non-extensible hack
Expand Down Expand Up @@ -597,4 +594,3 @@ addServerNode trunk response tree = treeFold trunk (ServerTree (Just response) M
treeFold :: Monoid a => BranchPath -> ServerTree a -> ServerTree a -> ServerTree a
treeFold [] newChild topLevel = combine newChild topLevel
treeFold (sdir:otherTree) newChild topLevel = treeFold otherTree (ServerTree Nothing $ Map.singleton sdir newChild) topLevel