fukamachi / clack

Web server abstraction layer for Common Lisp
MIT License
1.05k stars 86 forks source link

Starting multiple apps with the Hunchentoot handler causes the previous to be unreachable #122

Closed jorams closed 9 years ago

jorams commented 9 years ago

I'll illustrate the problem with an example:

(ql:quickload '(:clack :drakma))

(clack:clackup
  (lambda (env)
    '(200
      (:content-type "text/plain")
      ("Hello, Clack application 1!")))
  :port 5000)

(clack:clackup
  (lambda (env)
    '(200
      (:content-type "text/plain")
      ("Hello, Clack application 2!")))
  :port 5001)

(drakma:http-request "http://localhost:5000/") ;=> "Hello, Clack application 2!"
(drakma:http-request "http://localhost:5001/") ;=> "Hello, Clack application 2!"

The first drakma:http-request should return "Hello, Clack application 1!".

I'm pretty sure this happens because the RUN function of the Hunchentoot handler completely replaces hunchentoot:*dispatch-table* with a list containing only a function that always dispatches to the newly started app. (see here)

Instead it should work like the Hunchentoot documentation says: Check if the request should be handled by that app. The other handlers in the list should be kept in place.

Request dispatching is performed according to the list of dispatch functions in DISPATCH-TABLE. Each of the functions on that list is called to determine whether it wants to handle the request, provided as single argument. If a dispatcher function wants to handle the request, it returns another function to actually create the desired page.

fukamachi commented 9 years ago

Fixed at master branch. Hunchentoot handler has stopped using easy-acceptor, so confliction of *dispatch-table* doesn't matter now. Thank you for reporting!