[ftputil] FTP Through HTTP Proxy
Alexander Michael
lxander.m at gmail.com
Mon Mar 26 17:04:55 CEST 2007
On 3/25/07, Stefan Schwarzer <sschwarzer at sschwarzer.net> wrote:
> Since you access the path with the ftp:// protocol part
> prepended, there seems to be no HTTP server or proxy involved.
> Note that many web browsers support FTP directly, and, if I'm not
> mistaken, the ftp:// means that HTTP isn't used at all.
Hmm. This would explain why I'm not convinced of my own analysis of
the situation, but yet, I remain uncertain.
> Do you have any FTP proxies set in your browser configuration?
Yes. I set the HTTP proxy (the usual host "proxy" on port "8080") and
checked "Use this proxy server for all protocols."
> If you are using a Unix-type operating system, you should also
> look at the ftp_proxy environment variable.
I futzed with this, but couldn't get it to work. I'm working on both
linux and Windows, but testing on linux. The linux FTP client doesn't
seem to use FTP_PROXY, and I can't ftp into the HTTP proxy server.
> Can you directly log into the FTP server with a standalone FTP
> client? It may be that the company indeed shut down the FTP proxy -
> and you now can access the server directly. :-)
I used to be able to do this. :)
> Does that help?
Yes, it does. I am operating outside my realm of expertise (if indeed
I have such a realm) and these are good questions to ask myself as I
work to solve this issue. Thank you for responding.
Here's what I've been able to make work outside of Firefox (I cobbled
this together from some Google searches):
import urllib2
ph = urllib2.ProxyHandler(
{'ftp':'http://proxy_username:proxy_password@proxy:8080'})
passmgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
passmgr.add_password(None,
'http://proxy:8080', 'proxy_username', 'proxy_password')
au = urllib2.ProxyBasicAuthHandler(passmgr)
opener = urllib2.build_opener(ph, au)
index_fobj = opener.open(
'ftp://ftp_username:ftp_password@ftpserver')
print index_fobj.read() # print an html-ized dir list
data_fobj = opener.open(
'ftp://ftp_username:ftp_password@ftpserver/remote_file.dat')
open('remote_file.dat', 'wb').write(
data_fobj.read()) # get file from ftp server
More information about the ftputil
mailing list