@@ -69,10 +69,15 @@ type Port = Int
6969
7070serveConnections :: Port -> Application -> Socket -> IO ()
7171serveConnections port app socket = do
72− (conn, _) <- accept socket
73− let remoteHost' = undefined
72+ (conn, sa) <- accept socket
73+ let remoteHost' = stripPort $ show sa -- FIXME
7474 _ <- forkIO $ serveConnection port app conn remoteHost'
7575 serveConnections port app socket
76+ where
77+ stripPort s =
78+ case break (== ':') $ reverse s of
79+ (_, ':' : rest) -> reverse rest
80+ _ -> s
7681
7782serveConnection :: Port -> Application -> Socket -> String -> IO ()
7883serveConnection port app conn remoteHost' = do
@@ -84,7 +89,7 @@ serveConnection port app conn remoteHost' = do
8489 where
8590 ignoreAll :: SomeException -> IO ()
8691 ignoreAll _ = return ()
87− fromClient = enumSocket 4096 conn
92+ fromClient = enumSocket bytesPerRead conn
8893 serveConnection' = do
8994 (enumeratee, env) <- parseRequest port remoteHost'
9095 res <- E.joinI $ enumeratee $$ app env
@@ -97,9 +102,10 @@ parseRequest port remoteHost' = do
97102 parseRequest' port headers' remoteHost'
98103
99104-- FIXME come up with good values here
100−maxHeaders, maxHeaderLength :: Int
105+maxHeaders, maxHeaderLength, bytesPerRead :: Int
101106maxHeaders = 30
102107maxHeaderLength = 1024
108+bytesPerRead = 4096
103109
104110takeUntilBlank :: Int
105111 -> ([ByteString] -> [ByteString])