-
-
Notifications
You must be signed in to change notification settings - Fork 44
/
Copy pathproxy.lisp
46 lines (43 loc) · 1.56 KB
/
proxy.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
(defpackage #:qlot/proxy
(:use #:cl)
(:export #:*proxy*))
(in-package #:qlot/proxy)
(defvar *proxy*
(or (uiop:getenvp "http_proxy")
(uiop:getenvp "HTTP_PROXY")))
#+quicklisp
(eval-when (:compile-toplevel :load-toplevel :execute)
;; Previously, this wrapper was defined in the next
;; eval-when block as a lambda form.
;;
;; But this caused issue when loading cached
;; files:
;; https://github.com/fukamachi/qlot/issues/104
;;
;; For some reason, a separate function definition
;; works as expected.
(defun qlot-http-fetch (url &rest rest)
(if (find :quicklisp *features*)
(progv (list (intern (string '#:*proxy-url*) '#:ql))
(list
;; do not use proxy if connect localhost
(if (eql (search #1="qlot://localhost/" url
:end2 (length #1#))
0)
nil
(symbol-value (intern (string '#:*proxy-url*) '#:ql))))
(apply #'orig-http-fetch url rest))
(apply #'orig-http-fetch url rest))))
#+quicklisp
(eval-when (:compile-toplevel :load-toplevel :execute)
(unless (fboundp 'orig-http-fetch)
;; dummy for suppress style warning
(defun orig-http-fetch (&rest args)
(declare (ignore args))
(error "A dummy function is called"))
(when (find-package '#:ql-http)
(setf (symbol-function 'orig-http-fetch)
(fdefinition
(find-symbol (string '#:http-fetch) '#:ql-http)))
(setf (fdefinition (find-symbol (string '#:http-fetch) '#:ql-http))
#'qlot-http-fetch))))