forked from fukamachi/qlot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproxy.lisp
29 lines (26 loc) · 906 Bytes
/
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
(defpackage #:qlot/proxy
(:use #:cl)
(:import-from #:uiop
#:getenvp)
(:export #:get-proxy))
(in-package #:qlot/proxy)
(defvar *proxy*
(let ((proxy (or (getenvp "http_proxy")
(getenvp "HTTP_PROXY"))))
(and (not (string= "" proxy)) proxy)))
(defun get-proxy ()
*proxy*)
#+quicklisp
(progn
;; dummy for suppress style warning
(defun orig-http-fetch ())
(setf (symbol-function 'orig-http-fetch) (fdefinition
(find-symbol (string :http-fetch) :ql-http)))
;; do not use proxy if connect localhost
(setf (fdefinition (find-symbol (string :http-fetch) :ql-http))
(lambda (url &rest rest)
(let ((ql:*proxy-url*
(if (eql (search "http://127.0.0.1" url) 0)
nil
ql:*proxy-url*)))
(apply #'orig-http-fetch url rest)))))