Commit b448a4b2 authored by Eric Timmons's avatar Eric Timmons
Browse files

Add priorities to HTTP clients and reenable the curl client

parent bc40fb5a
Loading
Loading
Loading
Loading
+1 −1
Changes for src/clpm/http-client/all.lisp: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@

(uiop:define-package #:clpm/http-client/all
    (:use #:cl
          ;;#:clpm/http-client/curl
          #:clpm/http-client/curl
          #:clpm/http-client/defs
          #:clpm/http-client/drakma)
  (:reexport #:clpm/http-client/defs))
+4 −2
Changes for src/clpm/http-client/curl.lisp: 4 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -11,7 +11,7 @@

(in-package #:clpm/http-client/curl)

(defclass curl-client ()
(defclass curl-client (http-client)
  ((path
    :initarg :path
    :initform "curl"
@@ -19,7 +19,9 @@
    :documentation
    "The path to the curl program."))
  (:documentation
   "Describes an HTTP client that uses a curl executable."))
   "Describes an HTTP client that uses a curl executable.")
  (:default-initargs
   :priority 10))

(register-http-client :curl 'curl-client)

+11 −2
Changes for src/clpm/http-client/defs.lisp: 11 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -7,9 +7,11 @@
    (:use #:cl
          #:alexandria
          #:anaphora
          #:clpm/config)
          #:clpm/config
          #:iterate)
  (:export #:fetch-url-to-stream
           #:%fetch-url-to-stream
           #:http-client
           #:http-client-available-p
           #:http-fetch-error
           #:http-simple-fetch-error
@@ -17,6 +19,11 @@

(in-package #:clpm/http-client/defs)

(defclass http-client ()
  ((priority
    :initarg :priority
    :reader http-client-priority)))

(defvar *all-http-clients* nil
  "A list of all HTTP clients loaded into the image. An alist that maps
a (keyword) name to a class name.")
@@ -68,7 +75,9 @@ the ones where ~http-client-available-p~ returns NIL."
  (let* ((client-key (config-value :http-client :method))
         (available-http-clients (available-http-clients))
         (client (if (eql :auto client-key)
                     (cdr (first available-http-clients))
                     (iter
                       (for client :in (mapcar #'cdr available-http-clients))
                       (finding client :minimizing (http-client-priority client)))
                     (assoc-value available-http-clients client-key))))
    (unless client
      (error "Unable to find an HTTP client."))
+6 −3
Changes for src/clpm/http-client/drakma.lisp: 6 added lines, 3 removed lines.
Original line number Diff line number Diff line
@@ -9,14 +9,17 @@
          #:clpm/http-client/defs
          #:clpm/utils
          #:drakma)
  (:export #:curl-client))
  (:export #:drakma-client))

(in-package #:clpm/http-client/drakma)

(defclass drakma-client ()
(defclass drakma-client (http-client)
  ()
  (:documentation
   "Describes an HTTP client that uses drakma."))
   "Describes an HTTP client that uses drakma.")
  (:default-initargs
   ;; we like lisp, so if drakma is available, prefer to use it
   :priority 0))

(register-http-client :drakma 'drakma-client)