emptygif
Idioma: Português

Todas as linguagens e frameworks

Hunchentoot Common Lisp

Um snippet em Common Lisp para Hunchentoot que responde às requisições para /pixel.gif com o GIF vazio, decodificado uma única vez na inicialização.

Hunchentoot Common Lisp

Instalar
(ql:quickload '(:hunchentoot :cl-base64))
Arquivo
server.lisp
Executar
sbcl --load server.lisp
(ql:quickload '(:hunchentoot :cl-base64))

(defparameter *gif*
  (cl-base64:base64-string-to-usb8-array "R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=="))

(hunchentoot:define-easy-handler (pixel :uri "/pixel.gif") ()
  (setf (hunchentoot:content-type*) "image/gif"
        (hunchentoot:header-out :cache-control) "no-store")
  *gif*)

(hunchentoot:start (make-instance 'hunchentoot:easy-acceptor :port 8080))

Executamos este snippet e comparamos os bytes que ele retornou.

Verificar

curl -sI http://localhost:8080/pixel.gif

Site oficial: Hunchentoot