简体   繁体   中英

format for setting a boolean request header in django

I have created a response object in my django view by calling HttpResponse

myResponse = HttpResponse("Here is some text")

and I want to set set the Access-Control-Allow-Credentials header on the response to be true. Should this be set with a python string like I do for other headers

myResponse['Access-Control-Allow-Credentials'] = 'true'

or with a python boolean

myResponse['Access-Control-Allow-Credentials'] = True

or will either work? (and if they will both technically work, is one more "correct")

Go with:

myResponse['Access-Control-Allow-Credentials'] = 'true'

If the Boolean True is serialized as "True" then some browsers might not accept it

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM