Permalink
Browse files

Keep media type parameters in Accept

Closes #117
  • Loading branch information...
singpolyma committed Oct 9, 2012
1 parent edfa0ac commit 51b81d3e42a55394ec977619566c693422657233
Showing with 5 additions and 4 deletions.
  1. +5 −4 wai-extra/Network/Wai/Parse.hs
@@ -64,13 +64,14 @@ parseHttpAccept = map fst
rcompare :: Double -> Double -> Ordering
rcompare = flip compare
grabQ s =
- let (s', q) = breakDiscard 59 s -- semicolon
- (_, q') = breakDiscard 61 q -- equals sign
- in (trimWhite s', readQ $ trimWhite q')
+ -- Stripping all spaces may be too harsh.
+ -- Maybe just strip either side of semicolon?
+ let (s', q) = S.breakSubstring ";q=" (S.filter (/=0x20) s) -- 0x20 is space
+ q' = S.takeWhile (/=0x3B) (S.drop 3 q) -- 0x3B is semicolon
+ in (s', readQ q')
readQ s = case reads $ S8.unpack s of
(x, _):_ -> x
_ -> 1.0
- trimWhite = S.dropWhile (== 32) -- space
-- | Store uploaded files in memory
lbsBackEnd :: Monad m => ignored1 -> ignored2 -> Sink S.ByteString m L.ByteString

0 comments on commit 51b81d3

Please sign in to comment.