happstack-server-6.5.2: Web related tools and services.

Happstack.Server.Internal.Compression

Description

Filter for compressing the Response body.

Synopsis

Documentation

compressedResponseFilterSource

Arguments

:: (FilterMonad Response m, MonadPlus m, WebMonad Response m, ServerMonad m) 
=> m String

name of the encoding chosen

reads the Accept-Encoding header. Then, if possible will compress the response body with methods gzip or deflate.

 main = 
   simpleHTTP nullConf $ 
      do str <- compressedResponseFilter
         return $ toResponse ("This response compressed using: " ++ str)

compressWithFilterSource

Arguments

:: FilterMonad Response m 
=> (ByteString -> ByteString)

function to compress the body

-> String

encoding to use for Content-Encoding header

-> Bool

fallback to identity for SendFile

-> m () 

Ignore the Accept-Encoding header in the Request and attempt to compress the body of the response using the supplied compressor.

We can not compress files being transfered using SendFile. If identity is an allowed encoding, then just return the Response unmodified. Otherwise we return 406 Not Acceptable.

see also: gzipFilter and defaultFilter

gzipFilterSource

Arguments

:: FilterMonad Response m 
=> String

encoding to use for Content-Encoding header

-> Bool

fallback to identity for SendFile

-> m () 

Ignore the Accept-Encoding header in the Request and attempt to compress the body of the response with gzip.

calls compressWithFilter using compress.

see also: compressedResponseFilter

deflateFilterSource

Arguments

:: FilterMonad Response m 
=> String

encoding to use for Content-Encoding header

-> Bool

fallback to identity for SendFile

-> m () 

Ignore the Accept-Encoding header in the Request and attempt compress the body of the response with zlib's deflate method

calls compressWithFilter using compress.

see also: compressedResponseFilter

encodings :: GenParser Char st [([Char], Maybe Double)]Source

a parser for the Accept-Encoding header