我寫一個簡單的上傳腳本,只是釣到接下來的事情:捲曲試圖做PUT一個FTP服務器上:捲曲(pycurl)FTP over HTTP代理
簡化代碼:
import pycurl
from os.path import getsize
c = pycurl.Curl()
c.setopt(pycurl.URL, 'ftp://<ftp_name>:21/asus.c')
c.setopt(pycurl.USERPWD, 'username:password')
c.setopt(pycurl.PROXY, '10.0.0.35')
c.setopt(pycurl.PROXYPORT, 3128)
c.setopt(pycurl.VERBOSE, 1)
f = open('asus.c')
c.setopt(pycurl.INFILE, f)
c.setopt(pycurl.INFILESIZE, getsize('asus.c'))
c.setopt(pycurl.HTTPPROXYTUNNEL, 1)
c.setopt(pycurl.UPLOAD, 1)
c.perform()
幾乎相同的代碼運行良好幾個月前,但:
* About to connect() to proxy <IP> port 3128 (#0)
* Trying <IP>... * connected
* Connected to <IP> (<IP>) port 3128 (#0)
* Establish HTTP proxy tunnel to <ftp_name>:21
* Server auth using Basic with user 'username'
> CONNECT <ftp_name>:21 HTTP/1.1
Host: <ftp_name>:21
User-Agent: PycURL/7.21.6
Proxy-Connection: Keep-Alive
< HTTP/1.0 200 Connection established
<
* Proxy replied OK to CONNECT request
* Server auth using Basic with user 'username'
> PUT /asus.c HTTP/1.1
Authorization: Basic _______________________________
User-Agent: PycURL/7.21.6
Host: <ftp_name>:21
Accept: */*
Content-Length: 2627
Expect: 100-continue
220 ProFTPD 1.3.3 Server (______ FTP Server) [<IP>]
500 PUT not understood
500 AUTHORIZATION: not understood
500 USER-AGENT: not understood
500 HOST: not understood
500 ACCEPT: not understood
500 CONTENT-LENGTH: not understood
500 EXPECT: not understood
500 Invalid command: try being more creative
而且同樣的反應,當我嘗試這樣做從外殼:
curl --upload-file "asus.c" --proxy 10.0.0.35:3128 \
--proxytunnel -u username:password ftp://<ftp_name>/asus.c
爲什麼?我錯過了什麼?
它看起來像你試圖說服HTTP到FTP服務器。您的代理是否以這些設置作爲FTP代理工作,例如從瀏覽器或已知的FTP客戶端? – 9000 2012-02-06 19:03:37
是的。 FileZilla通過這個代理連接(並上傳)罰款(這是一個配置的魷魚)。 – 2012-02-06 19:12:24