emptygif
اللغة: العربية

كل اللغات وأطر العمل

Hunchentoot Common Lisp

مقتطف بلغة Common Lisp لـ Hunchentoot يستجيب لطلبات /pixel.gif بملف 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