hunchentoot: trouble dispatching requests
Posted: Thu May 10, 2012 5:20 pm
hunchentoot: requests do not dispatch
Disclaimer: I am a Lisp & software engineering novice and utter web application newbie. This message regards my first attempt at a web application. I'm still at a stage where having basic things, particularly about web application development, explicitly spelled out helps me.
I just installed hunchentoot with Clozure CL 1.8 under Mac OS 10.7. Hunchentoot serves my pages, but query requests do not result in other code being called. What I'm trying to make is a simple web application that presents a webpage with some text and a link. When the link is clicked, the application is to compute some other random assortment of text, write it to an html file overwriting the old "index.html" file, and then refresh so that the new "index.html" loads into the browser.
When the link to recompute text is clicked, I see in the console that hunchentoot receives the request:
98.218.230.125 - [2012-05-10 10:48:42] "GET /index.html?recompute HTTP/1.1" 304 - "http://drpantzo.mine.nu:4242/index.html?recompute" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/534.55.3 (KHTML, like Gecko) Version/5.1.5 Safari/534.55.3"
However, what I'm unclear on after reading hunchentoot's documentation as well as these three tutorials:
http://www.adampetersen.se/articles/lispweb.htm
http://msnyder.info/posts/2011/07/lisp- ... -ii/#sec-4
http://sites.google.com/site/sabraonthe ... p-packages
…is how the request gets processed by hunchentoot such that my page generation macro gets called again and the webpage gets reloaded. My understanding is that the link is to contain a query, the portion of the link request identified by the "?" prefix. When hunchentoot sees the "recompute" query it should check its *dispatch-table* where it should find an easy-handler function as defined by the macro, define-easy-handler. The easy-handler, having a name matching the query, should call my page generation macro and then redirect to "index.html" so that the page refreshes, showing the lovely new bag of words. However, when I have an easy handler defined and request the page with Safari, I get an internal server error message,
Incorrect keyword arguments in (#<HUNCHENTOOT:REQUEST #x302001F7AF9D>) .
Backtrace
(A019568) : 0 (PRINT-CALL-HISTORY :CONTEXT NIL :PROCESS NIL :ORIGIN NIL :DETAILED-P NIL :COUNT 1152921504606846975 :START-FRAME-NUMBER 0 :STREAM #<STRING-OUTPUT-STREAM #x302001F7ABFD> :PRINT-LEVEL 2 :PRINT-LENGTH 5 :SHOW-INTERNAL-FRAMES NIL :FORMAT :TRADITIONAL) 853
(A0196D0) : 1 (PRINT-BACKTRACE-TO-STREAM #<STRING-OUTPUT-STREAM #x302001F7ABFD>) 85
(A019700) : 2 (GET-BACKTRACE) 365
(A019768) : 3 (FUNCALL #'#<(:INTERNAL (HUNCHENTOOT:HANDLE-REQUEST (HUNCHENTOOT:ACCEPTOR HUNCHENTOOT:REQUEST)))> #<CCL::SIMPLE-PROGRAM-ERROR #x302001F7AC2D>) 109
(A019798) : 4 (SIGNAL #<CCL::SIMPLE-PROGRAM-ERROR #x302001F7AC2D>) 981
(A0197F0) : 5 (%ERROR #<CCL::SIMPLE-PROGRAM-ERROR #x302001F7AC2D> NIL 20984579) 117
(A019820) : 6 (FUNCALL #'#<(CCL::TRACED RECOMPUTE)> #<HUNCHENTOOT:REQUEST #x302001F7AF9D>) 605
(A019868) : 7 (FUNCALL #'#<#<STANDARD-METHOD HUNCHENTOOT:ACCEPTOR-DISPATCH-REQUEST (HUNCHENTOOT:EASY-ACCEPTOR T)>> #<EASY-ACCEPTOR (host *, port 4242)> #<HUNCHENTOOT:REQUEST #x302001F7AF9D>) 141
(A0198A8) : 8 (%%STANDARD-COMBINED-METHOD-DCODE (#<STANDARD-METHOD HUNCHENTOOT:ACCEPTOR-DISPATCH-REQUEST #> #<STANDARD-METHOD HUNCHENTOOT:ACCEPTOR-DISPATCH-REQUEST #>) 20984609) 669
(A019920) : 9 (FUNCALL #'#<#<STANDARD-METHOD HUNCHENTOOT:HANDLE-REQUEST (HUNCHENTOOT:ACCEPTOR HUNCHENTOOT:REQUEST)>> #<EASY-ACCEPTOR (host *, port 4242)> #<HUNCHENTOOT:REQUEST #x302001F7AF9D>) 533
(A0199B8) : 10 (FUNCALL #'#<#<STANDARD-METHOD HUNCHENTOOT:PROCESS-REQUEST (T)>> #<HUNCHENTOOT:REQUEST #x302001F7AF9D>) 1349
(A019AA8) : 11 (DO-WITH-ACCEPTOR-REQUEST-COUNT-INCREMENTED #<EASY-ACCEPTOR (host *, port 4242)> #<COMPILED-LEXICAL-CLOSURE (:INTERNAL #) #x302001F7B06F>) 1157
(A019B30) : 12 (FUNCALL #'#<#<STANDARD-METHOD HUNCHENTOOT:PROCESS-CONNECTION (HUNCHENTOOT:ACCEPTOR T)>> #<EASY-ACCEPTOR (host *, port 4242)> #<USOCKET:STREAM-USOCKET #x302001EBEC5D>) 2837
(A019C50) : 13 (%CALL-NEXT-METHOD (NIL #<STANDARD-METHOD HUNCHENTOOT:PROCESS-CONNECTION #> . 20984761)) 989
(A019CD0) : 14 (FUNCALL #'#<#<STANDARD-METHOD HUNCHENTOOT:PROCESS-CONNECTION :AROUND (HUNCHENTOOT:ACCEPTOR T)>> #<EASY-ACCEPTOR (host *, port 4242)> #<USOCKET:STREAM-USOCKET #x302001EBEC5D>) 637
(A019D68) : 15 (%%STANDARD-COMBINED-METHOD-DCODE (#<STANDARD-METHOD HUNCHENTOOT:PROCESS-CONNECTION :AROUND #> #<STANDARD-METHOD HUNCHENTOOT:PROCESS-CONNECTION #>) 20984761) 669
(A019DE0) : 16 (FUNCALL #'#<(:INTERNAL (HUNCHENTOOT:CREATE-REQUEST-HANDLER-THREAD (HUNCHENTOOT:ONE-THREAD-PER-CONNECTION-TASKMASTER T)))>) 181
(A019E38) : 17 (FUNCALL #'#<(:INTERNAL BORDEAUX-THREADS::BINDING-DEFAULT-SPECIALS)>) 757
(A019E78) : 18 (RUN-PROCESS-INITIAL-FORM #<PROCESS hunchentoot-worker-98.218.230.125:33226(91) [Active] #x302001EBDCAD> (#<COMPILED-LEXICAL-CLOSURE # #x302001EBDA1F>)) 669
(A019F08) : 19 (FUNCALL #'#<(:INTERNAL (CCL::%PROCESS-PRESET-INTERNAL (PROCESS)))> #<PROCESS hunchentoot-worker-98.218.230.125:33226(91) [Active] #x302001EBDCAD> (#<COMPILED-LEXICAL-CLOSURE # #x302001EBDA1F>)) 549
(A019F98) : 20 (FUNCALL #'#<(:INTERNAL CCL::THREAD-MAKE-STARTUP-FUNCTION)>) 301
Yet when I (setf hunchentoot:*dispatch-table* nil) I can at least get the page back, but of course then it won't compute a new page and load that. So I seem to misunderstand how to define an easy-handler:
(setf hunchentoot:*dispatch-table*
(list
(hunchentoot:define-easy-handler (recompute :uri "index.html") ()
(page 'index '|ice cream computer| (compute-ice-cream))
(hunchentoot:redirect "index.html"))))
Am I correct in my suspicion that I'm going awry in my easy-handler definition? What can I do to get my page to recompute and reload?
Disclaimer: I am a Lisp & software engineering novice and utter web application newbie. This message regards my first attempt at a web application. I'm still at a stage where having basic things, particularly about web application development, explicitly spelled out helps me.
I just installed hunchentoot with Clozure CL 1.8 under Mac OS 10.7. Hunchentoot serves my pages, but query requests do not result in other code being called. What I'm trying to make is a simple web application that presents a webpage with some text and a link. When the link is clicked, the application is to compute some other random assortment of text, write it to an html file overwriting the old "index.html" file, and then refresh so that the new "index.html" loads into the browser.
When the link to recompute text is clicked, I see in the console that hunchentoot receives the request:
98.218.230.125 - [2012-05-10 10:48:42] "GET /index.html?recompute HTTP/1.1" 304 - "http://drpantzo.mine.nu:4242/index.html?recompute" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/534.55.3 (KHTML, like Gecko) Version/5.1.5 Safari/534.55.3"
However, what I'm unclear on after reading hunchentoot's documentation as well as these three tutorials:
http://www.adampetersen.se/articles/lispweb.htm
http://msnyder.info/posts/2011/07/lisp- ... -ii/#sec-4
http://sites.google.com/site/sabraonthe ... p-packages
…is how the request gets processed by hunchentoot such that my page generation macro gets called again and the webpage gets reloaded. My understanding is that the link is to contain a query, the portion of the link request identified by the "?" prefix. When hunchentoot sees the "recompute" query it should check its *dispatch-table* where it should find an easy-handler function as defined by the macro, define-easy-handler. The easy-handler, having a name matching the query, should call my page generation macro and then redirect to "index.html" so that the page refreshes, showing the lovely new bag of words. However, when I have an easy handler defined and request the page with Safari, I get an internal server error message,
Incorrect keyword arguments in (#<HUNCHENTOOT:REQUEST #x302001F7AF9D>) .
Backtrace
(A019568) : 0 (PRINT-CALL-HISTORY :CONTEXT NIL :PROCESS NIL :ORIGIN NIL :DETAILED-P NIL :COUNT 1152921504606846975 :START-FRAME-NUMBER 0 :STREAM #<STRING-OUTPUT-STREAM #x302001F7ABFD> :PRINT-LEVEL 2 :PRINT-LENGTH 5 :SHOW-INTERNAL-FRAMES NIL :FORMAT :TRADITIONAL) 853
(A0196D0) : 1 (PRINT-BACKTRACE-TO-STREAM #<STRING-OUTPUT-STREAM #x302001F7ABFD>) 85
(A019700) : 2 (GET-BACKTRACE) 365
(A019768) : 3 (FUNCALL #'#<(:INTERNAL (HUNCHENTOOT:HANDLE-REQUEST (HUNCHENTOOT:ACCEPTOR HUNCHENTOOT:REQUEST)))> #<CCL::SIMPLE-PROGRAM-ERROR #x302001F7AC2D>) 109
(A019798) : 4 (SIGNAL #<CCL::SIMPLE-PROGRAM-ERROR #x302001F7AC2D>) 981
(A0197F0) : 5 (%ERROR #<CCL::SIMPLE-PROGRAM-ERROR #x302001F7AC2D> NIL 20984579) 117
(A019820) : 6 (FUNCALL #'#<(CCL::TRACED RECOMPUTE)> #<HUNCHENTOOT:REQUEST #x302001F7AF9D>) 605
(A019868) : 7 (FUNCALL #'#<#<STANDARD-METHOD HUNCHENTOOT:ACCEPTOR-DISPATCH-REQUEST (HUNCHENTOOT:EASY-ACCEPTOR T)>> #<EASY-ACCEPTOR (host *, port 4242)> #<HUNCHENTOOT:REQUEST #x302001F7AF9D>) 141
(A0198A8) : 8 (%%STANDARD-COMBINED-METHOD-DCODE (#<STANDARD-METHOD HUNCHENTOOT:ACCEPTOR-DISPATCH-REQUEST #> #<STANDARD-METHOD HUNCHENTOOT:ACCEPTOR-DISPATCH-REQUEST #>) 20984609) 669
(A019920) : 9 (FUNCALL #'#<#<STANDARD-METHOD HUNCHENTOOT:HANDLE-REQUEST (HUNCHENTOOT:ACCEPTOR HUNCHENTOOT:REQUEST)>> #<EASY-ACCEPTOR (host *, port 4242)> #<HUNCHENTOOT:REQUEST #x302001F7AF9D>) 533
(A0199B8) : 10 (FUNCALL #'#<#<STANDARD-METHOD HUNCHENTOOT:PROCESS-REQUEST (T)>> #<HUNCHENTOOT:REQUEST #x302001F7AF9D>) 1349
(A019AA8) : 11 (DO-WITH-ACCEPTOR-REQUEST-COUNT-INCREMENTED #<EASY-ACCEPTOR (host *, port 4242)> #<COMPILED-LEXICAL-CLOSURE (:INTERNAL #) #x302001F7B06F>) 1157
(A019B30) : 12 (FUNCALL #'#<#<STANDARD-METHOD HUNCHENTOOT:PROCESS-CONNECTION (HUNCHENTOOT:ACCEPTOR T)>> #<EASY-ACCEPTOR (host *, port 4242)> #<USOCKET:STREAM-USOCKET #x302001EBEC5D>) 2837
(A019C50) : 13 (%CALL-NEXT-METHOD (NIL #<STANDARD-METHOD HUNCHENTOOT:PROCESS-CONNECTION #> . 20984761)) 989
(A019CD0) : 14 (FUNCALL #'#<#<STANDARD-METHOD HUNCHENTOOT:PROCESS-CONNECTION :AROUND (HUNCHENTOOT:ACCEPTOR T)>> #<EASY-ACCEPTOR (host *, port 4242)> #<USOCKET:STREAM-USOCKET #x302001EBEC5D>) 637
(A019D68) : 15 (%%STANDARD-COMBINED-METHOD-DCODE (#<STANDARD-METHOD HUNCHENTOOT:PROCESS-CONNECTION :AROUND #> #<STANDARD-METHOD HUNCHENTOOT:PROCESS-CONNECTION #>) 20984761) 669
(A019DE0) : 16 (FUNCALL #'#<(:INTERNAL (HUNCHENTOOT:CREATE-REQUEST-HANDLER-THREAD (HUNCHENTOOT:ONE-THREAD-PER-CONNECTION-TASKMASTER T)))>) 181
(A019E38) : 17 (FUNCALL #'#<(:INTERNAL BORDEAUX-THREADS::BINDING-DEFAULT-SPECIALS)>) 757
(A019E78) : 18 (RUN-PROCESS-INITIAL-FORM #<PROCESS hunchentoot-worker-98.218.230.125:33226(91) [Active] #x302001EBDCAD> (#<COMPILED-LEXICAL-CLOSURE # #x302001EBDA1F>)) 669
(A019F08) : 19 (FUNCALL #'#<(:INTERNAL (CCL::%PROCESS-PRESET-INTERNAL (PROCESS)))> #<PROCESS hunchentoot-worker-98.218.230.125:33226(91) [Active] #x302001EBDCAD> (#<COMPILED-LEXICAL-CLOSURE # #x302001EBDA1F>)) 549
(A019F98) : 20 (FUNCALL #'#<(:INTERNAL CCL::THREAD-MAKE-STARTUP-FUNCTION)>) 301
Yet when I (setf hunchentoot:*dispatch-table* nil) I can at least get the page back, but of course then it won't compute a new page and load that. So I seem to misunderstand how to define an easy-handler:
(setf hunchentoot:*dispatch-table*
(list
(hunchentoot:define-easy-handler (recompute :uri "index.html") ()
(page 'index '|ice cream computer| (compute-ice-cream))
(hunchentoot:redirect "index.html"))))
Am I correct in my suspicion that I'm going awry in my easy-handler definition? What can I do to get my page to recompute and reload?