mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-03-23 09:20:30 +00:00
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@690 e7d03fd6-7b0d-0410-9947-9c21f3af8025
22 lines
869 B
Python
22 lines
869 B
Python
from UrlData import UrlData
|
|
from urllib import splittype, splithost, splituser, splitpasswd
|
|
|
|
class ProxyUrlData (UrlData):
|
|
"""urldata with ability for proxying and for urls with user:pass@host
|
|
setting"""
|
|
|
|
def setProxy (self, proxy):
|
|
self.proxy = proxy
|
|
self.proxyauth = None
|
|
if self.proxy:
|
|
if self.proxy[:7].lower() != "http://":
|
|
self.proxy = "http://"+self.proxy
|
|
self.proxy = splittype(self.proxy)[1]
|
|
self.proxy = splithost(self.proxy)[0]
|
|
self.proxyauth, self.proxy = splituser(self.proxy)
|
|
if self.proxyauth is not None:
|
|
if ":" not in self.proxyauth: self.proxyauth += ":"
|
|
import base64
|
|
self.proxyauth = base64.encodestring(self.proxyauth).strip()
|
|
self.proxyauth = "Basic "+self.proxyauth
|
|
|