summaryrefslogtreecommitdiffstats
path: root/module/network/HTTPChunk.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2012-01-15 19:28:12 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2012-01-15 19:28:12 +0100
commit17b3595dc5db8b3270e6bcd07176ed4b7b47930a (patch)
tree22585271445d40866e8a311db3372a93c39b4b82 /module/network/HTTPChunk.py
parentbackend + api test case, nicer format for plugin tester (diff)
downloadpyload-17b3595dc5db8b3270e6bcd07176ed4b7b47930a.tar.xz
improved handling of content-disposition
Diffstat (limited to 'module/network/HTTPChunk.py')
-rw-r--r--module/network/HTTPChunk.py17
1 files changed, 11 insertions, 6 deletions
diff --git a/module/network/HTTPChunk.py b/module/network/HTTPChunk.py
index add2cc094..3380fb733 100644
--- a/module/network/HTTPChunk.py
+++ b/module/network/HTTPChunk.py
@@ -20,10 +20,13 @@ from os import remove, stat, fsync
from os.path import exists
from time import sleep
from re import search
-from module.utils.fs import fs_encode
+
import codecs
import pycurl
+from module.utils import remove_chars
+from module.utils.fs import fs_encode
+
from HTTPRequest import HTTPRequest
class WrongFormat(Exception):
@@ -256,11 +259,13 @@ class HTTPChunk(HTTPRequest):
if line.startswith("accept-ranges") and "bytes" in line:
self.p.chunkSupport = True
- if line.startswith("content-disposition") and "filename=" in line:
- name = orgline.partition("filename=")[2]
- name = name.replace('"', "").replace("'", "").replace(";", "").strip()
- self.p.nameDisposition = name
- self.log.debug("Content-Disposition: %s" % name)
+ if "content-disposition" in line:
+
+ m = search("filename(?P<type>=|\*=(?P<enc>.+)'')(?P<name>.*)", line)
+ if m:
+ name = remove_chars(m.groupdict()['name'], "\"';").strip()
+ self.p._name = name
+ self.log.debug("Content-Disposition: %s" % name)
if not self.resume and line.startswith("content-length"):
self.p.size = int(line.split(":")[1])