snap-core-0.2.16: Snap: A Haskell Web Framework (Core)ContentsIndex
Snap.Util.GZip
Synopsis
withCompression :: Snap a -> Snap ()
withCompression' :: Set ByteString -> Snap a -> Snap ()
Documentation
withCompression
:: Snap athe web handler to run
-> Snap ()

Runs a Snap web handler with compression if available.

If the client has indicated support for gzip or compress in its Accept-Encoding header, and the Content-Type in the response is one of the following types:

  • application/x-javascript
  • text/css
  • text/html
  • text/javascript
  • text/plain
  • text/xml
  • application/x-font-truetype

Then the given handler's output stream will be compressed, Content-Encoding will be set in the output headers, and the Content-Length will be cleared if it was set. (We can't process the stream in O(1) space if the length is known beforehand.)

The wrapped handler will be run to completion, and then the Response that's contained within the Snap monad state will be passed to finishWith to prevent further processing.

withCompression'
:: Set ByteStringset of compressible MIME types
-> Snap athe web handler to run
-> Snap ()
The same as withCompression, with control over which MIME types to compress.
Produced by Haddock version 2.7.2