def patch_request_class(app, size=<NUM_LIT:64> * <NUM_LIT> * <NUM_LIT>):
if size is None:<EOL><INDENT>if isinstance(app.request_class.__dict__['<STR_LIT>'],<EOL>property):<EOL><INDENT>return<EOL><DEDENT>size = app.config.get('<STR_LIT>')<EOL><DEDENT>reqclass = app.request_class<EOL>patched = type(reqclass.__name__, (reqclass,),<EOL>{'<STR_LIT>': size})<EOL>app.request_class = patched<EOL>
By default, Flask will accept uploads to an arbitrary size. While Werkzeug
switches uploads from memory to a temporary file when they hit 500 KiB,
it's still possible for someone to overload your disk space with a
gigantic file.

This patches the app's request class's
`~werkzeug.BaseRequest.max_content_length` attribute so that any upload
larger than the given size is rejected with an HTTP error.

.. note::

   In Flask 0.6, you can do this by setting the `MAX_CONTENT_LENGTH`
   setting, without patching the request class. To emulate this behavior,
   you can pass `None` as the size (you must pass it explicitly). That is
   the best way to call this function, as it won't break the Flask 0.6
   functionality if it exists.

.. versionchanged:: 0.1.1

:param app: The app to patch the request class of.
:param size: The maximum size to accept, in bytes. The default is 64 MiB.
             If it is `None`, the app's `MAX_CONTENT_LENGTH` configuration
             setting will be used to patch.