(defun rewrite-http-to-https (url) (if (eql 0 (search "http://" url)) (concatenate 'string "https://" (subseq url (length "http://"))) url)) (defun drakma-fetch-to-file (url file) (let ((stream (drakma:http-request url :want-stream t :force-binary t)) (temp-file (make-pathname :type "tmp" :defaults file)) (buffer (make-array 10000 :element-type '(unsigned-byte 8)))) (with-open-file (output-stream temp-file :direction :output :if-exists :rename-and-delete :element-type '(unsigned-byte 8)) (loop (let ((last-index (read-sequence buffer stream))) (when (zerop last-index) ;; FIXME: doesn't work when FILE has no type already! (rename-file temp-file file) (return (probe-file file))) (write-sequence buffer output-stream :end last-index)))))) (defun ssl-fetch (url file &key follow-redirects quietly if-exists maximum-redirects) (declare (ignore follow-redirects quietly if-exists maximum-redirects)) (drakma-fetch-to-file (rewrite-http-to-https url) file)) ;; (setf ql-http:*fetch-scheme-functions* '(("http" . ssl-fetch)))