@@ -64,6 +64,7 @@ import Control.Exception
6464 , fromException
6565 )
6666import Control.Concurrent (forkIO, threadWaitWrite)
67+import qualified Data.Char as C
6768import Data.Maybe (fromMaybe)
6869
6970import Data.Typeable (Typeable)
@@ -215,10 +216,7 @@ parseRequest' port (firstLine:otherLines) remoteHost' = do
215216 let len =
216217 case lookup "content-length" heads of
217218 Nothing -> 0
218− Just bs ->
219− case reads $ B.unpack bs of -- FIXME could probably be optimized
220− (x, _):_ -> x
221− [] -> 0
219+ Just bs -> fromIntegral $ B.foldl' (\i c -> i * 10 + C.digitToInt c) 0 $ B.takeWhile C.isDigit bs
222220 let serverName' = takeUntil 58 host -- ':'
223221 -- FIXME isolate takes an Integer instead of Int or Int64. If this is a
224222 -- performance penalty, we may need our own version.