Subject: bug#35969: 26.2, Excorporate

From: Thomas Fitzsimmons <[email-masked]>
Date: Wed, 31 Jul 2019 21:58:22 -0400

Andreas Schwab <[email-masked]> writes:

> On Jul 31 2019, Thomas Fitzsimmons <[email-masked]> wrote:
>
>> Andreas, do you have a test case that patch A fixed, and if so, can
>> you retest with the proposed fix?
>
> Any https request over proxy will do.

OK, I tested the attached patch; it works for a request to an uncached
HTTPS website, and it works for Excorporate accessing an HTTPS server.

I moved the URL form logic to url-http-create-request because that
function refers to using-proxy (set to url-http-proxy on entry) in
multiple places, not just during URL recreation.  When
url-https-proxy-after-change-function was setting using-proxy to nil for
the entire duration of the url-http-create-request, it was interfering
with "Connection" handling later in the function:

   "Connection: " (if (or using-proxy
                          (not url-http-attempt-keepalives))
                      "close" "keep-alive")

Does this look OK to push to master?

Thanks,
Thomas

diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el
index 838f0a30c1..354cc56de4 100644
--- a/lisp/url/url-http.el
+++ b/lisp/url/url-http.el
@@ -329,7 +329,9 @@ url-http-create-request
              ;; The request
              (or url-http-method "GET") " "
              (url-http--encode-string
-              (if using-proxy (url-recreate-url url-http-target-url) real-fname))
+              (if (and using-proxy
+                       (not (equal "https" (url-type url-http-target-url))))
+                  (url-recreate-url url-http-target-url) real-fname))
              " HTTP/" url-http-version "\r\n"
              ;; Version of MIME we speak
              "MIME-Version: 1.0\r\n"
@@ -1435,9 +1437,7 @@ url-https-proxy-after-change-function
                         'url-http-wait-for-headers-change-function)
                   (set-process-filter tls-connection 'url-http-generic-filter)
                   (process-send-string tls-connection
-                                       ;; Use the non-proxy form of the request
-                                       (let (url-http-proxy)
-                                         (url-http-create-request))))
+                                       (url-http-create-request)))
               (gnutls-error
                (url-http-activate-callback)
                (error "gnutls-error: %s" e))