;;; http-drakma.lisp ;;; ;;; Author: Eric Marsden ;;; Time-stamp: <2006-12-28 emarsden> ;; TODO: reuse the connection for image requests (pipelining) ;; ;; (in-package :netlib) ;; 0: (WS/NETLIB::HTTP-OPEN-DOCUMENT #u"http://common-lisp.net/project/closure/" ;; :METHOD :GET) ;; 0: WS/NETLIB::HTTP-OPEN-DOCUMENT returned ;; # ;; (("Date" . "Wed, 27 Dec 2006 11:09:00 GMT") ;; ("Server" . "Apache/1.3.33 (Debian GNU/Linux) PHP/4.3.10-18") ;; ("Connection" . "close") ;; ("Content-Type" . "text/html; charset=iso-8859-1")) ;; emarsden2006-12-26 main entry point. Must return an IO and a ;; header. HEADER is an alist of (string . string) pairs of the HTTP ;; headers. IO is a stream of octets. (defun http-open-document (url &rest options &key (yet-urls nil) (method :get) (post-data ) (post-header )) (declare (ignore options yet-urls post-data post-header)) (let (io return-headers) (multiple-value-bind (body status-code headers uri stream must-close) (drakma:http-request (url:unparse-url url) :method method :force-binary t :want-stream t) (declare (ignore body status-code uri)) (setq return-headers (mapcar (lambda (a) (cons (string (car a)) (cdr a))) headers)) (setq io (cl-byte-stream->gstream stream)) #+nil (when must-close (close stream)) (values io return-headers)))) ;; EOF