]> git.mxchange.org Git - quix0rs-apt-p2p.git/blobdiff - apt_p2p/HTTPServer.py
Make the upload limit a config option.
[quix0rs-apt-p2p.git] / apt_p2p / HTTPServer.py
index b12ca713057c229d604689418298b835a4687885..3a9a3a3177ced71374c3d4c4a51b0979d617bd0c 100644 (file)
@@ -167,7 +167,7 @@ class TopLevel(resource.Resource):
     
     addSlash = True
     
-    def __init__(self, directory, db, manager):
+    def __init__(self, directory, db, manager, uploadLimit):
         """Initialize the instance.
         
         @type directory: L{twisted.python.filepath.FilePath}
@@ -180,6 +180,9 @@ class TopLevel(resource.Resource):
         self.directory = directory
         self.db = db
         self.manager = manager
+        self.uploadLimit = None
+        if uploadLimit > 0:
+            self.uploadLimit = int(uploadLimit*1024)
         self.factory = None
 
     def getHTTPFactory(self):
@@ -188,7 +191,7 @@ class TopLevel(resource.Resource):
             self.factory = channel.HTTPFactory(server.Site(self),
                                                **{'maxPipeline': 10, 
                                                   'betweenRequestsTimeOut': 60})
-            self.factory = ThrottlingFactory(self.factory, writeLimit = 30*1024)
+            self.factory = ThrottlingFactory(self.factory, writeLimit = self.uploadLimit)
             self.factory.protocol = UploadThrottlingProtocol
         return self.factory