]> git.eshelyaron.com Git - emacs.git/commitdiff
Support Proxy-Authorization in HTTPS CONNECT proxies
authorSatoshi Nakagawa <ghnacker@gmail.com>
Sun, 19 Jul 2020 19:12:08 +0000 (21:12 +0200)
committerLars Ingebrigtsen <larsi@gnus.org>
Sun, 19 Jul 2020 19:12:17 +0000 (21:12 +0200)
* lisp/url/url-http.el (url-https-proxy-connect): Support CONNECT
with Proxy-Authorization header (bug#42422).

Copyright-paperwork-exempt: yes

lisp/url/url-http.el

index 669c24571f91906ea5ebcc2580c654a43aa83ce8..c8a2da0546935a762083046c17b99a377bc4c0ad 100644 (file)
@@ -1404,13 +1404,22 @@ The return value of this function is the retrieval buffer."
 
 (defun url-https-proxy-connect (connection)
   (setq url-http-after-change-function 'url-https-proxy-after-change-function)
-  (process-send-string connection (format (concat "CONNECT %s:%d HTTP/1.1\r\n"
-                                                  "Host: %s\r\n"
-                                                  "\r\n")
-                                          (url-host url-current-object)
-                                          (or (url-port url-current-object)
-                                              url-https-default-port)
-                                          (url-host url-current-object))))
+  (process-send-string
+   connection
+   (format
+    (concat "CONNECT %s:%d HTTP/1.1\r\n"
+            "Host: %s\r\n"
+            (let ((proxy-auth (let ((url-basic-auth-storage
+                                     'url-http-proxy-basic-auth-storage))
+                                (url-get-authentication url-http-proxy nil
+                                                        'any nil))))
+              (and proxy-auth
+                   (concat "Proxy-Authorization: " proxy-auth "\r\n")))
+            "\r\n")
+    (url-host url-current-object)
+    (or (url-port url-current-object)
+        url-https-default-port)
+    (url-host url-current-object))))
 
 (defun url-https-proxy-after-change-function (_st _nd _length)
   (let* ((process-buffer (current-buffer))