Subject: Re: bug#35969: 26.2, Excorporate

From: Thomas Fitzsimmons <[email-masked]>
Date: Fri, 14 Jun 2019 20:36:24 -0400

Hi,

"tenspd137 ." <[email-masked]> writes:

> (defun thefile() "/EWS/Exchange.asmx")
> 
> (copied from url-http library)
> (defun url-http-create-request (&optional ref-url)
> .....
>    ;; This was done with a call to `format'.  Concatenating parts has
>     ;; the advantage of keeping the parts of each header together and
>     ;; allows us to elide null lines directly, at the cost of making
>     ;; the layout less clear.
>     (setq request
>           (concat
>              ;; The request
>              (or url-http-method "GET") " "
>              (url-http--encode-string
>               (if using-proxy (thefile) real-fname)) <------------Changed this to "hardcode" the request as proof of concept

Starting from your results I searched the web and turned up a Stack
Overflow post [1] which pointed me to the wget source code:

    if (proxy
#ifdef HAVE_SSL
        /* When using SSL over proxy, CONNECT establishes a direct
           connection to the HTTPS server.  Therefore use the same
           argument as when talking to the server directly. */
        && u->scheme != SCHEME_HTTPS
#endif
        )
      meth_arg = xstrdup (u->url);
    else
      meth_arg = url_full_path (u);

I think that comment explains why the url connection to the HTTPS
Exchange server is failing in your case.  Applying the same logic in the
location you found would give:

diff --git a/lisp/url/url-http.el b/lisp/url/url-http.el
index 00803a103a..723d111d58 100644
--- a/lisp/url/url-http.el
+++ b/lisp/url/url-http.el
@@ -329,7 +329,10 @@ 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"

Can you try out that patch and a) see if url-retrieve-synchronously
still works, and if so, b) see if Excorporate works through the proxy
with it?

Thanks,
Thomas

1. https://stackoverflow.com/questions/20050052/what-is-the-correct-url-format-to-send-to-an-http-proxy-server