6

when i use flask 1.1.1 , the request use http1.1 but the response use http1.0,

from flask import Flask, request, Response
import json

app = Flask(__name__)


@app.route('/', methods=['GET'])
def index():
    print(request.environ.get('SERVER_PROTOCOL'))
    return Response(json.dumps({'hi': 'hello'}))


if __name__ == '__main__':
    app.run(host='127.0.0.1', port=8080, debug=True)

the terminal print is

127.0.0.1 - - [25/Nov/2019 14:42:14] "GET / HTTP/1.1" 200 -
 * Detected change in '/Users/tal/test_redis/flask_ttttt.py', reloading
 * Restarting with stat
 * Debugger is active!
 * Debugger PIN: 840-568-290
HTTP/1.1

and it return

HTTP/1.0 200 OK
Content-Type: text/html; charset=utf-8
Content-Length: 15
Server: Werkzeug/0.15.5 Python/3.7.3

how can i change the http version 1.0 to 1.1?

Yang
  • 61
  • 2
  • 1
    A solution can be found in an answer of a related question: https://stackoverflow.com/a/25829635/463009 – BP8467 Jun 16 '20 at 20:46

0 Answers0