Created
June 24, 2012 01:57
-
-
Save yuttie/2980993 to your computer and use it in GitHub Desktop.
Problem of a large response content with the gzip middleware.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# 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'. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| {-# 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