Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

'Content-Length too' long when uploading file using Tornado

Using a slightly modified version of this Tornado upload app on my development machine, I get the following error from tornado server and a blank page whenever I try to upload large files (+100MB):

[I 130929 07:45:44 httpserver:330] Malformed HTTP request from 127.0.0.1: Content-Length too long

There is no problem uploading files up to ~20MB.

so I'm wondering whether there is any particular file upload limit in Tornado web server? Or does it have someting to do with the machine's available memory. And whatever the reason is, how can I overcome this problem?

like image 871
supermario Avatar asked Sep 29 '13 06:09

supermario


1 Answers

Tornado has a configurable limit on upload size (defaulting to 10MB). You can increase the limit by passing max_buffer_size to the HTTPServer constructor (or Application.listen). However, since Tornado (version 3.1) reads the entire upload body into a single contiguous string in memory, it's dangerous to make the limit too high. One popular alternative is the nginx upload module.

like image 89
Ben Darnell Avatar answered Nov 04 '22 23:11

Ben Darnell