happstack-server 7.9.2.1 → 7.9.2.2
raw patch · 11 files changed
+37/−65 lines, 11 filesdep −old-localedep −transformers-compatdep ~timePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies removed: old-locale, transformers-compat
Dependency ranges changed: time
API changes (from Hackage documentation)
- Happstack.Server.Error: errorHandlerSP :: Monad m => (Request -> e -> WebT m a) -> ServerPartT (ExceptT e m) a -> ServerPartT m a
+ Happstack.Server.Error: errorHandlerSP :: forall (m :: Type -> Type) e a. Monad m => (Request -> e -> WebT m a) -> ServerPartT (ExceptT e m) a -> ServerPartT m a
- Happstack.Server.Error: simpleErrorHandler :: Monad m => String -> ServerPartT m Response
+ Happstack.Server.Error: simpleErrorHandler :: forall (m :: Type -> Type). Monad m => String -> ServerPartT m Response
- Happstack.Server.Internal.Monads: FilterT :: WriterT (FilterFun a) m b -> FilterT a m b
+ Happstack.Server.Internal.Monads: FilterT :: WriterT (FilterFun a) m b -> FilterT a (m :: Type -> Type) b
- Happstack.Server.Internal.Monads: ServerPartT :: ReaderT Request (WebT m) a -> ServerPartT m a
+ Happstack.Server.Internal.Monads: ServerPartT :: ReaderT Request (WebT m) a -> ServerPartT (m :: Type -> Type) a
- Happstack.Server.Internal.Monads: WebT :: ExceptT Response (FilterT Response (MaybeT m)) a -> WebT m a
+ Happstack.Server.Internal.Monads: WebT :: ExceptT Response (FilterT Response (MaybeT m)) a -> WebT (m :: Type -> Type) a
- Happstack.Server.Internal.Monads: [unFilterT] :: FilterT a m b -> WriterT (FilterFun a) m b
+ Happstack.Server.Internal.Monads: [unFilterT] :: FilterT a (m :: Type -> Type) b -> WriterT (FilterFun a) m b
- Happstack.Server.Internal.Monads: [unServerPartT] :: ServerPartT m a -> ReaderT Request (WebT m) a
+ Happstack.Server.Internal.Monads: [unServerPartT] :: ServerPartT (m :: Type -> Type) a -> ReaderT Request (WebT m) a
- Happstack.Server.Internal.Monads: [unWebT] :: WebT m a -> ExceptT Response (FilterT Response (MaybeT m)) a
+ Happstack.Server.Internal.Monads: [unWebT] :: WebT (m :: Type -> Type) a -> ExceptT Response (FilterT Response (MaybeT m)) a
- Happstack.Server.Internal.Monads: anyRequest :: Monad m => WebT m a -> ServerPartT m a
+ Happstack.Server.Internal.Monads: anyRequest :: forall (m :: Type -> Type) a. Monad m => WebT m a -> ServerPartT m a
- Happstack.Server.Internal.Monads: class Monad m => FilterMonad a m | m -> a
+ Happstack.Server.Internal.Monads: class Monad m => FilterMonad a (m :: Type -> Type) | m -> a
- Happstack.Server.Internal.Monads: class Monad m => ServerMonad m
+ Happstack.Server.Internal.Monads: class Monad m => ServerMonad (m :: Type -> Type)
- Happstack.Server.Internal.Monads: class Monad m => WebMonad a m | m -> a
+ Happstack.Server.Internal.Monads: class Monad m => WebMonad a (m :: Type -> Type) | m -> a
- Happstack.Server.Internal.Monads: debugFilter :: (MonadIO m, Show a) => ServerPartT m a -> ServerPartT m a
+ Happstack.Server.Internal.Monads: debugFilter :: forall (m :: Type -> Type) a. (MonadIO m, Show a) => ServerPartT m a -> ServerPartT m a
- Happstack.Server.Internal.Monads: localContext :: Monad m => (WebT m a -> WebT m' a) -> ServerPartT m a -> ServerPartT m' a
+ Happstack.Server.Internal.Monads: localContext :: forall (m :: Type -> Type) a (m' :: Type -> Type). Monad m => (WebT m a -> WebT m' a) -> ServerPartT m a -> ServerPartT m' a
- Happstack.Server.Internal.Monads: multi :: (Monad m, MonadPlus m) => [ServerPartT m a] -> ServerPartT m a
+ Happstack.Server.Internal.Monads: multi :: forall (m :: Type -> Type) a. (Monad m, MonadPlus m) => [ServerPartT m a] -> ServerPartT m a
- Happstack.Server.Internal.Monads: newtype FilterT a m b
+ Happstack.Server.Internal.Monads: newtype FilterT a (m :: Type -> Type) b
- Happstack.Server.Internal.Monads: newtype ServerPartT m a
+ Happstack.Server.Internal.Monads: newtype ServerPartT (m :: Type -> Type) a
- Happstack.Server.Internal.Monads: newtype WebT m a
+ Happstack.Server.Internal.Monads: newtype WebT (m :: Type -> Type) a
- Happstack.Server.Internal.Monads: runServerPartT :: ServerPartT m a -> Request -> WebT m a
+ Happstack.Server.Internal.Monads: runServerPartT :: forall (m :: Type -> Type) a. ServerPartT m a -> Request -> WebT m a
- Happstack.Server.Internal.Monads: type FilterFun a = SetAppend (Dual (Endo a))
+ Happstack.Server.Internal.Monads: type FilterFun a = SetAppend Dual Endo a
- Happstack.Server.Internal.Monads: type UnWebT m a = m (Maybe (Either Response a, FilterFun Response))
+ Happstack.Server.Internal.Monads: type UnWebT (m :: Type -> Type) a = m Maybe (Either Response a, FilterFun Response)
- Happstack.Server.Internal.Monads: withRequest :: (Request -> WebT m a) -> ServerPartT m a
+ Happstack.Server.Internal.Monads: withRequest :: forall (m :: Type -> Type) a. (Request -> WebT m a) -> ServerPartT m a
- Happstack.Server.Internal.Multipart: type FileSaver = -- | tempdir FilePath -> -- | quota Int64 -> -- | filename of field FilePath -> -- | content to save ByteString -> -- | truncated?, saved bytes, saved filename IO (Bool, Int64, FilePath)
+ Happstack.Server.Internal.Multipart: type FileSaver = FilePath -> Int64 -> FilePath -> ByteString -> IO (Bool, Int64, FilePath)
- Happstack.Server.Internal.Types: logMAccess :: forall t. FormatTime t => LogAccess t
+ Happstack.Server.Internal.Types: logMAccess :: FormatTime t => LogAccess t
- Happstack.Server.Internal.Types: type Headers = -- | lowercased name -> (realname, value) Map ByteString HeaderPair
+ Happstack.Server.Internal.Types: type Headers = Map ByteString HeaderPair
- Happstack.Server.Internal.Types: type Host = -- | (hostname, port) (String, Int)
+ Happstack.Server.Internal.Types: type Host = (String, Int)
- Happstack.Server.Internal.Types: type LogAccess time = (String -> String -> time -> String -> Int -> Integer -> String -> String -> IO ())
+ Happstack.Server.Internal.Types: type LogAccess time = String -> String -> time -> String -> Int -> Integer -> String -> String -> IO ()
- Happstack.Server.Monads: class Monad m => FilterMonad a m | m -> a
+ Happstack.Server.Monads: class Monad m => FilterMonad a (m :: Type -> Type) | m -> a
- Happstack.Server.Monads: class (ServerMonad m, WebMonad Response m, FilterMonad Response m, MonadIO m, MonadPlus m, HasRqData m, Monad m, Functor m, Applicative m, Alternative m) => Happstack m
+ Happstack.Server.Monads: class (ServerMonad m, WebMonad Response m, FilterMonad Response m, MonadIO m, MonadPlus m, HasRqData m, Monad m, Functor m, Applicative m, Alternative m) => Happstack (m :: Type -> Type)
- Happstack.Server.Monads: class Monad m => ServerMonad m
+ Happstack.Server.Monads: class Monad m => ServerMonad (m :: Type -> Type)
- Happstack.Server.Monads: class Monad m => WebMonad a m | m -> a
+ Happstack.Server.Monads: class Monad m => WebMonad a (m :: Type -> Type) | m -> a
- Happstack.Server.Monads: data ServerPartT m a
+ Happstack.Server.Monads: data ServerPartT (m :: Type -> Type) a
- Happstack.Server.Monads: type UnWebT m a = m (Maybe (Either Response a, FilterFun Response))
+ Happstack.Server.Monads: type UnWebT (m :: Type -> Type) a = m Maybe (Either Response a, FilterFun Response)
- Happstack.Server.RqData: class HasRqData m
+ Happstack.Server.RqData: class HasRqData (m :: Type -> Type)
- Happstack.Server.SimpleHTTP: runWebT :: forall m b. (Functor m, ToMessage b) => WebT m b -> m (Maybe Response)
+ Happstack.Server.SimpleHTTP: runWebT :: (Functor m, ToMessage b) => WebT m b -> m (Maybe Response)
- Happstack.Server.Types: logMAccess :: forall t. FormatTime t => LogAccess t
+ Happstack.Server.Types: logMAccess :: FormatTime t => LogAccess t
- Happstack.Server.Types: type Headers = -- | lowercased name -> (realname, value) Map ByteString HeaderPair
+ Happstack.Server.Types: type Headers = Map ByteString HeaderPair
- Happstack.Server.Types: type Host = -- | (hostname, port) (String, Int)
+ Happstack.Server.Types: type Host = (String, Int)
- Happstack.Server.Types: type LogAccess time = (String -> String -> time -> String -> Int -> Integer -> String -> String -> IO ())
+ Happstack.Server.Types: type LogAccess time = String -> String -> time -> String -> Int -> Integer -> String -> String -> IO ()
Files
- happstack-server.cabal +7/−6
- src/Happstack/Server/Cookie.hs +4/−4
- src/Happstack/Server/FileServe/BuildingBlocks.hs +4/−10
- src/Happstack/Server/Internal/Clock.hs +2/−9
- src/Happstack/Server/Internal/Cookie.hs +7/−10
- src/Happstack/Server/Internal/LogFormat.hs +0/−5
- src/Happstack/Server/Internal/Types.hs +5/−8
- src/Happstack/Server/Response.hs +1/−6
- src/Happstack/Server/RqData.hs +3/−3
- src/Happstack/Server/SURI.hs +2/−2
- src/Happstack/Server/SimpleHTTP.hs +2/−2
happstack-server.cabal view
@@ -1,5 +1,5 @@ Name: happstack-server-Version: 7.9.2.1+Version: 7.9.2.2 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@@ -13,9 +13,12 @@ Extra-Source-Files: tests/Happstack/Server/Tests.hs README.md tested-with:+ GHC == 9.14.1+ GHC == 9.12.2+ GHC == 9.10.2 GHC == 9.8.2- GHC == 9.6.3- GHC == 9.4.7+ GHC == 9.6.7+ GHC == 9.4.8 GHC == 9.2.8 GHC == 9.0.2 GHC == 8.10.7@@ -91,18 +94,16 @@ html, monad-control >= 1.0 && < 1.1, mtl >= 2.2 && < 2.4,- old-locale, parsec < 4, process, sendfile >= 0.7.1 && < 0.8, system-filepath >= 0.3.1, syb, text >= 0.10 && < 2.2,- time,+ time >= 1.5, threads >= 0.5, transformers >= 0.1.3 && < 0.7, transformers-base >= 0.4 && < 0.5,- transformers-compat >= 0.3 && < 0.8, utf8-string >= 0.3.4 && < 1.1, xhtml < 3000.4, zlib
src/Happstack/Server/Cookie.hs view
@@ -1,4 +1,4 @@-{-# LANGUAGE DeriveDataTypeable, FlexibleContexts #-}+{-# LANGUAGE FlexibleContexts #-} -- | Functions for creating, adding, and expiring cookies. To lookup cookie values see "Happstack.Server.RqData". module Happstack.Server.Cookie ( Cookie(..)@@ -19,7 +19,7 @@ -- | Add the 'Cookie' to 'Response'. -- -- example--- +-- -- > main = simpleHTTP nullConf $ -- > do addCookie Session (mkCookie "name" "value") -- > ok $ "You now have a session cookie."@@ -33,7 +33,7 @@ addHeaderM a v = composeFilter $ \res-> addHeader a v res -- | Add the list 'Cookie' to the 'Response'.--- +-- -- see also: 'addCookie' addCookies :: (MonadIO m, FilterMonad Response m) => [(CookieLife, Cookie)] -> m () addCookies = mapM_ (uncurry addCookie)@@ -44,5 +44,5 @@ -- > do expireCookie "name" -- > ok $ "The cookie has been expired." -expireCookie :: (MonadIO m, FilterMonad Response m) => String -> m () +expireCookie :: (MonadIO m, FilterMonad Response m) => String -> m () expireCookie name = addCookie Expired (mkCookie name "")
src/Happstack/Server/FileServe/BuildingBlocks.hs view
@@ -59,11 +59,12 @@ import Control.Monad.Trans (MonadIO(liftIO)) import qualified Data.ByteString.Lazy.Char8 as L import qualified Data.ByteString.Char8 as S-import Data.Data (Data, Typeable)+import Data.Data (Data) import Data.List (sort) import Data.Maybe (fromMaybe) import Data.Map (Map) import qualified Data.Map as Map+import Data.Time (UTCTime, formatTime, defaultTimeLocale) import Filesystem.Path.CurrentOS (commonPrefix, encodeString, decodeString, collapse, append) import Happstack.Server.Monads (ServerMonad(askRq), FilterMonad, WebMonad) import Happstack.Server.Response (ToMessage(toResponse), ifModifiedSince, forbidden, ok, seeOther)@@ -76,13 +77,6 @@ import qualified Text.Blaze.Html5 as H import qualified Text.Blaze.Html5.Attributes as A -#if MIN_VERSION_time(1,5,0)-import Data.Time (UTCTime, formatTime, defaultTimeLocale)-#else-import System.Locale (defaultTimeLocale)-import Data.Time (UTCTime, formatTime)-#endif- -- * Mime-Type / Content-Type -- |a 'Map' from file extensions to content-types@@ -529,7 +523,7 @@ listing <- renderFn localPath $ filter (/= ".") (sort c) ok $ toResponse $ listing -data EntryKind = File | Directory | UnknownKind deriving (Eq, Ord, Read, Show, Data, Typeable, Enum)+data EntryKind = File | Directory | UnknownKind deriving (Eq, Ord, Read, Show, Data, Enum) -- | a function to generate an HTML page showing the contents of a directory on the disk --@@ -631,7 +625,7 @@ -- | see 'serveDirectory' data Browsing = EnableBrowsing | DisableBrowsing- deriving (Eq, Enum, Ord, Read, Show, Data, Typeable)+ deriving (Eq, Enum, Ord, Read, Show, Data) -- | Serve files and directories from a directory and its subdirectories using 'sendFile'. --
src/Happstack/Server/Internal/Clock.hs view
@@ -9,19 +9,12 @@ import Control.Concurrent import Control.Monad+import qualified Data.ByteString.Char8 as B import Data.IORef import Data.Time.Clock (UTCTime) import Data.Time.Clock.POSIX (POSIXTime, getPOSIXTime, posixSecondsToUTCTime)-import System.IO.Unsafe--#if MIN_VERSION_time(1,5,0) import Data.Time.Format (formatTime, defaultTimeLocale)-#else-import Data.Time.Format (formatTime)-import System.Locale (defaultTimeLocale)-#endif--import qualified Data.ByteString.Char8 as B+import System.IO.Unsafe data DateCache = DateCache { cachedPOSIXTime :: !(IORef POSIXTime)
src/Happstack/Server/Internal/Cookie.hs view
@@ -21,21 +21,18 @@ import Control.Monad.Fail (MonadFail) import qualified Data.ByteString.Char8 as C import Data.Char (chr, toLower)-import Data.Data (Data, Typeable)+import Data.Data (Data) import Data.List ((\\), intersperse) import Data.Time.Clock (UTCTime, addUTCTime, diffUTCTime) import Data.Time.Clock.POSIX (posixSecondsToUTCTime)+import Data.Time.Format (formatTime, defaultTimeLocale) import Happstack.Server.Internal.Clock (getApproximateUTCTime) import Network.URI (escapeURIString) import Text.ParserCombinators.Parsec hiding (token) -#if MIN_VERSION_time(1,5,0)-import Data.Time.Format (formatTime, defaultTimeLocale)-#else-import Data.Time.Format (formatTime)-import System.Locale (defaultTimeLocale)-#endif ++ -- | a type for HTTP cookies. Usually created using 'mkCookie'. data Cookie = Cookie { cookieVersion :: String@@ -47,7 +44,7 @@ , httpOnly :: Bool , sameSite :: SameSite , partitioned :: Bool- } deriving(Show,Eq,Read,Typeable,Data)+ } deriving (Show, Eq, Read, Data) -- | Specify the lifetime of a cookie. --@@ -61,7 +58,7 @@ | MaxAge Int -- ^ life time of cookie in seconds | Expires UTCTime -- ^ cookie expiration date | Expired -- ^ cookie already expired- deriving (Eq, Ord, Read, Show, Typeable)+ deriving (Eq, Ord, Read, Show) -- | Options for specifying third party cookie behaviour. --@@ -78,7 +75,7 @@ -- secure. | SameSiteNoValue -- ^ The default; used if you do not wish a SameSite attribute present at all.- deriving (Eq, Ord, Typeable, Data, Show, Read)+ deriving (Eq, Ord, Data, Show, Read) displaySameSite :: SameSite -> String displaySameSite ss =
src/Happstack/Server/Internal/LogFormat.hs view
@@ -4,12 +4,7 @@ , formatRequestCombined ) where -#if MIN_VERSION_time(1,5,0) import Data.Time.Format (FormatTime(..), formatTime, defaultTimeLocale)-#else-import Data.Time.Format (FormatTime(..), formatTime)-import System.Locale (defaultTimeLocale)-#endif -- | Format the time as describe in the Apache combined log format. -- http://httpd.apache.org/docs/2.2/logs.html#combined
src/Happstack/Server/Internal/Types.hs view
@@ -32,7 +32,6 @@ import Data.Data (Data) import Data.String (fromString) import Data.Time.Format (FormatTime(..))-import Data.Typeable(Typeable) import qualified Data.ByteString.Char8 as P import Data.ByteString.Char8 (ByteString,pack) import qualified Data.ByteString.Lazy.Char8 as L@@ -139,7 +138,7 @@ -- | HTTP request method data Method = GET | HEAD | POST | PUT | DELETE | TRACE | OPTIONS | CONNECT | PATCH | EXTENSION ByteString- deriving (Show,Read,Eq,Ord,Typeable,Data)+ deriving (Show, Read, Eq, Ord, Data) -- | Does the method support a message body? --@@ -179,7 +178,7 @@ -- | Result flags data RsFlags = RsFlags { rsfLength :: Length- } deriving (Show,Read,Typeable)+ } deriving (Show, Read) -- | Default RsFlags: automatically use @Transfer-Encoding: Chunked@. nullRsFlags :: RsFlags@@ -204,7 +203,7 @@ { inputValue :: Either FilePath L.ByteString , inputFilename :: Maybe FilePath , inputContentType :: ContentType- } deriving (Show, Read, Typeable)+ } deriving (Show, Read) -- | hostname & port type Host = (String, Int) -- ^ (hostname, port)@@ -225,7 +224,6 @@ , sfOffset :: Integer -- ^ offset to start at , sfCount :: Integer -- ^ number of bytes to send }- deriving (Typeable) instance Show Response where showsPrec _ res@Response{} =@@ -270,7 +268,7 @@ , rqHeaders :: Headers -- ^ the HTTP request headers , rqBody :: MVar RqBody -- ^ the raw, undecoded request body , rqPeer :: Host -- ^ (hostname, port) of the client making the request- } deriving (Typeable)+ } instance Show Request where showsPrec _ rq =@@ -329,7 +327,7 @@ headers = id -- | The body of an HTTP 'Request'-newtype RqBody = Body { unBody :: L.ByteString } deriving (Read,Show,Typeable)+newtype RqBody = Body { unBody :: L.ByteString } deriving (Read, Show) -- | Sets the Response status code to the provided Int and lifts the computation -- into a Monad.@@ -531,7 +529,6 @@ -- | Escape from the HTTP world and get direct access to the underlying 'TimeoutIO' functions data EscapeHTTP = EscapeHTTP (TimeoutIO -> IO ())- deriving (Typeable) instance Exception EscapeHTTP
src/Happstack/Server/Response.hs view
@@ -37,6 +37,7 @@ import qualified Data.Text.Encoding as T import qualified Data.Text.Lazy as LT import qualified Data.Text.Lazy.Encoding as LT+import Data.Time (UTCTime, formatTime, defaultTimeLocale) import Happstack.Server.Internal.Monads (FilterMonad(composeFilter)) import Happstack.Server.Internal.Types import Happstack.Server.Types (Response(..), Request(..), nullRsFlags, getHeader, noContentLength, redirect, result, setHeader, setHeaderBS)@@ -46,12 +47,6 @@ import Text.Html (Html, renderHtml) import qualified Text.XHtml as XHtml (Html, renderHtml) -#if MIN_VERSION_time(1,5,0)-import Data.Time (UTCTime, formatTime, defaultTimeLocale)-#else-import Data.Time (UTCTime, formatTime)-import System.Locale (defaultTimeLocale)-#endif -- | A low-level function to build a 'Response' from a content-type -- and a 'ByteString'.
src/Happstack/Server/RqData.hs view
@@ -78,7 +78,7 @@ import qualified Data.ByteString.Lazy.UTF8 as LU import Data.Char (toLower) import Data.Either (partitionEithers)-import Data.Generics (Data, Typeable)+import Data.Generics (Data) import Data.Maybe (fromJust) import Data.Monoid (Monoid(mempty, mappend, mconcat)) import qualified Data.Semigroup as SG@@ -134,7 +134,7 @@ -- | a list of errors newtype Errors a = Errors { unErrors :: [a] }- deriving (Eq, Ord, Show, Read, Data, Typeable)+ deriving (Eq, Ord, Show, Read, Data) instance SG.Semigroup (Errors a) where (Errors x) <> (Errors y) = Errors (x ++ y)@@ -493,7 +493,7 @@ Nothing -> rqDataError $ strMsg $ "lookCookie: cookie not found: " ++ name Just c -> return c{cookieValue = f c} where- f = unEscapeString . cookieValue + f = unEscapeString . cookieValue -- | gets the named cookie as a string lookCookieValue :: (Functor m, Monad m, HasRqData m) => String -> m String
src/Happstack/Server/SURI.hs view
@@ -23,7 +23,7 @@ import Control.Arrow (first) import Data.Char (chr, digitToInt, isHexDigit) import Data.Maybe (fromJust, isJust)-import Data.Generics (Data, Typeable)+import Data.Generics (Data) import qualified Data.Text as Text import qualified Data.Text.Lazy as LazyText import qualified Network.URI as URI@@ -74,7 +74,7 @@ isAbs :: SURI -> Bool isAbs = not . null . URI.uriScheme . suri -newtype SURI = SURI {suri::URI.URI} deriving (Eq,Data,Typeable)+newtype SURI = SURI {suri::URI.URI} deriving (Eq,Data) instance Show SURI where showsPrec d (SURI uri) = showsPrec d $ show uri instance Read SURI where
src/Happstack/Server/SimpleHTTP.hs view
@@ -30,9 +30,9 @@ -- > import Happstack.Server -- > main = simpleHTTP nullConf $ ok "Hello World!" ----- By default the server will listen on port 8000. Run the app and point your browser at: <http://localhost:8000/>+-- By default the server will listen on port 8000. Run the app and point your browser at: <http:\/\/localhost:8000\/> ----- For FastCGI support see: <http://hackage.haskell.org/package/happstack-fastcgi>+-- For FastCGI support see: <http:\/\/hackage.haskell.org\/package\/happstack-fastcgi> ----------------------------------------------------------------------------- module Happstack.Server.SimpleHTTP ( -- * SimpleHTTP