Re: [LFTP] https_proxy

"Alexander V. Lukyanov" <[email protected]> Tue, 10 Mar 2015 10:25:14 +0300
Newsgroups gmane.network.lftp.user
Message-ID <[email protected]>
On Wed, Mar 04, 2015 at 09:52:36AM +0100, Vincent Lasselin wrote:
> One example of an unsuccessfull connection with https.

Thanks! Please try this patch.

--
   Alexander.

_______________________________________________
lftp mailing list
[email protected]
http://univ.uniyar.ac.ru/mailman/listinfo/lftp
diff (text/plain, 1.8 KB)
diff --git a/src/Http.cc b/src/Http.cc
index 9705f36..de01b40 100644
--- a/src/Http.cc
+++ b/src/Http.cc
@@ -414,10 +414,14 @@ void Http::SendBasicAuth(const char *tag,const char *user,const char *pass)
    SendBasicAuth(tag,xstring::cat(user,":",pass,NULL));
 }
 
-void Http::SendAuth()
+void Http::SendProxyAuth()
 {
    if(proxy && proxy_user && proxy_pass)
       SendBasicAuth("Proxy-Authorization",proxy_user,proxy_pass);
+}
+
+void Http::SendAuth()
+{
    if(user && pass && !(hftp && !QueryBool("use-authorization",proxy)))
       SendBasicAuth("Authorization",user,pass);
    else if(!hftp)
@@ -736,6 +740,8 @@ void Http::SendRequest(const char *connection,const char *f)
 	 Send("Destination: %s\r\n",GetFileURL(file1));
       }
    }
+   if(proxy && !https)
+      SendProxyAuth();
    SendAuth();
    if(no_cache || no_cache_this)
       Send("Pragma: no-cache\r\n"); // for HTTP/1.0 compatibility
@@ -1322,7 +1328,9 @@ int Http::Do()
 	    AppendHostEncoded(ehost,hostname);
 	    const char *port_to_use=portname?portname.get():HTTPS_DEFAULT_PORT;
 	    const char *eport=url::encode(port_to_use,URL_PORT_UNSAFE);
-	    Send("CONNECT %s:%s HTTP/1.1\r\n\r\n",ehost.get(),eport);
+	    Send("CONNECT %s:%s HTTP/1.1\r\n",ehost.get(),eport);
+	    SendProxyAuth();
+	    Send("\r\n");
 	    tunnel_state=TUNNEL_WAITING;
 	    state=RECEIVING_HEADER;
 	    return MOVED;
diff --git a/src/Http.h b/src/Http.h
index fdcecb4..e377a0d 100644
--- a/src/Http.h
+++ b/src/Http.h
@@ -86,6 +86,7 @@ class Http : public NetAccess
    xstring special_data;
    void DirFile(xstring& path,const xstring& ecwd,const xstring& efile) const;
    void SendAuth();
+   void SendProxyAuth();
    void SendCacheControl();
    void SendBasicAuth(const char *tag,const char *auth);
    void SendBasicAuth(const char *tag,const char *u,const char *p);