mitsuhiko/flask — Issue #419: request.mimetype always empty
Author: FND
Created: 2012-03-06 09:26:51+00:00
State: open

it appears that `request.mimetype` is always an empty string - which I assume is a bug:

$ cat testcase.py
from flask import Flask, request, make_response

app = Flask(__name__)

@app.route("/")
def root():
response = make_response("mimetype: %s\n\n%s" % (repr(request.mimetype),
request.headers))
response.headers["Content-Type"] = "text/plain"
return response

if __name__ == "__main__":
app.run()

$ python testcase.py &

$ curl -X GET -H "Accept: text/plain" http://127.0.0.1:5000/
mimetype: ''

Accept: text/plain
...

$ curl -X GET -H "Accept: application/json" http://127.0.0.1:5000/
mimetype: ''

Accept: application/json
...

$ curl -X GET -H \
"Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" \
http://127.0.0.1:5000/
mimetype: ''

Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
...

My expectation was that `request.mimetype` be populated based on the Accept header - is this perhaps misguided?

(I've traced this into Werkzeug, but kinda got lost along the way.)