def alter_old_distutils_request(request: WSGIRequest):
<EOL>body = request.body<EOL>if request.POST or request.FILES:<EOL><INDENT>return<EOL><DEDENT>new_body = BytesIO()<EOL>content_type, opts = parse_header(request.META['<STR_LIT>'].encode('<STR_LIT:ascii>'))<EOL>parts = body.split(b'<STR_LIT>' + opts['<STR_LIT>'] + b'<STR_LIT:\n>')<EOL>for part in parts:<EOL><INDENT>if b'<STR_LIT>' not in part:<EOL><INDENT>continue<EOL><DEDENT>headers, content = part.split(b'<STR_LIT>', <NUM_LIT:1>)<EOL>if not headers:<EOL><INDENT>continue<EOL><DEDENT>new_body.write(b'<STR_LIT>' + opts['<STR_LIT>'] + b'<STR_LIT:\r\n>')<EOL>new_body.write(headers.replace(b'<STR_LIT:\n>', b'<STR_LIT:\r\n>'))<EOL>new_body.write(b'<STR_LIT>')<EOL>new_body.write(content)<EOL>new_body.write(b'<STR_LIT:\r\n>')<EOL><DEDENT>new_body.write(b'<STR_LIT>' + opts['<STR_LIT>'] + b'<STR_LIT>')<EOL>request._body = new_body.getvalue()<EOL>request.META['<STR_LIT>'] = len(request._body)<EOL>if hasattr(request, '<STR_LIT>'):<EOL><INDENT>delattr(request, '<STR_LIT>')<EOL><DEDENT>if hasattr(request, '<STR_LIT>'):<EOL><INDENT>delattr(request, '<STR_LIT>')<EOL><DEDENT>
Alter the request body for compatibility with older distutils clients

    Due to a bug in the Python distutils library, the request post is sent
    using \n as a separator instead of the \r\n that the HTTP spec demands.
    This breaks the Django form parser and therefore we have to write a
    custom parser.

    This bug was fixed in the Python 2.7.4 and 3.4:

    http://bugs.python.org/issue10510