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

Safe Haskell | None

Happstack.Server.Internal.Compression

Description

Filter for compressing the `Response` body.

Synopsis

- compressedResponseFilter :: (FilterMonad Response m, MonadPlus m, WebMonad Response m, ServerMonad m) => m String
- compressWithFilter :: FilterMonad Response m => (ByteString -> ByteString) -> String -> Bool -> m ()
- gzipFilter :: FilterMonad Response m => String -> Bool -> m ()
- deflateFilter :: FilterMonad Response m => String -> Bool -> m ()
- encodings :: GenParser Char st [(String, Maybe Double)]

# Documentation

compressedResponseFilter

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)

compressWithFilter

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`

gzipFilter

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`

deflateFilter

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 [(String, Maybe Double)]

a parser for the Accept-Encoding header