Merge pull request #358 from mattwwarren/post-response-headers-357

add POST to methods kwarg
This commit is contained in:
2017-05-26 06:07:14 -07:00
committed by GitHub
2 changed files with 15 additions and 9 deletions
+1 -1
View File
@@ -337,7 +337,7 @@ def view_status_code(codes):
return status_code(code)
@app.route('/response-headers')
@app.route('/response-headers', methods=['GET', 'POST'])
def response_headers():
"""Returns a set of response headers from the query string """
headers = MultiDict(request.args.items(multi=True))
+14 -8
View File
@@ -119,16 +119,22 @@ class HttpbinTestCase(unittest.TestCase):
return response.data
def test_response_headers_simple(self):
response = self.app.get('/response-headers?animal=dog')
self.assertEqual(response.status_code, 200)
self.assertEqual(response.headers.get_all('animal'), ['dog'])
assert json.loads(response.data.decode('utf-8'))['animal'] == 'dog'
supported_verbs = ['get', 'post']
for verb in supported_verbs:
method = getattr(self.app, verb)
response = method('/response-headers?animal=dog')
self.assertEqual(response.status_code, 200)
self.assertEqual(response.headers.get_all('animal'), ['dog'])
assert json.loads(response.data.decode('utf-8'))['animal'] == 'dog'
def test_response_headers_multi(self):
response = self.app.get('/response-headers?animal=dog&animal=cat')
self.assertEqual(response.status_code, 200)
self.assertEqual(response.headers.get_all('animal'), ['dog', 'cat'])
assert json.loads(response.data.decode('utf-8'))['animal'] == ['dog', 'cat']
supported_verbs = ['get', 'post']
for verb in supported_verbs:
method = getattr(self.app, verb)
response = method('/response-headers?animal=dog&animal=cat')
self.assertEqual(response.status_code, 200)
self.assertEqual(response.headers.get_all('animal'), ['dog', 'cat'])
assert json.loads(response.data.decode('utf-8'))['animal'] == ['dog', 'cat']
def test_get(self):
response = self.app.get('/get', headers={'User-Agent': 'test'})