head 1.2; access; symbols pkgsrc-2013Q2:1.2.0.18 pkgsrc-2013Q2-base:1.2 pkgsrc-2012Q4:1.2.0.16 pkgsrc-2012Q4-base:1.2 pkgsrc-2011Q4:1.2.0.14 pkgsrc-2011Q4-base:1.2 pkgsrc-2011Q2:1.2.0.12 pkgsrc-2011Q2-base:1.2 pkgsrc-2009Q4:1.2.0.10 pkgsrc-2009Q4-base:1.2 pkgsrc-2008Q4:1.2.0.8 pkgsrc-2008Q4-base:1.2 pkgsrc-2008Q3:1.2.0.6 pkgsrc-2008Q3-base:1.2 cube-native-xorg:1.2.0.4 cube-native-xorg-base:1.2 pkgsrc-2008Q2:1.2.0.2 pkgsrc-2008Q2-base:1.2 pkgsrc-2008Q1:1.1.0.38 pkgsrc-2008Q1-base:1.1 pkgsrc-2007Q4:1.1.0.36 pkgsrc-2007Q4-base:1.1 pkgsrc-2007Q3:1.1.0.34 pkgsrc-2007Q3-base:1.1 pkgsrc-2007Q2:1.1.0.32 pkgsrc-2007Q2-base:1.1 pkgsrc-2007Q1:1.1.0.30 pkgsrc-2007Q1-base:1.1 pkgsrc-2006Q4:1.1.0.28 pkgsrc-2006Q4-base:1.1 pkgsrc-2006Q3:1.1.0.26 pkgsrc-2006Q3-base:1.1 pkgsrc-2006Q2:1.1.0.24 pkgsrc-2006Q2-base:1.1 pkgsrc-2006Q1:1.1.0.22 pkgsrc-2006Q1-base:1.1 pkgsrc-2005Q4:1.1.0.20 pkgsrc-2005Q4-base:1.1 pkgsrc-2005Q3:1.1.0.18 pkgsrc-2005Q3-base:1.1 pkgsrc-2005Q2:1.1.0.16 pkgsrc-2005Q2-base:1.1 pkgsrc-2005Q1:1.1.0.14 pkgsrc-2005Q1-base:1.1 pkgsrc-2004Q4:1.1.0.12 pkgsrc-2004Q4-base:1.1 pkgsrc-2004Q3:1.1.0.10 pkgsrc-2004Q3-base:1.1 pkgsrc-2004Q2:1.1.0.8 pkgsrc-2004Q2-base:1.1 pkgsrc-2004Q1:1.1.0.6 pkgsrc-2004Q1-base:1.1 pkgsrc-2003Q4:1.1.0.4 pkgsrc-2003Q4-base:1.1 netbsd-1-6-1:1.1.0.2 netbsd-1-6-1-base:1.1; locks; strict; comment @# @; 1.2 date 2008.04.25.16.11.13; author tnn; state dead; branches; next 1.1; 1.1 date 2002.10.16.15.51.04; author tsarna; state Exp; branches; next ; desc @@ 1.2 log @De-orbit support for python 2.0 and python 2.2 under the "three major releases is enough" rule of thumb. (python 2.3 was released 5 years ago.) Keep python 1.5 and 2.1 though, because there are a handful of packages that still need them. @ text @$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 @ 1.1 log @Add an unofficial patch that allows xmlrpclib to supply Basic Auth. Shouldn't affect other uses, just ads a missing feature. @ text @d1 1 a1 1 $NetBSD$ @