diff --git a/src/http/server.cr b/src/http/server.cr index 6e44f4150582..53ee873ed330 100644 --- a/src/http/server.cr +++ b/src/http/server.cr @@ -445,6 +445,12 @@ class HTTP::Server listen end + # Overwrite this method to implement an alternative concurrency handler + # one example could be the use of a fiber pool + protected def dispatch(io) + spawn handle_client(io) + end + # Starts the server. Blocks until the server is closed. def listen : Nil raise "Can't re-start closed server" if closed? @@ -465,9 +471,7 @@ class HTTP::Server end if io - # a non nillable version of the closured io - _io = io - spawn handle_client(_io) + dispatch(io) else break end