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-server".
The branch, master has been updated
via 21319aef0cbd8f8fdbef81130fb87930e99fcedc (commit)
from 30f087131a25d32a361464f03c1c3a30b1811372 (commit)
Summary of changes:
test/snap-server-testsuite.cabal | 73 ++++++++++++++++++++
test/suite/Snap/Internal/Http/Server/Tests.hs | 22 ++++++
test/testserver/Main.hs | 61 ++++++++++++++++
.../Paths_snap_server.hs | 0
test/testserver/static/hello.txt | 1 +
5 files changed, 157 insertions(+), 0 deletions(-)
create mode 100644 test/testserver/Main.hs
copy test/{pongserver => testserver}/Paths_snap_server.hs (100%)
create mode 100644 test/testserver/static/hello.txt
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 21319aef0cbd8f8fdbef81130fb87930e99fcedc
Author: Mighty Byte <[email protected]>
Date: Thu Jul 15 01:03:27 2010 -0400
Added 304 test. Created new testserver executable for black box testing.
diff --git a/test/snap-server-testsuite.cabal b/test/snap-server-testsuite.cabal
index 7ba4e5d..0ef4356 100644
--- a/test/snap-server-testsuite.cabal
+++ b/test/snap-server-testsuite.cabal
@@ -141,6 +141,79 @@ Executable pongserver
-fno-warn-unused-do-bind
ghc-prof-options: -prof -auto-all
+Executable testserver
+ hs-source-dirs: testserver ../src
+ main-is: Main.hs
+
+ build-depends:
+ QuickCheck >= 2,
+ array >= 0.3 && <0.4,
+ attoparsec >= 0.8.0.2 && < 0.9,
+ attoparsec-iteratee >= 0.1.1 && <0.2,
+ base >= 4 && < 5,
+ bytestring,
+ bytestring-nums >= 0.3.1 && < 0.4,
+ bytestring-show >= 0.3.2 && < 0.4,
+ cereal >= 0.2 && < 0.3,
+ containers,
+ directory-tree,
+ dlist >= 0.5 && < 0.6,
+ filepath,
+ haskell98,
+ HUnit >= 1.2 && < 2,
+ monads-fd,
+ old-locale,
+ parallel > 2,
+ iteratee >= 0.3.1 && < 0.4,
+ murmur-hash >= 0.1 && < 0.2,
+ network == 2.2.1.7,
+ network-bytestring >= 0.1.2 && < 0.2,
+ snap-core >= 0.2.7 && <0.3,
+ time,
+ transformers,
+ unix-compat,
+ vector >= 0.6.0.1 && < 0.7
+
+ if flag(portable) || os(windows)
+ cpp-options: -DPORTABLE
+ else
+ build-depends: unix
+
+ if flag(libev)
+ build-depends: hlibev >= 0.2.5 && < 0.3
+ other-modules: Snap.Internal.Http.Server.LibevBackend
+ cpp-options: -DLIBEV
+ else
+ build-depends: network-bytestring >= 0.1.2 && < 0.2,
+ PSQueue >= 1.1 && <1.2
+
+ other-modules: Snap.Internal.Http.Server.SimpleBackend
+
+ if os(linux) && !flag(portable)
+ cpp-options: -DLINUX -DHAS_SENDFILE
+ other-modules:
+ System.SendFile,
+ System.SendFile.Linux
+
+ if os(darwin) && !flag(portable)
+ cpp-options: -DOSX -DHAS_SENDFILE
+ other-modules:
+ System.SendFile,
+ System.SendFile.Darwin
+
+ if os(freebsd) && !flag(portable)
+ cpp-options: -DFREEBSD -DHAS_SENDFILE
+ other-modules:
+ System.SendFile,
+ System.SendFile.FreeBSD
+
+ if flag(portable) || os(windows)
+ cpp-options: -DPORTABLE
+
+ ghc-options: -Wall -O2 -fwarn-tabs -funbox-strict-fields -threaded
+ -fno-warn-unused-do-bind
+ ghc-prof-options: -prof -auto-all
+
Executable benchmark
hs-source-dirs: benchmark ../src
main-is: Benchmark.hs
diff --git a/test/suite/Snap/Internal/Http/Server/Tests.hs
b/test/suite/Snap/Internal/Http/Server/Tests.hs
index eee73ae..6f0302c 100644
--- a/test/suite/Snap/Internal/Http/Server/Tests.hs
+++ b/test/suite/Snap/Internal/Http/Server/Tests.hs
@@ -46,6 +46,7 @@ tests = [ testHttpRequest1
, testHttpResponse1
, testHttpResponse2
, testHttpResponse3
+ , testHttpResponse4
, testHttp1
, testHttp2
, testPartialParse
@@ -378,6 +379,27 @@ testHttpResponse3 = testCase "HttpResponse3" $ do
rsp3 = setContentType "text/plain" $ (rsp2 { rspHttpVersion = (1,1) })
+testHttpResponse4 :: Test
+testHttpResponse4 = testCase "HttpResponse4" $ do
+ let onSendFile = \f _ -> enumFile f copyingStream2stream >>= run
+
+ buf <- mkIterateeBuffer
+
+ b <- run $ rsm $
+ sendResponse rsp1 copyingStream2stream buf (return ()) onSendFile >>=
+ return . fromWrap . snd
+
+ assertEqual "http response" (L.concat [
+ "HTTP/1.0 304 Test\r\n"
+ , "Transfer-Encoding: chunked\r\n\r\n"
+ , "Content-Length: 0\r\n\r\n"
+ ]) b
+
+ where
+ rsp1 = setResponseStatus 304 "Test" $
+ emptyResponse { rspHttpVersion = (1,0) }
+
+
-- httpServe "127.0.0.1" 8080 "localhost" pongServer
diff --git a/test/testserver/Main.hs b/test/testserver/Main.hs
new file mode 100644
index 0000000..d29f8b3
--- /dev/null
+++ b/test/testserver/Main.hs
@@ -0,0 +1,61 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Main where
+
+import Control.Concurrent
+
+import Snap.Iteratee
+import Snap.Types
+import Snap.Http.Server
+import Snap.Util.FileServe
+
+{-
+
+/pong
+/fileserve
+/echo
+pipelined POST requests
+slowloris attack / timeout test
+
+-}
+
+pongHandler :: Snap ()
+pongHandler = modifyResponse $ setResponseBody (enumBS "PONG") .
+ setContentType "text/plain" .
+ setContentLength 4
+
+echoHandler :: Snap ()
+echoHandler = do
+ req <- getRequest
+ writeBS $ rqPathInfo req
+
+responseHandler = do
+ code <- getParam "code"
+ case code of
+ Nothing -> undefined
+ Just code -> f code
+ where
+ f "300" = undefined
+ f "304" = undefined
+
+handlers :: Snap ()
+handlers =
+ route [ ("pong", pongHandler)
+ , ("echo", echoHandler)
+ , ("fileserve", fileServe "static")
+ , ("respcode/:code", responseHandler)
+ ]
+
+main :: IO ()
+main = do
+ m <- newEmptyMVar
+
+ forkIO $ go m
+ takeMVar m
+
+ return ()
+
+ where
+ go m = do
+ httpServe "*" 3000 "localhost" Nothing Nothing handlers
+ putMVar m ()
+
diff --git a/test/testserver/Paths_snap_server.hs
b/test/testserver/Paths_snap_server.hs
new file mode 100644
index 0000000..dc7b284
--- /dev/null
+++ b/test/testserver/Paths_snap_server.hs
@@ -0,0 +1,9 @@
+module Paths_snap_server (
+ version
+ ) where
+
+import Data.Version (Version(..))
+
+version :: Version
+version = Version {versionBranch = [0,0,0], versionTags = ["unknown"]}
+
diff --git a/test/testserver/static/hello.txt b/test/testserver/static/hello.txt
new file mode 100644
index 0000000..3b18e51
--- /dev/null
+++ b/test/testserver/static/hello.txt
@@ -0,0 +1 @@
+hello world
-----------------------------------------------------------------------
hooks/post-receive
--
snap-server
_______________________________________________
Snap mailing list
[email protected]
http://mailman-mail5.webfaction.com/listinfo/snap