mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-12-23 00:47:21 -06:00
BUGFIX: Improved HTTP gzip compression detection in downloader
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
- BUGFIX: Only one program preferences dialog is allowed at a time
|
- BUGFIX: Only one program preferences dialog is allowed at a time
|
||||||
- BUGFIX: Link against boost and ssl to fix issues with gold linker
|
- BUGFIX: Link against boost and ssl to fix issues with gold linker
|
||||||
- BUGFIX: Fix memory leak in RSS
|
- BUGFIX: Fix memory leak in RSS
|
||||||
|
- BUGFIX: Improved HTTP gzip compression detection in downloader
|
||||||
|
|
||||||
* Mon Feb 8 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.1.4
|
* Mon Feb 8 2010 - Christophe Dumez <chris@qbittorrent.org> - v2.1.4
|
||||||
- BUGFIX: Fix file prioritizing in a torrent
|
- BUGFIX: Fix file prioritizing in a torrent
|
||||||
|
|||||||
@@ -103,6 +103,7 @@ void downloadThread::downloadUrl(QString url){
|
|||||||
// Spoof Firefox 3.5 user agent to avoid
|
// Spoof Firefox 3.5 user agent to avoid
|
||||||
// Web server banning
|
// Web server banning
|
||||||
request.setRawHeader("User-Agent", "Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5");
|
request.setRawHeader("User-Agent", "Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5");
|
||||||
|
request.setRawHeader("Accept-Encoding", "");
|
||||||
qDebug("Downloading %s...", request.url().toString().toLocal8Bit().data());
|
qDebug("Downloading %s...", request.url().toString().toLocal8Bit().data());
|
||||||
networkManager->get(request);
|
networkManager->get(request);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,15 +84,14 @@ def download_file(url, referer=None):
|
|||||||
req.add_header('referer', referer)
|
req.add_header('referer', referer)
|
||||||
response = urllib2.urlopen(req)
|
response = urllib2.urlopen(req)
|
||||||
dat = response.read()
|
dat = response.read()
|
||||||
# Check if data is gzip encoded
|
# Check if it is gzipped
|
||||||
response_info = response.info()
|
if dat[:2] == '\037\213':
|
||||||
content_encoding = response_info.get('Content-Encoding')
|
|
||||||
if content_encoding is not None and 'gzip' in content_encoding:
|
|
||||||
# Data is gzip encoded, decode it
|
# Data is gzip encoded, decode it
|
||||||
compressedstream = StringIO.StringIO(dat)
|
compressedstream = StringIO.StringIO(dat)
|
||||||
gzipper = gzip.GzipFile(fileobj=compressedstream)
|
gzipper = gzip.GzipFile(fileobj=compressedstream)
|
||||||
extracted_data = gzipper.read()
|
extracted_data = gzipper.read()
|
||||||
dat = extracted_data
|
dat = extracted_data
|
||||||
|
|
||||||
# Write it to a file
|
# Write it to a file
|
||||||
file.write(dat)
|
file.write(dat)
|
||||||
file.close()
|
file.close()
|
||||||
|
|||||||
Reference in New Issue
Block a user