From a37404f6b9a3486943fa1dbbca35b4a3e9cff77e Mon Sep 17 00:00:00 2001 From: Maitiu O Ciarain Date: Tue, 7 Aug 2018 09:25:00 +0100 Subject: [PATCH 1/3] Make the max_body_size & max_buffer_size configurable --- notebook/notebookapp.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/notebook/notebookapp.py b/notebook/notebookapp.py index 8b0d5b1538..913a8c4fe0 100755 --- a/notebook/notebookapp.py +++ b/notebook/notebookapp.py @@ -240,11 +240,6 @@ def init_settings(self, jupyter_app, kernel_manager, contents_manager, iopub_data_rate_limit=jupyter_app.iopub_data_rate_limit, rate_limit_window=jupyter_app.rate_limit_window, - # maximum request sizes - support saving larger notebooks - # tornado defaults are 100 MiB, we increase it to 0.5 GiB - max_body_size = 512 * 1024 * 1024, - max_buffer_size = 512 * 1024 * 1024, - # authentication cookie_secret=jupyter_app.cookie_secret, login_url=url_path_join(base_url,'/login'), From 090f9c23143b63186ddc42090c4c5bc5e75b19f6 Mon Sep 17 00:00:00 2001 From: Maitiu O Ciarain Date: Tue, 7 Aug 2018 09:26:12 +0100 Subject: [PATCH 2/3] Correctly pass them to the underlying tornado server --- notebook/notebookapp.py | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/notebook/notebookapp.py b/notebook/notebookapp.py index 913a8c4fe0..1a712a0cab 100755 --- a/notebook/notebookapp.py +++ b/notebook/notebookapp.py @@ -775,6 +775,24 @@ def _token_default(self): self._token_generated = True return binascii.hexlify(os.urandom(24)).decode('ascii') + max_body_size = Integer(512 * 1024 * 1024, config=True, + help=""" + Sets the maximum allowed size of the client request body, specified in + the “Content-Length” request header field. If the size in a request + exceeds the configured value, returned to the client a + Malformed HTTP message is returned. + + Note: max_body_size is applied even in streaming mode. + """ + ) + + max_buffer_size = Integer(512 * 1024 * 1024, config=True, + help=""" + Gets or sets the maximum amount of memory, in bytes, that is allocated + for use by the manager of the buffers. + """ + ) + @observe('token') def _token_changed(self, change): self._token_generated = False @@ -1380,7 +1398,9 @@ def init_webapp(self): self.login_handler_class.validate_security(self, ssl_options=ssl_options) self.http_server = httpserver.HTTPServer(self.web_app, ssl_options=ssl_options, - xheaders=self.trust_xheaders) + xheaders=self.trust_xheaders, + max_body_size=self.max_body_size, + max_buffer_size=self.max_buffer_size) success = None for port in random_ports(self.port, self.port_retries+1): From 0827dcb0b5e041c11d15db5bb02f7c86e6382eb7 Mon Sep 17 00:00:00 2001 From: Maitiu O Ciarain Date: Tue, 7 Aug 2018 10:42:06 +0100 Subject: [PATCH 3/3] Fix quotes and tidy up the help messages --- notebook/notebookapp.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/notebook/notebookapp.py b/notebook/notebookapp.py index 1a712a0cab..20be704b63 100755 --- a/notebook/notebookapp.py +++ b/notebook/notebookapp.py @@ -778,9 +778,9 @@ def _token_default(self): max_body_size = Integer(512 * 1024 * 1024, config=True, help=""" Sets the maximum allowed size of the client request body, specified in - the “Content-Length” request header field. If the size in a request - exceeds the configured value, returned to the client a - Malformed HTTP message is returned. + the Content-Length request header field. If the size in a request + exceeds the configured value, a malformed HTTP message is returned to + the client. Note: max_body_size is applied even in streaming mode. """ @@ -789,7 +789,7 @@ def _token_default(self): max_buffer_size = Integer(512 * 1024 * 1024, config=True, help=""" Gets or sets the maximum amount of memory, in bytes, that is allocated - for use by the manager of the buffers. + for use by the buffer manager. """ )