diff options
author | Walter Purcaro <vuolter@gmail.com> | 2014-11-09 03:13:25 +0100 |
---|---|---|
committer | Walter Purcaro <vuolter@gmail.com> | 2014-11-09 03:13:25 +0100 |
commit | a590adbf123452cc51dc187d72d8dc79c04a7be2 (patch) | |
tree | 1c7b24898c02461738272d585726616b9fc19364 | |
parent | Code cosmetics (diff) | |
download | pyload-a590adbf123452cc51dc187d72d8dc79c04a7be2.tar.xz |
[HTTPRequest] Improve load method
-rw-r--r-- | module/network/HTTPRequest.py | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/module/network/HTTPRequest.py b/module/network/HTTPRequest.py index d6fcae7d6..df952a690 100644 --- a/module/network/HTTPRequest.py +++ b/module/network/HTTPRequest.py @@ -181,7 +181,7 @@ class HTTPRequest(): self.getCookies() - def load(self, url, get={}, post={}, referer=True, cookies=True, just_header=False, multipart=False, decode=False): + def load(self, url, get={}, post={}, referer=True, cookies=True, just_header=False, multipart=False, decode=False, follow_location=True, save_cookies=True): """ load and returns a given page """ self.setRequestContext(url, get, post, referer, cookies, multipart) @@ -190,24 +190,27 @@ class HTTPRequest(): self.c.setopt(pycurl.HTTPHEADER, self.headers) - if just_header: + if not follow_location: self.c.setopt(pycurl.FOLLOWLOCATION, 0) + + if just_header: self.c.setopt(pycurl.NOBODY, 1) - self.c.perform() - rep = self.header + self.c.perform() + rep = self.header if just_header else self.getResponse() + + if not follow_location: self.c.setopt(pycurl.FOLLOWLOCATION, 1) - self.c.setopt(pycurl.NOBODY, 0) - else: - self.c.perform() - rep = self.getResponse() + if just_header: + self.c.setopt(pycurl.NOBODY, 0) self.c.setopt(pycurl.POSTFIELDS, "") self.lastEffectiveURL = self.c.getinfo(pycurl.EFFECTIVE_URL) self.code = self.verifyHeader() - self.addCookies() + if save_cookies: + self.addCookies() if decode: rep = self.decodeResponse(rep) |