summaryrefslogtreecommitdiffstats
path: root/module/network
diff options
context:
space:
mode:
Diffstat (limited to 'module/network')
-rw-r--r--module/network/Browser.py8
-rw-r--r--module/network/HTTPChunk.py7
-rw-r--r--module/network/HTTPDownload.py12
-rw-r--r--module/network/HTTPRequest.py13
4 files changed, 29 insertions, 11 deletions
diff --git a/module/network/Browser.py b/module/network/Browser.py
index 6cc907491..adb2cb5d9 100644
--- a/module/network/Browser.py
+++ b/module/network/Browser.py
@@ -95,6 +95,14 @@ class Browser(object):
""" retrieves page """
return self.http.load(url, get, post, ref, cookies, just_header)
+
+ def putHeader(self, name, value):
+ """ add a header to the request """
+ self.http.putHeader(name, value)
+
+ def clearHeaders(self):
+ self.http.clearHeaders()
+
def close(self):
""" cleanup """
if hasattr(self, "http"):
diff --git a/module/network/HTTPChunk.py b/module/network/HTTPChunk.py
index 9ca1be909..2fc48a588 100644
--- a/module/network/HTTPChunk.py
+++ b/module/network/HTTPChunk.py
@@ -36,6 +36,13 @@ class ChunkInfo():
self.resume = False
self.chunks = []
+ def __repr__(self):
+ ret = "ChunkInfo: %s, %s\n" % (self.name, self.size)
+ for i, c in enumerate(self.chunks):
+ ret += "%s# %s\n" % (i, c[1])
+
+ return ret
+
def setSize(self, size):
self.size = int(size)
diff --git a/module/network/HTTPDownload.py b/module/network/HTTPDownload.py
index 4c9d0705d..50b33cd97 100644
--- a/module/network/HTTPDownload.py
+++ b/module/network/HTTPDownload.py
@@ -48,8 +48,6 @@ class HTTPDownload():
self.chunks = []
- self.infoSaved = False # needed for 1 chunk resume
-
try:
self.info = ChunkInfo.load(filename)
self.info.resume = True #resume is only possible with valid info file
@@ -123,6 +121,7 @@ class HTTPDownload():
def _download(self, chunks, resume):
if not resume:
+ self.info.clear()
self.info.addChunk("%s.chunk0" % self.filename, (0, 0)) #create an initial entry
init = HTTPChunk(0, self, None, resume) #initial chunk that will load complete file (if needed)
@@ -134,15 +133,8 @@ class HTTPDownload():
chunksCreated = False
while 1:
- if (chunks == 1) and self.chunkSupport and self.size and not self.infoSaved:
- # if chunk size is one, save info file here to achieve resume support
- self.info.setSize(self.size)
- self.info.createChunks(1)
- self.info.save()
- self.infoSaved = True
-
#need to create chunks
- if not chunksCreated and self.chunkSupport and self.size: #will be set later by first chunk
+ if not chunksCreated and self.chunkSupport and self.size: #will be setted later by first chunk
if not resume:
self.info.setSize(self.size)
diff --git a/module/network/HTTPRequest.py b/module/network/HTTPRequest.py
index 42b7aaf51..cd3635bcf 100644
--- a/module/network/HTTPRequest.py
+++ b/module/network/HTTPRequest.py
@@ -47,6 +47,8 @@ class HTTPRequest():
self.header = ""
+ self.headers = [] #temporary request header
+
self.initHandle()
self.setInterface(interface, proxies)
@@ -150,7 +152,8 @@ class HTTPRequest():
self.header = ""
- #@TODO raw_cookies and some things in old backend, which are apperently not needed
+ if self.headers:
+ self.c.setopt(pycurl.HTTPHEADER, self.headers)
if just_header:
self.c.setopt(pycurl.NOBODY, 1)
@@ -165,6 +168,8 @@ class HTTPRequest():
self.lastEffectiveURL = self.c.getinfo(pycurl.EFFECTIVE_URL)
self.addCookies()
+ self.headers = []
+
return rep
def verifyHeader(self):
@@ -198,6 +203,12 @@ class HTTPRequest():
""" writes header """
self.header += buf
+ def putHeader(self, name, value):
+ self.headers.append("%s: %s" % (name, value))
+
+ def clearHeaders(self):
+ self.headers = []
+
def close(self):
""" cleanup, unusable after this """
self.rep.close()