This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "snap-core".
The branch, 0.3 has been updated
via 6244a6cb25d353d75cb8193ebb50c6fc066c462b (commit)
via c797f4c6f0c2b0627328a5d6bd77c7cae47c7bfb (commit)
via 1cc5c22f880c9132fe8c10ee9b697c3d10ba4954 (commit)
via 26e05da3a88a32091649ccf2d77aa2b2cdf858cc (commit)
via ef6c351c14594517dea3a5159d75af38c47700f5 (commit)
via 6dc149cd34142785d1460a757b219008a9d16fe6 (commit)
from ec5a96bbe134bd7e64570ac8b39f25de498a1651 (commit)
Summary of changes:
snap-core.cabal | 2 +
src/Snap/Internal/Http/Types.hs | 17 +++-
src/Snap/Internal/Parsing.hs | 26 +++++
src/Snap/Internal/Types.hs | 21 ++++-
src/Snap/Iteratee.hs | 92 ++++++++++++++++--
src/Snap/Types.hs | 2 +
src/Snap/Util/FileServe.hs | 162 +++++++++++++++++++++++++++++--
src/Snap/Util/GZip.hs | 14 +---
test/runTestsAndCoverage.sh | 5 +-
test/snap-core-testsuite.cabal | 1 +
test/suite/Snap/Types/Tests.hs | 4 +-
test/suite/Snap/Util/FileServe/Tests.hs | 35 ++++++-
12 files changed, 337 insertions(+), 44 deletions(-)
create mode 100644 src/Snap/Internal/Parsing.hs
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 6244a6cb25d353d75cb8193ebb50c6fc066c462b
Merge: ec5a96b c797f4c
Author: Mighty Byte <[email protected]>
Date: Sat Oct 2 12:00:16 2010 -0400
Merge branch 'master' into 0.3
Conflicts:
snap-core.cabal
src/Snap/Internal/Types.hs
src/Snap/Iteratee.hs
diff --cc snap-core.cabal
index 00fef66,1f264d3..2d7de8a
--- a/snap-core.cabal
+++ b/snap-core.cabal
@@@ -133,7 -140,7 +133,8 @@@ Librar
Snap.Util.GZip
other-modules:
+ Snap.Internal.Instances,
+ Snap.Internal.Parsing,
Snap.Internal.Routing,
Snap.Internal.Types
diff --cc src/Snap/Internal/Types.hs
index 0128e1b,89dc694..176882c
--- a/src/Snap/Internal/Types.hs
+++ b/src/Snap/Internal/Types.hs
@@@ -8,31 -6,30 +8,32 @@@
module Snap.Internal.Types where
------------------------------------------------------------------------------
-import Control.Applicative
-import Control.Exception (throwIO, ErrorCall(..))
-import Control.Monad.CatchIO
-import Control.Monad.State.Strict
-import Data.ByteString.Char8 (ByteString)
-import qualified Data.ByteString.Char8 as S
-import qualified Data.ByteString.Lazy.Char8 as L
-import qualified Data.CIByteString as CIB
-import Data.Int
-import Data.IORef
-import qualified Data.Iteratee as Iter
-import Data.Maybe
-import qualified Data.Text as T
-import qualified Data.Text.Encoding as T
-import qualified Data.Text.Lazy as LT
-import qualified Data.Text.Lazy.Encoding as LT
+import "MonadCatchIO-transformers" Control.Monad.CatchIO
+
+import Control.Applicative
+import Control.Exception (throwIO, ErrorCall(..))
+import Control.Monad
+import "monads-fd" Control.Monad.State
+import Data.ByteString.Char8 (ByteString)
+import qualified Data.ByteString.Char8 as S
+import qualified Data.ByteString.Lazy.Char8 as L
+import qualified Data.CIByteString as CIB
++import Data.Int
+import Data.IORef
+import qualified Data.Iteratee as Iter
+import Data.Maybe
+import qualified Data.Text as T
+import qualified Data.Text.Encoding as T
+import qualified Data.Text.Lazy as LT
+import qualified Data.Text.Lazy.Encoding as LT
+import Data.Typeable
+import Prelude hiding (catch)
-import Data.Typeable
------------------------------------------------------------------------------
-import Snap.Iteratee hiding (Enumerator)
-import Snap.Internal.Http.Types
-import Snap.Internal.Debug
-import Snap.Internal.Iteratee.Debug
+import Snap.Iteratee hiding (Enumerator, filter)
+import Snap.Internal.Http.Types
+import Snap.Internal.Iteratee.Debug
------------------------------------------------------------------------------
diff --cc src/Snap/Iteratee.hs
index a6176b5,2b87aab..68575f6
--- a/src/Snap/Iteratee.hs
+++ b/src/Snap/Iteratee.hs
@@@ -1,8 -1,9 +1,10 @@@
+{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE CPP #-}
+ {-# LANGUAGE DeriveDataTypeable #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE PackageImports #-}
+ {-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeSynonymInstances #-}
-- | Snap Framework type aliases and utilities for iteratees. Note that as a
@@@ -47,7 -50,8 +51,8 @@@ module Snap.Iterate
------------------------------------------------------------------------------
import Control.Monad
-import Control.Monad.CatchIO
+import "MonadCatchIO-transformers" Control.Monad.CatchIO
+ import Control.Exception (Exception, SomeException)
import Data.ByteString (ByteString)
import qualified Data.ByteString as S
import qualified Data.ByteString.Unsafe as S
diff --cc src/Snap/Util/FileServe.hs
index 4d68a5d,41afc2d..b14191d
--- a/src/Snap/Util/FileServe.hs
+++ b/src/Snap/Util/FileServe.hs
@@@ -216,13 -223,13 +226,14 @@@ fileServeSingle fp
------------------------------------------------------------------------------
-- | Same as 'fileServeSingle', with control over the MIME mapping used.
-fileServeSingle' :: ByteString -- ^ MIME type mapping
+fileServeSingle' :: MonadSnap m
+ => ByteString -- ^ MIME type mapping
-> FilePath -- ^ path to file
- -> Snap ()
+ -> m ()
fileServeSingle' mime fp = do
req <- getRequest
-
+
+ -- check "If-Modified-Since" and "If-Range" headers
let mbH = getHeader "if-modified-since" req
mbIfModified <- liftIO $ case mbH of
Nothing -> return Nothing
@@@ -236,18 -248,38 +252,38 @@@
let sz = fromIntegral $ fileSize filestat
lm <- liftIO $ formatHttpTime mt
+ -- ok, at this point we know the last-modified time and the
+ -- content-type. set those.
modifyResponse $ setHeader "Last-Modified" lm
+ . setHeader "Accept-Ranges" "bytes"
. setContentType mime
- . setContentLength sz
- sendFile fp
- where
- --------------------------------------------------------------------------
- chkModificationTime mt lt = when (mt <= lt) notModified
+ -- now check: is this a range request? If there is an 'If-Range' header
+ -- with an old modification time we skip this check and send a 200
response
+ let skipRangeCheck = maybe (False)
+ (\lt -> mt > lt)
+ mbIfRange
+
+
+ -- checkRangeReq checks for a Range: header in the request and sends a
+ -- partial response if it matches.
+ wasRange <- if skipRangeCheck
+ then return False
- else checkRangeReq req fp sz
++ else liftSnap $ checkRangeReq req fp sz
+
+ dbg $ "was this a range request? " ++ Prelude.show wasRange
+
+ -- if we didn't have a range request, we just do normal sendfile
+ unless wasRange $ do
+ modifyResponse $ setResponseCode 200
+ . setContentLength sz
- sendFile fp
++ liftSnap $ sendFile fp
+
+ where
--------------------------------------------------------------------------
notModified = finishWith $
- setResponseStatus 304 "Not Modified" emptyResponse
+ setResponseCode 304 emptyResponse
------------------------------------------------------------------------------
-----------------------------------------------------------------------
hooks/post-receive
--
snap-core
_______________________________________________
Snap mailing list
[email protected]
http://mailman-mail5.webfaction.com/listinfo/snap