mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-16 02:03:07 -07:00
Search plugins: Properly uncompress gzipped responses in retrieve_url()
This commit is contained in:
parent
4db73d421d
commit
1b3a758f28
1 changed files with 8 additions and 1 deletions
|
@ -22,7 +22,7 @@
|
||||||
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
# POSSIBILITY OF SUCH DAMAGE.
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
|
||||||
#VERSION: 1.31
|
#VERSION: 1.32
|
||||||
|
|
||||||
# Author:
|
# Author:
|
||||||
# Christophe DUMEZ (chris@qbittorrent.org)
|
# Christophe DUMEZ (chris@qbittorrent.org)
|
||||||
|
@ -64,6 +64,13 @@ def retrieve_url(url):
|
||||||
req = urllib2.Request(url)
|
req = urllib2.Request(url)
|
||||||
response = urllib2.urlopen(req)
|
response = urllib2.urlopen(req)
|
||||||
dat = response.read()
|
dat = response.read()
|
||||||
|
# Check if it is gzipped
|
||||||
|
if dat[:2] == '\037\213':
|
||||||
|
# Data is gzip encoded, decode it
|
||||||
|
compressedstream = StringIO.StringIO(dat)
|
||||||
|
gzipper = gzip.GzipFile(fileobj=compressedstream)
|
||||||
|
extracted_data = gzipper.read()
|
||||||
|
dat = extracted_data
|
||||||
info = response.info()
|
info = response.info()
|
||||||
charset = 'utf-8'
|
charset = 'utf-8'
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue