# You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # # This is (hopefully) a drop-in for urllib which will request gzip/deflate # compression and then decompress the output if a compressed response is # received while maintaining the API. # # by Robert Stone 2/22/2003 # extended by Matt Chisholm # tracker announce --bind support added by Jeremy Evans 11/2005 import sys import threading import thread from BitTorrent import PeerID user_agent = PeerID.make_id() del PeerID import urllib2 OldOpenerDirector = urllib2.OpenerDirector class MyOpenerDirector(OldOpenerDirector): def __init__(self): OldOpenerDirector.__init__(self) self.addheaders = [('User-agent', user_agent)] urllib2.OpenerDirector = MyOpenerDirector del urllib2
def _make_id(self): return PeerID.make_id()
# # zurllib.py # # This is (hopefully) a drop-in for urllib which will request gzip/deflate # compression and then decompress the output if a compressed response is # received while maintaining the API. # # by Robert Stone 2/22/2003 # extended by Matt Chisholm # tracker announce --bind support added by Jeremy Evans 11/2005 import sys import threading import thread from BitTorrent import PeerID user_agent = PeerID.make_id() del PeerID import urllib2 OldOpenerDirector = urllib2.OpenerDirector class MyOpenerDirector(OldOpenerDirector): def __init__(self): OldOpenerDirector.__init__(self) self.addheaders = [('User-agent', user_agent)] urllib2.OpenerDirector = MyOpenerDirector del urllib2 from httplib import HTTPConnection, HTTP