[Solved] Flask request urllib3.exceptions.ProtocolError: (“Connection broken: ConnectionAborted or BrokenPipeError error

When the flask request body is large (roughly estimated to be larger than 1M), the corresponding code on the server side will report 200 when the request is not read from request.json or request.files, but the requester will display

requests.exceptions.ConnectionError: ('Connection aborted.', BrokenPipeError(32, 'Broken pipe'))

or

urllib3.exceptions.ProtocolError: ("Connection broken: ConnectionAbortedError(10053, 'Software on your host aborted an established connection.', None, 10053, None)", ConnectionAbortedError(10053, 'You
The software in the host aborted an established connection. ', None, 10053, None))

The guess is that when the request body is large, if the request is not read into memory, the request dialog will be automatically closed, resulting in an error.

@app.route('/upload', methods=['GET', 'POST'])
def upload():
    if request.method == 'POST':
        f = request.files['file']
return jsonify({"Status": "Sucess"})
    else:
# Reading without request.file or request.json will report an error
        return jsonify({"Status": "Sucess"})