emptygif
Langue: Français

Tous les langages et frameworks

Hunchentoot Common Lisp

Un extrait Common Lisp pour Hunchentoot qui répond aux requêtes sur /pixel.gif avec le GIF vide, décodé une seule fois au démarrage.

Hunchentoot Common Lisp

Installer
(ql:quickload '(:hunchentoot :cl-base64))
Fichier
server.lisp
Lancer
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))

Nous avons exécuté cet extrait et comparé les octets qu’il a renvoyés.

Vérifier

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

Site officiel: Hunchentoot