packages feed

happstack-server 7.0.5 → 7.0.6

raw patch · 3 files changed

+34/−6 lines, 3 files

Files

happstack-server.cabal view
@@ -1,5 +1,5 @@ Name:                happstack-server-Version:             7.0.5+Version:             7.0.6 Synopsis:            Web related tools and services. Description:         Happstack Server provides an HTTP server and a rich set of functions for routing requests, handling query parameters, generating responses, working with cookies, serving files, and more. For in-depth documentation see the Happstack Crash Course <http://happstack.com/docs/crashcourse/index.html> License:             BSD3@@ -42,6 +42,7 @@                        Happstack.Server.Internal.Types                        Happstack.Server.Internal.Listen                        Happstack.Server.Internal.LowLevel+                       Happstack.Server.Internal.LogFormat                        Happstack.Server.Internal.MessageWrap                        Happstack.Server.Internal.Multipart                        Happstack.Server.Internal.Socket@@ -61,7 +62,6 @@   Other-modules:                        Happstack.Server.Internal.Clock                        Happstack.Server.Internal.LazyLiner-                       Happstack.Server.Internal.LogFormat                        Happstack.Server.Internal.RFC822Headers                        Happstack.Server.Internal.SocketTH                        Happstack.Server.SURI.ParseURI
src/Happstack/Server/Internal/Types.hs view
@@ -68,11 +68,20 @@       _               -> False  -- | Should the connection be used for further messages after this.--- | isHTTP1_0 && hasKeepAlive || isHTTP1_1 && hasNotConnectionClose+-- isHTTP1_0 && hasKeepAlive || isHTTP1_1 && hasNotConnectionClose+--+-- In addition to this rule All 1xx (informational), 204 (no content),+-- and 304 (not modified) responses MUST NOT include a message-body+-- and therefore are eligible for connection keep-alive. continueHTTP :: Request -> Response -> Bool-continueHTTP rq res =-    (isHTTP1_0 rq && checkHeaderBS connectionC keepaliveC rq   && rsfLength (rsFlags res) == ContentLength) ||-    (isHTTP1_1 rq && not (checkHeaderBS connectionC closeC rq) && rsfLength (rsFlags res) /= NoContentLength)+continueHTTP rq rs =+    (isHTTP1_0 rq && checkHeaderBS connectionC keepaliveC rq   &&+       (rsfLength (rsFlags rs) == ContentLength || isNoMessageBodyResponse rs)) ||+    (isHTTP1_1 rq && not (checkHeaderBS connectionC closeC rq) &&+       (rsfLength (rsFlags rs) /= NoContentLength || isNoMessageBodyResponse rs))+  where+    isNoMessageBodyCode code = (code >= 100 && code <= 199) || code == 204 || code == 304+    isNoMessageBodyResponse rs = isNoMessageBodyCode (rsCode rs) && L.null (rsBody rs)  -- | function to log access requests (see also: 'logMAccess') -- type LogAccess time =
+ tests/Test.hs view
@@ -0,0 +1,19 @@+module Main where++import Happstack.Server.Tests (allTests)+import Test.HUnit (errors, failures, putTextToShowS,runTestText, runTestTT)+import System.Exit (exitFailure)+import System.IO (hIsTerminalDevice, stdout)++-- |A simple driver for running the local test suite.+main :: IO ()+main =+    do c <- do istty <- hIsTerminalDevice stdout+               if istty+                  then runTestTT allTests+                  else do (c,st) <- runTestText putTextToShowS allTests+                          putStrLn (st "")+                          return c+       case (failures c) + (errors c) of+         0 -> return ()+         _ -> exitFailure