Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tornado max_body_size & max_buffer_size settings #3829

Merged
merged 3 commits into from
Sep 13, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 21 additions & 6 deletions notebook/notebookapp.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down Expand Up @@ -780,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, a malformed HTTP message is returned to
the client.

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 buffer manager.
"""
)

@observe('token')
def _token_changed(self, change):
self._token_generated = False
Expand Down Expand Up @@ -1385,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):
Expand Down