worker :: Socket -> IO ()
worker sock = loop expectedRequestLength
  where
    loop :: Int -> IO ()
    loop !left
      | left == 0 = do sendAll sock reply
                       loop expectedRequestLength
      | otherwise = do bs' <- recv sock left
                       if B.length bs' == 0
                         then return ()
                         else loop $ left - B.length bs'

-- REPLY   
worker :: Socket -> IO ()
worker sock = loop expectedRequestLength
  where
    loop :: Int -> IO ()
    loop !left
      | left == 0 = do sendAll sock reply
                       loop expectedRequestLength
      | otherwise = do bs' <- recv sock left
                       if B.length bs' == 0
                         then return ()
                         else loop $ left - B.length bs'

-- REPLY   
worker sock = loop expectedRequestLength
  where
    loop :: Int -> IO ()
    loop !left
      | left == 0 = do sendAll sock reply
                       loop expectedRequestLength
      | otherwise = do bs' <- recv sock left
                       if B.length bs' == 0
                         then return ()
                         else loop $ left - B.length bs'

-- REPLY   