diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-12-29 12:18:51 +0100 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2013-12-29 12:18:51 +0100 |
commit | d007aac6244a63ee49cf155de3c8af1b4b94d4c3 (patch) | |
tree | fb0f71e203841a7867fd405a5ff4a3b71dd3e646 | |
parent | disabled colored log on windows (diff) | |
download | pyload-d007aac6244a63ee49cf155de3c8af1b4b94d4c3.tar.xz |
added auth to request class
-rw-r--r-- | pyload/plugins/Request.py | 11 | ||||
-rw-r--r-- | pyload/plugins/network/CurlRequest.py | 5 | ||||
-rw-r--r-- | pyload/web/package.json | 2 | ||||
-rw-r--r-- | pyload/web/pyload_app.py | 36 |
4 files changed, 33 insertions, 21 deletions
diff --git a/pyload/plugins/Request.py b/pyload/plugins/Request.py index 8e8e0cc6b..9f6fe8c2b 100644 --- a/pyload/plugins/Request.py +++ b/pyload/plugins/Request.py @@ -59,7 +59,16 @@ class Request(object): if name == "": self.options.clear() else: - del self.options[name] + if name in self.options: + del self.options[name] + + def addAuth(self, user, pwd): + """ Adds authentication information to the request """ + self.options["auth"] = user + ":" + pwd + + def removeAuth(self): + """ Removes authentication from the request """ + self.unsetOption("auth") def load(self, uri, *args, **kwargs): """ Loads given resource from given uri. Args and kwargs depends on implementation""" diff --git a/pyload/plugins/network/CurlRequest.py b/pyload/plugins/network/CurlRequest.py index 717590ac5..03c049cf5 100644 --- a/pyload/plugins/network/CurlRequest.py +++ b/pyload/plugins/network/CurlRequest.py @@ -63,7 +63,7 @@ class CurlRequest(Request): self.c.setopt(pycurl.WRITEFUNCTION, self.write) self.c.setopt(pycurl.HEADERFUNCTION, self.writeHeader) - # TODO: addAuth, addHeader + # TODO: addHeader @property def http(self): @@ -138,6 +138,9 @@ class CurlRequest(Request): if "timeout" in options: self.c.setopt(pycurl.LOW_SPEED_TIME, options["timeout"]) + if "auth" in options: + self.c.setopt(pycurl.USERPWD, str(options["auth"])) + def initOptions(self, options): """ Sets same options as available in pycurl """ for k, v in options.iteritems(): diff --git a/pyload/web/package.json b/pyload/web/package.json index 4ea7ce484..4b5ce8788 100644 --- a/pyload/web/package.json +++ b/pyload/web/package.json @@ -18,7 +18,7 @@ "grunt-contrib-clean": "~0.4.0", "grunt-contrib-htmlmin": "~0.1.3", "grunt-contrib-requirejs": "~0.4.1", - "grunt-contrib-imagemin": "~0.1.3", + "grunt-contrib-imagemin": "~0.4.0", "grunt-contrib-watch": "~0.4.0", "grunt-contrib-compress": "~0.5.0", "grunt-rev": "~0.1.0", diff --git a/pyload/web/pyload_app.py b/pyload/web/pyload_app.py index 70ada0b53..32b288e57 100644 --- a/pyload/web/pyload_app.py +++ b/pyload/web/pyload_app.py @@ -1,21 +1,21 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- -""" - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, - or (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see <http://www.gnu.org/licenses/>. - - @author: RaNaN -""" + +############################################################################### +# Copyright(c) 2008-2013 pyLoad Team +# http://www.pyload.org +# +# This file is part of pyLoad. +# pyLoad is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# Subjected to the terms and conditions in LICENSE +# +# @author: RaNaN +############################################################################### + import time from os.path import join, exists @@ -35,8 +35,8 @@ GZIPPED = {} @route('/icons/<path:path>') def serve_icon(path): - # TODO - return redirect('/images/icon.png') + # TODO: send real file, no redirects + return redirect(PREFIX if PREFIX else '/' + '../images/icon.png') # return static_file(path, root=join("tmp", "icons")) |