Skip to content

Instantly share code, notes, and snippets.

@yuttie
Created June 24, 2012 01:57
Show Gist options
  • Select an option

  • Save yuttie/2980993 to your computer and use it in GitHub Desktop.

Select an option

Save yuttie/2980993 to your computer and use it in GitHub Desktop.
Problem of a large response content with the gzip middleware.
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.ByteString.Lazy as B
import Data.Char
import Network.Wai
import Network.Wai.Handler.CGI (run)
import Network.Wai.Middleware.Gzip (gzip, def)
import Network.HTTP.Types (status200)
application _ = return $ responseLBS status200 [("Content-Type", "text/plain")]
content
where
content = B.pack $ map (fromIntegral . ord) $ concat $ ["BEGIN"] ++ map show [1..100000] ++ ["END"]
main = run $ gzip def application
--main = run $ application
-- This can be executed by `REMOTE_ADDR=localhost HTTP_ACCEPT_ENCODING=gzip runghc test_with_cgi.hs'.
{-# LANGUAGE OverloadedStrings #-}
import qualified Data.ByteString.Lazy as B
import Data.Char
import Network.Wai
import Network.Wai.Handler.Warp (run)
import Network.Wai.Middleware.Gzip (gzip, def)
import Network.HTTP.Types (status200)
application _ = return $ responseLBS status200 [("Content-Type", "text/plain")]
content
where
content = B.pack $ map (fromIntegral . ord) $ concat $ ["BEGIN"] ++ map show [1..100000] ++ ["END"]
main = run 3000 $ gzip def application
--main = run 3000 $ application
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment