Package: dput
Version: 0.9.2.32
Severity: wishlist

Hi,

Specifying the port to upload on when using the http/https method in
doesn't work as it's simply not handled in http.py.

I attach a patch to enable changing the HTTP port by using "fqdn:port"
for the fqdn config variable.

Thanks,

-- 
Jonny Lamb, UK                                   [EMAIL PROTECTED]
http://jonnylamb.com                                     GPG: 0x2E039402
diff -Nruad -Nruad dput-0.9.2.32.orig/dput dput-0.9.2.32/dput
--- dput-0.9.2.32.orig/dput     2008-05-04 10:58:54.000000000 +0100
+++ dput-0.9.2.32/dput  2008-06-02 15:20:42.000000000 +0100
@@ -876,6 +876,19 @@
                   print "D: ssh config options:\n  "+'\n  
'.join(ssh_config_options)
                 upload_methods[method](fqdn, login, incoming, \
                     files_to_upload, debug, scp_compress, ssh_config_options)
+            elif method.startswith('http'):
+                if ':' in fqdn:
+                    fqdn, port = fqdn.rsplit(':',1)
+                else:
+                    if method == 'https':
+                        port = 443
+                    else:
+                        port = 80
+                if debug:
+                    print "D: HTTP port: %s" % port
+                upload_methods[method](
+                    fqdn, login, incoming, \
+                    files_to_upload, debug, 0, progress=progress, port=port)
             else:
                 upload_methods[method](fqdn, login, incoming, \
                     files_to_upload, debug, 0, progress=progress)
diff -Nruad -Nruad dput-0.9.2.32.orig/http.py dput-0.9.2.32/http.py
--- dput-0.9.2.32.orig/http.py  2008-05-01 19:56:34.000000000 +0100
+++ dput-0.9.2.32/http.py       2008-06-02 15:14:44.000000000 +0100
@@ -56,7 +56,7 @@
     return self.headers
   
 # Upload the files via WebDAV
-def upload(fqdn, login, incoming, files_to_upload, debug, dummy, progress=0, 
protocol="http"):
+def upload(fqdn, login, incoming, files_to_upload, debug, dummy, progress=0, 
protocol="http", port=80):
     # EXCEPTION HANDLING!
     if protocol == 'https':
       connclass = httplib.HTTPSConnection
@@ -92,7 +92,7 @@
        url = "%s://%s%s" % (protocol,fqdn,url_path)
         if debug:
           print "D: HTTP-PUT to URL: %s"%url
-       conn = connclass(fqdn)
+       conn = connclass(fqdn, port=int(port))
        conn.putrequest("PUT", url_path, skip_accept_encoding=True)
        # Host: should be automatic
        conn.putheader('User-Agent','dput')
@@ -120,6 +120,6 @@
            print "Upload failed as unauthorized: %s"%res.reason
            print "  Maybe wrong username or password?"
          else:
-           print "Upload failed: %d %d"%res.status, res.reason
+           print "Upload failed: %d %s" % (res.status, res.reason)
          sys.exit(1)
        res.read() # must be done, but we're not interested
diff -Nruad -Nruad dput-0.9.2.32.orig/https.py dput-0.9.2.32/https.py
--- dput-0.9.2.32.orig/https.py 2008-05-01 19:56:34.000000000 +0100
+++ dput-0.9.2.32/https.py      2008-06-02 15:20:49.000000000 +0100
@@ -3,5 +3,5 @@
 exec open("/usr/share/dput/http.py") in d
 real_upload = d["upload"]
 
-def upload(fqdn, login, incoming, files_to_upload, debug, dummy, progress=0):
-    return real_upload(fqdn, login, incoming, files_to_upload, debug, dummy, 
progress, protocol="https")
+def upload(fqdn, login, incoming, files_to_upload, debug, dummy, progress=0, 
port=443):
+    return real_upload(fqdn, login, incoming, files_to_upload, debug, dummy, 
progress, protocol="https", port=port)

Attachment: signature.asc
Description: Digital signature

Reply via email to