Function: url-find-proxy-for-url

url-find-proxy-for-url is a byte-compiled function defined in url-proxy.el.gz.

Signature

(url-find-proxy-for-url URL HOST)

Source Code

;; Defined in /usr/src/emacs/lisp/url/url-proxy.el.gz
(defun url-find-proxy-for-url (url host)
  (let ((proxies (split-string (funcall url-proxy-locator url host) " *; *"))
	(proxy nil)
	(case-fold-search t))
    ;; Not sure how I should handle gracefully degrading from one proxy to
    ;; another, so for now just deal with the first one
    ;; (while proxies
    (setq proxy (if (listp proxies) (car proxies) proxies))
    (cond
     ((string-match "^DIRECT" proxy) nil)
     ((string-match "^PROXY +" proxy)
      (concat "http://" (substring proxy (match-end 0)) "/"))
     ((string-match "^SOCKS +" proxy)
      (concat "socks://" (substring proxy (match-end 0))))
     (t
      (display-warning 'url (format "Unknown proxy directive: %s" proxy) :error)
      nil))))