Commit 9590790f authored by Eric Timmons's avatar Eric Timmons
Browse files

Make stream types for HTTP clients consistent

parent 2dfea679
Loading
Loading
Loading
Loading
+6 −4
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@
          #:alexandria
          #:clpm/config
          #:iterate)
  (:import-from #:flexi-streams)
  (:import-from #:uiop
                #:read-file-form
                #:with-safe-io-syntax)
@@ -64,10 +65,11 @@ the request."
(defun fetch-url (url)
  "Given a URL, return a string with the contents of the file located at ~url~."
  (let ((url (puri:parse-uri url)))
    (with-output-to-string (s)
    (babel:octets-to-string
     (flexi-streams:with-output-to-sequence (s :element-type '(unsigned-byte 8))
       (fetch-url-to-stream url s
                            :headers (get-additional-headers-for-hostname (puri:uri-host url)
                                                                         (puri:uri-scheme url))))))
                                                                          (puri:uri-scheme url)))))))

(defun ensure-file-fetched (pathname url &key refresh-time)
  "Given a pathname, make sure it exists. If it does not exist, fetch it from
+1 −2
Original line number Diff line number Diff line
@@ -32,8 +32,7 @@
  (multiple-value-bind (http-stream status-code)
      (http-request url :want-stream t
                        :verify :required
                        :decode-content t
                        :additional-headers headers)
    (assert (= 200 status-code))
    (copy-stream http-stream out-stream :element-type 'character :buffer-size 8192)
    (copy-stream http-stream out-stream :element-type '(unsigned-byte 8) :buffer-size 8192)
    (close http-stream)))