mirror of
https://github.com/kennethreitz/httpbin.git
synced 2026-06-05 14:50:17 +00:00
Merge pull request #250 from phouse512/master
Added 406 unsupported media type response to /image
This commit is contained in:
+1
-1
@@ -669,7 +669,7 @@ def image():
|
||||
elif 'image/png' in accept or 'image/*' in accept:
|
||||
return image_png()
|
||||
else:
|
||||
return status_code(404)
|
||||
return status_code(406) # Unsupported media type
|
||||
|
||||
|
||||
@app.route('/image/png')
|
||||
|
||||
@@ -54,6 +54,14 @@ ROBOT_TXT = """User-agent: *
|
||||
Disallow: /deny
|
||||
"""
|
||||
|
||||
ACCEPTED_MEDIA_TYPES = [
|
||||
'image/webp',
|
||||
'image/svg+xml',
|
||||
'image/jpeg',
|
||||
'image/png',
|
||||
'image/*'
|
||||
]
|
||||
|
||||
ANGRY_ASCII ="""
|
||||
.-''''''-.
|
||||
.' _ _ '.
|
||||
@@ -209,6 +217,13 @@ def status_code(code):
|
||||
'x-more-info': 'http://vimeo.com/22053820'
|
||||
}
|
||||
),
|
||||
406: dict(data=json.dumps({
|
||||
'message': 'Client did not request a supported media type.',
|
||||
'accept': ACCEPTED_MEDIA_TYPES
|
||||
}),
|
||||
headers={
|
||||
'Content-Type': 'application/json'
|
||||
}),
|
||||
407: dict(headers={'Proxy-Authenticate': 'Basic realm="Fake Realm"'}),
|
||||
418: dict( # I'm a teapot!
|
||||
data=ASCII_ART,
|
||||
|
||||
Reference in New Issue
Block a user