Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7894d01

Browse files
committed
Python: Add test for mimetype/headers priority
1 parent 35334cf commit 7894d01

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

python/ql/test/experimental/library-tests/frameworks/flask/response_test.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,16 @@ def Response5(): # $routeHandler
119119
return resp
120120

121121

122+
@app.route("/content-type/Response6") # $routeSetup="/content-type/Response6"
123+
def Response6(): # $routeHandler
124+
# mimetype argument takes priority over header (and result is text/plain)
125+
# note: capitalization of Content-Type does not matter
126+
resp = Response(
127+
"<h1>hello</h1>", headers={"Content-TYPE": "text/html"}, mimetype="text/plain"
128+
) # $f-:HttpResponse $f-:contentType=text/plain $f-:responseBody="<h1>hello</h1>"
129+
return resp
130+
131+
122132
@app.route("/content-type/Flask-response-class") # $routeSetup="/content-type/Flask-response-class"
123133
def Flask_response_class(): # $routeHandler
124134
# note: flask.Flask.response_class is set to `flask.Response` by default.

0 commit comments

Comments
 (0)