mirror of
https://git.freebsd.org/ports.git
synced 2025-07-18 17:59:20 -04:00
o Add a missing exception handler around httplib requests
o Bump PORTREVISION Approved by: portmgr (krion) Obtained from: John Hoffman BitTornado Developer <theshadow@degreez.net>
This commit is contained in:
parent
4a58d04c9f
commit
dc9079bdf7
Notes:
svn2git
2021-03-31 03:12:20 +00:00
svn path=/head/; revision=125732
4 changed files with 92 additions and 2 deletions
|
@ -7,7 +7,7 @@
|
|||
|
||||
PORTNAME= BitTorrent
|
||||
PORTVERSION= 3.9.0
|
||||
PORTREVISION= 2
|
||||
PORTREVISION= 3
|
||||
PORTEPOCH= 1
|
||||
CATEGORIES?= net python
|
||||
MASTER_SITES= http://www.bittorrent.com/
|
||||
|
|
|
@ -0,0 +1,45 @@
|
|||
--- BitTorrent/zurllib.py.orig Wed Jan 5 20:41:27 2005
|
||||
+++ BitTorrent/zurllib.py Wed Jan 5 20:41:50 2005
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
# Written by John Hoffman
|
||||
|
||||
-from httplib import HTTPConnection
|
||||
+from httplib import HTTPConnection, HTTPException
|
||||
from urlparse import urlparse
|
||||
import socket
|
||||
from gzip import GzipFile
|
||||
@@ -20,6 +20,15 @@
|
||||
|
||||
MAX_REDIRECTS = 10
|
||||
|
||||
+class btHTTPcon(HTTPConnection): # attempt to add automatic connection timeout
|
||||
+ def connect(self):
|
||||
+ HTTPConnection.connect(self)
|
||||
+ try:
|
||||
+ self.sock.settimeout(30)
|
||||
+ except:
|
||||
+ pass
|
||||
+
|
||||
+
|
||||
class urlopen:
|
||||
def __init__(self, url):
|
||||
self.tries = 0
|
||||
@@ -39,11 +48,14 @@
|
||||
if query:
|
||||
url += '?'+query
|
||||
# if fragment:
|
||||
- self.connection = HTTPConnection(netloc)
|
||||
- self.connection.request('GET', url, None,
|
||||
+ try:
|
||||
+ self.connection = btHTTPcon(netloc)
|
||||
+ self.connection.request('GET', url, None,
|
||||
{ 'User-Agent': 'BitTorrent/' + version,
|
||||
'Accept-Encoding': 'gzip' } )
|
||||
- self.response = self.connection.getresponse()
|
||||
+ self.response = self.connection.getresponse()
|
||||
+ except HTTPException, e:
|
||||
+ raise IOError, ('http error', str(e))
|
||||
status = self.response.status
|
||||
if status in (301,302):
|
||||
try:
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
PORTNAME= BitTorrent
|
||||
PORTVERSION= 3.9.0
|
||||
PORTREVISION= 2
|
||||
PORTREVISION= 3
|
||||
PORTEPOCH= 1
|
||||
CATEGORIES?= net python
|
||||
MASTER_SITES= http://www.bittorrent.com/
|
||||
|
|
45
net/py-bittorrent-devel/files/patch-BitTorrent::zurllib.py
Normal file
45
net/py-bittorrent-devel/files/patch-BitTorrent::zurllib.py
Normal file
|
@ -0,0 +1,45 @@
|
|||
--- BitTorrent/zurllib.py.orig Wed Jan 5 20:41:27 2005
|
||||
+++ BitTorrent/zurllib.py Wed Jan 5 20:41:50 2005
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
# Written by John Hoffman
|
||||
|
||||
-from httplib import HTTPConnection
|
||||
+from httplib import HTTPConnection, HTTPException
|
||||
from urlparse import urlparse
|
||||
import socket
|
||||
from gzip import GzipFile
|
||||
@@ -20,6 +20,15 @@
|
||||
|
||||
MAX_REDIRECTS = 10
|
||||
|
||||
+class btHTTPcon(HTTPConnection): # attempt to add automatic connection timeout
|
||||
+ def connect(self):
|
||||
+ HTTPConnection.connect(self)
|
||||
+ try:
|
||||
+ self.sock.settimeout(30)
|
||||
+ except:
|
||||
+ pass
|
||||
+
|
||||
+
|
||||
class urlopen:
|
||||
def __init__(self, url):
|
||||
self.tries = 0
|
||||
@@ -39,11 +48,14 @@
|
||||
if query:
|
||||
url += '?'+query
|
||||
# if fragment:
|
||||
- self.connection = HTTPConnection(netloc)
|
||||
- self.connection.request('GET', url, None,
|
||||
+ try:
|
||||
+ self.connection = btHTTPcon(netloc)
|
||||
+ self.connection.request('GET', url, None,
|
||||
{ 'User-Agent': 'BitTorrent/' + version,
|
||||
'Accept-Encoding': 'gzip' } )
|
||||
- self.response = self.connection.getresponse()
|
||||
+ self.response = self.connection.getresponse()
|
||||
+ except HTTPException, e:
|
||||
+ raise IOError, ('http error', str(e))
|
||||
status = self.response.status
|
||||
if status in (301,302):
|
||||
try:
|
Loading…
Add table
Reference in a new issue