summaryrefslogtreecommitdiff
path: root/lang/python22
diff options
context:
space:
mode:
authortsarna <tsarna@pkgsrc.org>2002-10-16 15:51:03 +0000
committertsarna <tsarna@pkgsrc.org>2002-10-16 15:51:03 +0000
commit6cac91ef5ed6f6ff0c1f482b7a301f3d35ab5df0 (patch)
tree767be914acd64c9b2cd149cf3480dffa6535beb6 /lang/python22
parente0542c19e0f1f9b544d1483a1a4869b53c2284d2 (diff)
downloadpkgsrc-6cac91ef5ed6f6ff0c1f482b7a301f3d35ab5df0.tar.gz
Add an unofficial patch that allows xmlrpclib to supply Basic Auth.
Shouldn't affect other uses, just ads a missing feature.
Diffstat (limited to 'lang/python22')
-rw-r--r--lang/python22/distinfo3
-rw-r--r--lang/python22/patches/patch-af88
2 files changed, 90 insertions, 1 deletions
diff --git a/lang/python22/distinfo b/lang/python22/distinfo
index 6a4353d9546..a3702b0e2e1 100644
--- a/lang/python22/distinfo
+++ b/lang/python22/distinfo
@@ -1,7 +1,8 @@
-$NetBSD: distinfo,v 1.7 2002/10/15 16:16:35 tsarna Exp $
+$NetBSD: distinfo,v 1.8 2002/10/16 15:51:03 tsarna Exp $
SHA1 (Python-2.2.2.tgz) = 52e5dc6273c83973f8fc92a7f19c15f97e59fc0e
Size (Python-2.2.2.tgz) = 6669400 bytes
SHA1 (patch-aa) = b6320ac24c1924d6e7924b6f4d6a42d146e2e8ab
SHA1 (patch-ab) = aa06824d9f595a24aaddc96c83f31646f522ab09
SHA1 (patch-ae) = aefeec78e25631a6e9e2aa047dce12c9c522715e
+SHA1 (patch-af) = a2b23859941766319f638e40c49b5af3f504ef52
diff --git a/lang/python22/patches/patch-af b/lang/python22/patches/patch-af
new file mode 100644
index 00000000000..5489702ef0b
--- /dev/null
+++ b/lang/python22/patches/patch-af
@@ -0,0 +1,88 @@
+$NetBSD: patch-af,v 1.1 2002/10/16 15:51:04 tsarna Exp $
+
+Unofficial patch to support Basic Auth for XML-RPC.
+
+--- Lib/xmlrpclib.py.orig Tue Oct 15 18:52:10 2002
++++ Lib/xmlrpclib.py Wed Oct 16 11:44:47 2002
+@@ -852,20 +852,55 @@
+
+ return self.parse_response(h.getfile())
+
++ ##
++ # Get authorization info from host parameter
++ # Host may be a string, or a (host, x509-dict) tuple; if a string,
++ # it is checked for a 'user:pw@host' format, and a "Basic Auth"
++ # header is created from the 'user:pw' info.
++ #
++ # @return A tuple of: (actual host, base64-encoded Authorization
++ # header or None, x509 info or empty dictionary)
++
++ def get_host_info(self, host):
++
++ x509 = {}
++ if isinstance(host,tuple):
++ host, x509 = host
++
++ import urllib
++ auth, host = urllib.splituser(host)
++
++ if auth:
++ auth='Basic %s' % auth.encode('base64').strip()
++ else:
++ auth=None
++
++ return host, auth, x509
++
+ def getparser(self):
+ # get parser and unmarshaller
+ return getparser()
+
+ def make_connection(self, host):
+ # create a HTTP connection object from a host descriptor
++ host, auth, x509 = self.get_host_info(host)
+ import httplib
+ return httplib.HTTP(host)
+
+ def send_request(self, connection, handler, request_body):
+ connection.putrequest("POST", handler)
+
++ ##
++ # Send host name (and authorization, if any)
++ #
++ # @param connection Connection handle.
++ # @param host Host object (per get_host_info).
++
+ def send_host(self, connection, host):
++ host, auth, x509 = self.get_host_info(host)
+ connection.putheader("Host", host)
++ if auth:
++ connection.putheader("Authorization", auth)
+
+ def send_user_agent(self, connection):
+ connection.putheader("User-Agent", self.user_agent)
+@@ -901,11 +936,10 @@
+ def make_connection(self, host):
+ # create a HTTPS connection object from a host descriptor
+ # host may be a string, or a (host, x509-dict) tuple
++
+ import httplib
+- if isinstance(host, TupleType):
+- host, x509 = host
+- else:
+- x509 = {}
++ host, auth, x509 = self.get_host_info(host)
++
+ try:
+ HTTPS = httplib.HTTPS
+ except AttributeError:
+@@ -914,10 +948,6 @@
+ else:
+ return apply(HTTPS, (host, None), x509)
+
+- def send_host(self, connection, host):
+- if isinstance(host, TupleType):
+- host, x509 = host
+- connection.putheader("Host", host)
+
+ class ServerProxy:
+ """uri [,options] -> a logical connection to an XML-RPC server