[hunchentoot-devel] hunchentoot-cgi and the new hunchentoot regime

Cyrus Harmon ch-tbnl at bobobeach.com
Tue Jul 22 02:04:10 UTC 2008


Falling squarely in the more than one way to skin a cat, perhaps it's  
easier to just read off the CGI headers and DTRT WRT to those headers  
and then send the output of the CGI to the tbnl output-stream.

(let* ((process (sb-ext::run-program path nil
                                            :output :stream
                                            :environment env))
              (in (sb-ext:process-output process)))
         (let ((headers
                (loop for line = (chunga:read-line* in)
                   until (equal line "")
                   collect (destructuring-bind
                                 (key val)
                               (ppcre:split ": " line)
                             (cons (chunga:as-keyword key) val)))))
           (let ((type-cons (assoc :content-type headers)))
             (when type-cons
               (setf (tbnl:content-type)
                     (cdr type-cons)))))
         (let ((out (flexi-streams:make-flexi-stream
                     (tbnl:send-headers)
                     :external-format tbnl::+latin-1+)))
           (do ((c (read-char in) (read-char in)))
               ((eq c 'eof))
             (write-char c out))))

This works well enough for the git CGI interface to sit behind (an  
unhacked) hunchentoot and hunchentoot-cgi as can be seen here:

http://git.cyrusharmon.org/cgi-bin/gitweb.cgi?p=hunchentoot-cgi.git

thanks for prodding me to think about this some more...

cyrus


On Jul 20, 2008, at 11:44 PM, Edi Weitz wrote:

> On Mon, 21 Jul 2008 07:54:51 +0200, "Hans Hübner" <hans at huebner.org>  
> wrote:
>
>> Why not make the flag to suppress sending the content type and
>> terminating the header be an argument to START-OUTPUT?  I don't
>> think that adding more special variables for no good reason would be
>> so nice.  It may just be me, though.
>
> Fine with me.
>
> What's so special about the content type, though?  Do you actually
> want /any/ headers to be sent or any processing to be done?
> _______________________________________________
> tbnl-devel site list
> tbnl-devel at common-lisp.net
> http://common-lisp.net/mailman/listinfo/tbnl-devel




More information about the Tbnl-devel mailing list