[Flask] Cannot get custom header value from request.headers
Tom Vaughan
thomas.david.vaughan at gmail.com
Thu Jul 27 00:51:32 EDT 2017
Hi,
Why would this:
print(request.headers)
print(request.headers.get('Accept', 'No Accept'))
print(request.headers.get('X-Real-Ip', 'No X-Real-Ip'))
cause this output:
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Connection: keep-alive
X-Real-Ip: 172.17.0.1
[...]
text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
No X-Real-Ip
?
Notice how X-Real-Ip and its value are printed when request.headers is
printed, yet the value of X-Real-Ip cannot be fetched from
requests.headers.
Thanks,
-Tom
More information about the Flask
mailing list