summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfsbs <fsbs@users.noreply.github.com>2021-11-05 13:26:49 +0000
committerfsbs <fsbs@users.noreply.github.com>2021-11-05 14:26:49 +0100
commit0ab1dbe654f025e5b37acb5434776e0a6e03070c (patch)
tree2567d3db6ad0b57aedc5c70ccf048ce00e9f1e7f
parent7333f21a094e8904bc0e318963dc70dea0529381 (diff)
downloadpycurl-0ab1dbe654f025e5b37acb5434776e0a6e03070c.tar.gz
bottle test app: fix /header_utf and /postfields
* /header_utf8: don't fail if request header wasn't sent, return '' * /postfields: allow GET requests This makes it possible to test unsetopt() and reset() for HTTPHEADER and HTTPPOST options.
-rw-r--r--tests/app.py3
1 files changed, 2 insertions, 1 deletions
diff --git a/tests/app.py b/tests/app.py
index cf3fe75..62ff574 100644
--- a/tests/app.py
+++ b/tests/app.py
@@ -30,6 +30,7 @@ def forbidden():
def not_found():
return bottle.HTTPResponse('not found', 404)
+@app.route('/postfields', method='get')
@app.route('/postfields', method='post')
def postfields():
return json.dumps(dict(bottle.request.forms))
@@ -88,7 +89,7 @@ def header():
# Thanks to bdarnell for the idea: https://github.com/pycurl/pycurl/issues/124
@app.route('/header_utf8')
def header_utf8():
- header_value = bottle.request.headers[bottle.request.query['h']]
+ header_value = bottle.request.headers.get(bottle.request.query['h'], '' if py3 else b'')
if py3:
# header_value is a string, headers are decoded in latin1
header_value = header_value.encode('latin1').decode('utf8')