[Kimchi-devel] [PATCH v5 4/7] Storage volume upload: Control request body size of kimchi

Crístian Viana vianac at linux.vnet.ibm.com
Fri Sep 5 16:44:53 UTC 2014


From: Royce Lv <lvroyce at linux.vnet.ibm.com>

This patch control request body size to be 4G,
when request size exceed, kimchi will response with 413.

Signed-off-by: Royce Lv <lvroyce at linux.vnet.ibm.com>
Signed-off-by: Crístian Viana <vianac at linux.vnet.ibm.com>
---
 src/kimchi.conf.in      | 3 +++
 src/kimchi/config.py.in | 1 +
 src/kimchi/server.py    | 1 +
 src/kimchid.in          | 2 ++
 4 files changed, 7 insertions(+)

diff --git a/src/kimchi.conf.in b/src/kimchi.conf.in
index 2be1a0e..ea39292 100644
--- a/src/kimchi.conf.in
+++ b/src/kimchi.conf.in
@@ -30,6 +30,9 @@
 # at the same network
 #federation = off
 
+# Max request body size in KB, default value is 4GB
+#max_body_size = 4 * 1024 * 1024
+
 [logging]
 # Log directory
 #log_dir = @localstatedir@/log/kimchi
diff --git a/src/kimchi/config.py.in b/src/kimchi/config.py.in
index d403827..91e5f48 100644
--- a/src/kimchi/config.py.in
+++ b/src/kimchi/config.py.in
@@ -255,6 +255,7 @@ def _get_config():
     config.set("server", "ssl_key", "")
     config.set("server", "environment", "production")
     config.set("server", "federation", "off")
+    config.set('server', 'max_body_size', '4*1024*1024')
     config.add_section("logging")
     config.set("logging", "log_dir", paths.log_dir)
     config.set("logging", "log_level", DEFAULT_LOG_LEVEL)
diff --git a/src/kimchi/server.py b/src/kimchi/server.py
index 10f5dff..1c3b360 100644
--- a/src/kimchi/server.py
+++ b/src/kimchi/server.py
@@ -87,6 +87,7 @@ class Server(object):
         # directly. You must go through the proxy.
         cherrypy.server.socket_host = '127.0.0.1'
         cherrypy.server.socket_port = options.cherrypy_port
+        cherrypy.server.max_request_body_size = eval(options.max_body_size)
 
         cherrypy.log.screen = True
         cherrypy.log.access_file = options.access_log
diff --git a/src/kimchid.in b/src/kimchid.in
index 3ed087f..075b744 100644
--- a/src/kimchid.in
+++ b/src/kimchid.in
@@ -86,6 +86,8 @@ def main(options):
     # Add non-option arguments
     setattr(options, 'ssl_cert', config.config.get('server', 'ssl_cert'))
     setattr(options, 'ssl_key', config.config.get('server', 'ssl_key'))
+    setattr(options, 'max_body_size',
+            config.config.get('server', 'max_body_size')*1024)
 
     kimchi.server.main(options)
 
-- 
1.9.3




More information about the Kimchi-devel mailing list