Я установил hunchentoot-cgi и проверил его.Ниже приведен простой файл сценария Python:
>cat cgi-bin/nav.py
#!/usr/local/bin/python
# -*- coding: utf-8 -*-
print "Content-type: text/html\n\n"
print """from Python"""
когда я посетил http://127.0.0.1:8000/cgi-bin/nav.py, hunchentoot сообщил:
11111111111111111
**End of file, but expected #\Newline.**
[2011-12-28 13:35:16 [ERROR]] error in handle-cgi-script from URL /cgi-bin/nav.py
127.0.0.1 - [2011-12-28 13:35:16] "GET /cgi-bin/nav.py HTTP/1.1" 200 - "-"
"Opera/9.80 (X11; FreeBSD 8.2-RELEASE i386; U; zh-cn) Presto/2.10.229 Version/11.60"
Взломав hunchentoot-cgi.lisp, я нашелФункция «handle-cgi-script» сообщила об ошибке:
(handler-case
(with-input-from-program (in path nil env)
(format t "11111111111111111~%")
(chunga:with-character-stream-semantics
(loop for line = (chunga:read-line* in)
until (equal line "")
do
(format t "22222222222222222:~A~%" line)
(destructuring-bind (key val)
(ppcre:split ": " line :limit 2)
(setf (hunchentoot:header-out key) val))
(format t "22222222222222222~%")))
(format t "33333333333333333~%")
(let ((out (flexi-streams:make-flexi-stream
(tbnl:send-headers)
:external-format tbnl::+latin-1+)))
(copy-stream in out 'character))
(format t "33333333333333333~%"))
(error (error)
(format t "~A~%" error)
(tbnl:log-message* :error "error in handle-cgi-script from URL ~A"
(tbnl:request-uri*))))
Любое предложение приветствуется!