From 1ecdd9f6b53fec45e1d48592e3ff56aa7a576bec Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sun, 8 Jan 2012 16:47:52 +0100 Subject: some cleanups, closed #490 --- module/network/HTTPChunk.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'module/network/HTTPChunk.py') diff --git a/module/network/HTTPChunk.py b/module/network/HTTPChunk.py index b637aef32..add2cc094 100644 --- a/module/network/HTTPChunk.py +++ b/module/network/HTTPChunk.py @@ -20,7 +20,7 @@ from os import remove, stat, fsync from os.path import exists from time import sleep from re import search -from module.utils import fs_encode +from module.utils.fs import fs_encode import codecs import pycurl -- cgit v1.2.3 From 17b3595dc5db8b3270e6bcd07176ed4b7b47930a Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sun, 15 Jan 2012 19:28:12 +0100 Subject: improved handling of content-disposition --- module/network/HTTPChunk.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'module/network/HTTPChunk.py') 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=|\*=(?P.+)'')(?P.*)", 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]) -- cgit v1.2.3 From b40b32ee05f611323a7827fad2a25fa0a28dcb24 Mon Sep 17 00:00:00 2001 From: X3n0m0rph59 Date: Sun, 22 Apr 2012 19:56:17 +0200 Subject: a huge pile of spelling fixes --- module/network/HTTPChunk.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'module/network/HTTPChunk.py') diff --git a/module/network/HTTPChunk.py b/module/network/HTTPChunk.py index 3380fb733..d17177ee7 100644 --- a/module/network/HTTPChunk.py +++ b/module/network/HTTPChunk.py @@ -207,7 +207,7 @@ class HTTPChunk(HTTPRequest): def writeHeader(self, buf): self.header += buf - #@TODO forward headers?, this is possibly unneeeded, when we just parse valid 200 headers + #@TODO forward headers?, this is possibly unneeded, when we just parse valid 200 headers # as first chunk, we will parse the headers if not self.range and self.header.endswith("\r\n\r\n"): self.parseHeader() @@ -236,8 +236,8 @@ class HTTPChunk(HTTPRequest): sleep(self.p.bucket.consumed(size)) else: # Avoid small buffers, increasing sleep time slowly if buffer size gets smaller - # otherwise reduce sleep time percentual (values are based on tests) - # So in general cpu time is saved without reducing bandwith too much + # otherwise reduce sleep time percentile (values are based on tests) + # So in general cpu time is saved without reducing bandwidth too much if size < self.lastSize: self.sleep += 0.002 @@ -253,7 +253,7 @@ class HTTPChunk(HTTPRequest): def parseHeader(self): - """parse data from recieved header""" + """parse data from received header""" for orgline in self.decodeResponse(self.header).splitlines(): line = orgline.strip().lower() if line.startswith("accept-ranges") and "bytes" in line: -- cgit v1.2.3