- Timestamp:
- 06/25/15 18:59:54 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
etherws/trunk/etherws.py
r280 r281 695 695 def __init__(self, *args, **kwargs): 696 696 super(ClientHandler, self).__init__(*args, **kwargs) 697 698 self._sslopt = kwargs.get('sslopt', {}) 699 self._options = self._getproxy() 700 701 cred = kwargs.get('cred', None) 702 703 if isinstance(cred, dict) and cred['user'] and cred['passwd']: 704 token = base64.b64encode('%s:%s' % (cred['user'], cred['passwd'])) 705 auth = ['Authorization: Basic %s' % token] 706 self._options['header'] = auth 697 self._sslopt = self._kwargs.get('sslopt', {}) 698 self._options = dict(self.authopts, **self.proxyopts) 707 699 708 700 def open(self): … … 730 722 return self.device.recv() 731 723 732 def _getproxy(self): 724 @property 725 def authopts(self): 726 cred = self._kwargs.get('cred') 727 728 if not isinstance(cred, dict): 729 return {} 730 if 'user' not in cred: 731 return {} 732 if 'passwd' not in cred: 733 return {} 734 735 token = base64.b64encode('%s:%s' % (cred['user'], cred['passwd'])) 736 return {'header': ['Authorization: Basic %s' % token]} 737 738 @property 739 def proxyopts(self): 733 740 scheme, remain = urllib2.splittype(self.target) 734 741
Note: See TracChangeset
for help on using the changeset viewer.