Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Upgrade to latest enumerator, which fixes a bug in catchError

  • Loading branch information...
commit 484393975288e554b128fdca6d83fb919c0300d5 1 parent 4dad391
@gregorycollins gregorycollins authored
View
4 snap-core.cabal
@@ -1,5 +1,5 @@
name: snap-core
-version: 0.5.1.4
+version: 0.5.2
synopsis: Snap: A Haskell Web Framework (Core)
description:
@@ -138,7 +138,7 @@ Library
deepseq >= 1.1 && <1.2,
directory,
dlist >= 0.5 && < 0.6,
- enumerator >= 0.4.8 && < 0.5,
+ enumerator >= 0.4.13.1 && < 0.5,
filepath,
MonadCatchIO-transformers >= 0.2.1 && < 0.3,
mtl == 2.0.*,
View
30 src/Snap/Util/FileUploads.hs
@@ -174,15 +174,24 @@ handleFileUploads tmpdir uploadPolicy partPolicy handler = do
retVal (_,x) = (partInfo, Right x)
takeIt maxSize = do
+ debug "handleFileUploads/takeIt: begin"
let it = fmap retVal $
joinI' $
+ iterateeDebugWrapper "takeNoMoreThan" $
takeNoMoreThan maxSize $$
fileReader uploadedFiles tmpdir partInfo
- it `catches` [ Handler $ \(_ :: TooManyBytesReadException) ->
- (skipToEof >> tooMany maxSize)
- , Handler $ \(e :: SomeException) -> throw e
- ]
+ it `catches` [
+ Handler $ \(_ :: TooManyBytesReadException) -> do
+ debug $ "handleFileUploads/iter: " ++
+ "caught TooManyBytesReadException"
+ skipToEof
+ tooMany maxSize
+ , Handler $ \(e :: SomeException) -> do
+ debug $ "handleFileUploads/iter: caught " ++ show e
+ debug "handleFileUploads/iter: rethrowing"
+ throw e
+ ]
tooMany maxSize =
return ( partInfo
@@ -267,6 +276,7 @@ handleMultipart uploadPolicy origPartHandler = do
(minimumUploadSeconds uploadPolicy)
m
`catchError` \e -> do
+ debug $ "rateLimit: caught " ++ show e
let (me::Maybe RateTooSlowException) = fromException e
maybe (throwError e)
terminateConnection
@@ -551,10 +561,15 @@ captureVariableOrReadFile maxSize fileHandler partInfo =
return $ Capture fieldName var
handler e = do
+ debug $ "captureVariableOrReadFile/handler: caught " ++ show e
let m = fromException e :: Maybe TooManyBytesReadException
case m of
- Nothing -> throwError e
- Just _ -> throwError $ PolicyViolationException $
+ Nothing -> do
+ debug "didn't expect this error, rethrowing"
+ throwError e
+ Just _ -> do
+ debug "rethrowing as PolicyViolationException"
+ throwError $ PolicyViolationException $
T.concat [ "form input '"
, TE.decodeUtf8 fieldName
, "' exceeded maximum permissible size ("
@@ -574,6 +589,7 @@ fileReader :: UploadedFiles
-> PartInfo
-> Iteratee ByteString IO (PartInfo, FilePath)
fileReader uploadedFiles tmpdir partInfo = do
+ debug "fileReader: begin"
(fn, h) <- openFileForUpload uploadedFiles tmpdir
let i = iterateeDebugWrapper "fileReader" $ iter fn h
i `catch` \(e::SomeException) -> throwError e
@@ -630,6 +646,7 @@ internalHandleMultipart boundary clientHandler = go `catch` errorHandler
iterParser pHeadersWithSeparator
handler e = do
+ debug $ "internalHandleMultipart/takeHeaders: caught " ++ show e
let m = fromException e :: Maybe TooManyBytesReadException
case m of
Nothing -> throwError e
@@ -639,6 +656,7 @@ internalHandleMultipart boundary clientHandler = go `catch` errorHandler
--------------------------------------------------------------------------
iter = do
hdrs <- takeHeaders
+ debug $ "internalHandleMultipart/iter: got headers"
-- are we using mixed?
let (contentType, mboundary) = getContentType hdrs
View
2  test/snap-core-testsuite.cabal
@@ -36,7 +36,7 @@ Executable testsuite
dlist >= 0.5 && < 0.6,
filepath,
HUnit >= 1.2 && < 2,
- enumerator >= 0.4.7 && <0.5,
+ enumerator >= 0.4.13.1 && < 0.5,
MonadCatchIO-transformers >= 0.2 && < 0.3,
mtl >= 2 && <3,
old-locale,
Please sign in to comment.
Something went wrong with that request. Please try again.