mirror of
https://github.com/kennethreitz/httpbin.git
synced 2026-06-05 14:50:17 +00:00
Merge pull request #358 from mattwwarren/post-response-headers-357
add POST to methods kwarg
This commit is contained in:
+1
-1
@@ -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
@@ -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'})
|
||||
|
||||
Reference in New Issue
Block a user