emptygif
言語: 日本語

すべての言語・フレームワーク

Hunchentoot Common Lisp

/pixel.gif へのリクエストに空の GIF を返す、Hunchentoot 用の Common Lisp スニペット。GIF は起動時に一度だけデコードします。

Hunchentoot Common Lisp

インストール
(ql:quickload '(:hunchentoot :cl-base64))
ファイル
server.lisp
実行
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))

このスニペットは実行し、返されたバイト列を照合しました。

確認

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

公式サイト: Hunchentoot