def read_and_discard_input(environ):
if environ.get("<STR_LIT>") or environ.get("<STR_LIT>"):<EOL><INDENT>return<EOL><DEDENT>cl = get_content_length(environ)<EOL>assert cl >= <NUM_LIT:0><EOL>if cl == <NUM_LIT:0>:<EOL><INDENT>return<EOL><DEDENT>READ_ALL = True<EOL>environ["<STR_LIT>"] = <NUM_LIT:1><EOL>if READ_ALL:<EOL><INDENT>environ["<STR_LIT>"] = <NUM_LIT:1><EOL><DEDENT>wsgi_input = environ["<STR_LIT>"]<EOL>if hasattr(wsgi_input, "<STR_LIT>") and hasattr(wsgi_input, "<STR_LIT>"):<EOL><INDENT>if wsgi_input._consumed == <NUM_LIT:0> and wsgi_input.length > <NUM_LIT:0>:<EOL><INDENT>if READ_ALL:<EOL><INDENT>n = wsgi_input.length<EOL><DEDENT>else:<EOL><INDENT>n = <NUM_LIT:1><EOL><DEDENT>body = wsgi_input.read(n)<EOL>_logger.debug(<EOL>"<STR_LIT>".format(<EOL>n, body[:<NUM_LIT:50>]<EOL>)<EOL>)<EOL><DEDENT><DEDENT>elif hasattr(wsgi_input, "<STR_LIT>") and hasattr(wsgi_input._sock, "<STR_LIT>"):<EOL><INDENT>try:<EOL><INDENT>sock = wsgi_input._sock<EOL>timeout = sock.gettimeout()<EOL>sock.settimeout(<NUM_LIT:0>)<EOL>try:<EOL><INDENT>if READ_ALL:<EOL><INDENT>n = cl<EOL><DEDENT>else:<EOL><INDENT>n = <NUM_LIT:1><EOL><DEDENT>body = wsgi_input.read(n)<EOL>_logger.debug(<EOL>"<STR_LIT>".format(<EOL>n, body[:<NUM_LIT:50>]<EOL>)<EOL>)<EOL><DEDENT>except socket.error as se:<EOL><INDENT>_logger.error("<STR_LIT>".format(n, se))<EOL><DEDENT>sock.settimeout(timeout)<EOL><DEDENT>except Exception:<EOL><INDENT>_logger.error("<STR_LIT>".format(sys.exc_info()))<EOL><DEDENT><DEDENT>
Read 1 byte from wsgi.input, if this has not been done yet.

    Returning a response without reading from a request body might confuse the
    WebDAV client.
    This may happen, if an exception like '401 Not authorized', or
    '500 Internal error' was raised BEFORE anything was read from the request
    stream.

    See GC issue 13, issue 23
    See http://groups.google.com/group/paste-users/browse_frm/thread/fc0c9476047e9a47?hl=en

    Note that with persistent sessions (HTTP/1.1) we must make sure, that the
    'Connection: closed' header is set with the response, to prevent reusing
    the current stream.