Permalink
Browse files

Use Dexador instead of Drakma.

  • Loading branch information...
1 parent 75be7e6 commit f202489277d1ad163621c465315fa6ddb9461a12 @fukamachi committed Sep 5, 2016
Showing with 30 additions and 94 deletions.
  1. +2 −2 .travis.yml
  2. +1 −1 README.markdown
  3. +3 −4 qlot-install.asd
  4. +0 −57 src/http.lisp
  5. +3 −4 src/install.lisp
  6. +2 −4 src/source/github.lisp
  7. +3 −4 src/source/http.lisp
  8. +8 −10 src/source/ql.lisp
  9. +8 −8 t/server.lisp
View
@@ -13,9 +13,9 @@ install:
# Roswell
- curl -L https://raw.githubusercontent.com/snmsts/roswell/release/scripts/install-for-ci.sh | sh
# Libraries to use the latest version
- - git clone https://github.com/froydnj/archive ~/lisp/archive
- # prove
+ - ros install froydnj/archive
- ros install prove
+ - ros install fukamachi/dexador
cache:
directories:
View
@@ -189,7 +189,7 @@ Eval the given form in the local quicklisp environment.
```common-lisp
(qlot:with-local-quicklisp :myapp
- (ql:quickload :drakma))
+ (ql:quickload :dexador))
```
## `qlfile` syntax
View
@@ -9,7 +9,7 @@
:license "MIT"
:depends-on (:clack
:clack-handler-hunchentoot
- :drakma
+ :dexador
:archive
:salza2
:gzip-stream
@@ -25,16 +25,15 @@
:components ((:module "src"
:components
((:file "parser" :depends-on ("source" "dist-sources" "error" "util"))
- (:file "install" :depends-on ("parser" "server" "tmp" "source" "http" "shell" "util"))
+ (:file "install" :depends-on ("parser" "server" "tmp" "source" "shell" "util"))
(:file "server" :depends-on ("source" "parser" "tmp"))
- (:file "http")
(:file "shell")
(:file "tmp" :depends-on ("util"))
(:file "archive")
(:file "source" :depends-on ("tmp" "util"))
(:module "dist-sources"
:pathname "source"
- :depends-on ("source" "http" "shell" "archive" "tmp" "util")
+ :depends-on ("source" "shell" "archive" "tmp" "util")
:serial t
:components
((:file "ql")
View
@@ -1,57 +0,0 @@
-(in-package :cl-user)
-(defpackage qlot.http
- (:use :cl)
- (:import-from :uiop
- :file-exists-p)
- (:import-from :alexandria
- :with-gensyms
- :once-only
- :copy-stream)
- (:export :http-request
- :safety-http-request
- :http-request-failed
- :download-file
- :retry-download))
-(in-package :qlot.http)
-
-(define-condition http-request-failed (simple-error)
- ((status :initarg :status :type integer)
- (url :initarg :url :type string))
- (:report
- (lambda (condition stream)
- (format stream "HTTP Request to ~A has failed (Code=~D)."
- (slot-value condition 'url)
- (slot-value condition 'status)))))
-
-(defun http-request (url &rest args)
- (apply #'drakma:http-request
- url
- (append args
- (list :user-agent (format nil "qlot/~A"
- (asdf::component-version (asdf:find-system :qlot)))))))
-
-(defun safety-http-request (url &rest args)
- (multiple-value-bind (body status)
- (apply #'http-request url args)
- (unless (= status 200)
- (error 'http-request-failed
- :url url
- :status status))
-
- body))
-
-(defun download-file (url output &key (element-type '(unsigned-byte 8)))
- (format t "~&Downloading ~S to ~S...~%" url output)
- (let (stream)
- (tagbody downloading
- (restart-case (setf stream (safety-http-request url :want-stream t))
- (retry-download ()
- :report "Retry to download."
- (when (uiop:file-exists-p output)
- (delete-file output))
- (go downloading))))
- (with-open-file (out output
- :direction :output :if-exists :supersede
- :element-type element-type)
- (alexandria:copy-stream stream out
- :element-type element-type))))
View
@@ -20,8 +20,6 @@
:update-available-p
:url-path-for
:project.txt)
- (:import-from :qlot.http
- :download-file)
(:import-from :qlot.shell
:safety-shell-command)
(:import-from :qlot.util
@@ -61,8 +59,9 @@
(generate-random-string))
*tmp-directory*)))
(ensure-directories-exist *tmp-directory*)
- (download-file "http://beta.quicklisp.org/quicklisp.lisp"
- quicklisp-file)
+ (dex:fetch "http://beta.quicklisp.org/quicklisp.lisp"
+ quicklisp-file
+ :if-exists :supersede)
#+(or ccl sbcl allegro clisp cmu ecl)
(let ((eval-option (or
@@ -6,8 +6,6 @@
:source-http
:source-http-url
:url)
- (:import-from :qlot.http
- :safety-http-request)
(:import-from :yason
:parse)
(:export :source-github
@@ -60,11 +58,11 @@
(defun retrieve-from-github (repos action)
(let ((github-access-token (uiop:getenv "GITHUB_ACCESS_TOKEN")))
(yason:parse
- (apply #'safety-http-request
+ (apply #'dex:get
(format nil "https://api.github.com/repos/~A/~A" repos action)
:want-stream t
(if github-access-token
- (list :basic-authorization (list github-access-token "x-oauth-basic"))
+ (list :basic-auth (cons github-access-token "x-oauth-basic"))
'())))))
(defun retrieve-source-git-ref-from-github (source)
@@ -6,8 +6,6 @@
:tmp-path)
(:import-from :qlot.archive
:extract-tarball)
- (:import-from :qlot.http
- :download-file)
(:import-from :ironclad
:byte-array-to-hex-string
:digest-file)
@@ -47,8 +45,9 @@
(setf (source-archive source)
(pathname
(format nil "~A.tar.gz" (source-project-name source))))
- (download-file (source-http-url source)
- (source-archive source))
+ (dex:fetch (source-http-url source)
+ (source-archive source)
+ :if-exists :supersede)
(setf (source-directory source)
(extract-tarball (source-archive source)
(tmp-path #P"source-http/repos/")))
View
@@ -2,8 +2,6 @@
(defpackage qlot.source.ql
(:use :cl
:qlot.source)
- (:import-from :qlot.http
- :safety-http-request)
(:import-from :qlot.util
:find-qlfile
:with-package-functions)
@@ -79,8 +77,8 @@
(slot-value source2 '%version))))
(defcached ql-latest-version ()
- (let ((stream (safety-http-request "http://beta.quicklisp.org/dist/quicklisp.txt"
- :want-stream t)))
+ (let ((stream (dex:get "http://beta.quicklisp.org/dist/quicklisp.txt"
+ :want-stream t)))
(or
(loop for line = (read-line stream nil nil)
while line
@@ -89,14 +87,14 @@
(error "Failed to get the latest version of Quicklisp."))))
(defun retrieve-quicklisp-releases (version)
- (safety-http-request (format nil "http://beta.quicklisp.org/dist/quicklisp/~A/releases.txt"
- version)
- :want-stream t))
+ (dex:get (format nil "http://beta.quicklisp.org/dist/quicklisp/~A/releases.txt"
+ version)
+ :want-stream t))
(defun retrieve-quicklisp-systems (version)
- (safety-http-request (format nil "http://beta.quicklisp.org/dist/quicklisp/~A/systems.txt"
- version)
- :want-stream t))
+ (dex:get (format nil "http://beta.quicklisp.org/dist/quicklisp/~A/systems.txt"
+ version)
+ :want-stream t))
(defun source-ql-releases (source)
(with-slots (project-name) source
View
@@ -9,8 +9,6 @@
:*tmp-directory*)
(:import-from :qlot.util
:generate-random-string)
- (:import-from :drakma
- :http-request)
(:import-from :uiop
:file-exists-p
:ensure-directory-pathname
@@ -32,12 +30,14 @@
(diag "starting a server..")
(start-server qlfile)
- (is (nth-value 1 (http-request (localhost "/quicklisp.txt"))) 404)
- (is (nth-value 1 (http-request (localhost "/clack.txt"))) 200)
- (is (nth-value 1 (http-request (localhost "/shelly.txt"))) 200)
- (is (nth-value 1 (http-request (localhost "/cl-dbi.txt"))) 200)
- (is (nth-value 1 (http-request (localhost "/datafly.txt"))) 200)
- (is (nth-value 1 (http-request (localhost "/log4cl.txt"))) 200)
+ (handler-case
+ (dex:get (localhost "/quicklisp.txt"))
+ (dex:http-request-not-found () (pass "/quicklisp.txt is 404")))
+ (is (nth-value 1 (dex:get (localhost "/clack.txt"))) 200)
+ (is (nth-value 1 (dex:get (localhost "/shelly.txt"))) 200)
+ (is (nth-value 1 (dex:get (localhost "/cl-dbi.txt"))) 200)
+ (is (nth-value 1 (dex:get (localhost "/datafly.txt"))) 200)
+ (is (nth-value 1 (dex:get (localhost "/log4cl.txt"))) 200)
(uiop:delete-directory-tree *tmp-directory* :validate t :if-does-not-exist :ignore)

0 comments on commit f202489

Please sign in to comment.