Example #1
0
 def test_unsupported_media_type(self):
     r = http.unsupported_media_type([('Content-Type', 'text/plain')], '415 Unsupported Media Type')
     assert r.status.startswith('415')
     assert r.headers['Content-Type'] == 'text/plain'
     assert '415 Unsupported Media Type' in r.body
     exc = http.UnsupportedMediaType([('Content-Type', 'text/plain')], '415 Unsupported Media Type')
     r = exc.make_response()
     assert r.status.startswith('415')
Example #2
0
def _best_dispatcher_error_response(reason):
    """ Create an HTTP response for a _best_dispatcher failure. """
    if reason == 406:
        return http.not_acceptable([('Content-Type', 'text/plain')], \
                                    '406 Not Acceptable')
    elif reason == 415:
        return http.unsupported_media_type([('Content-Type', 'text/plain')], \
                                           '415 Unsupported Media Type')
Example #3
0
 def test_unsupported_media_type(self):
     r = http.unsupported_media_type([('Content-Type', 'text/plain')],
                                     '415 Unsupported Media Type')
     assert r.status.startswith('415')
     assert r.headers['Content-Type'] == 'text/plain'
     assert '415 Unsupported Media Type' in r.body
     exc = http.UnsupportedMediaType([('Content-Type', 'text/plain')],
                                     '415 Unsupported Media Type')
     r = exc.make_response()
     assert r.status.startswith('415')
Example #4
0
def _best_dispatcher_error_response(reason):
    """ Create an HTTP response for a _best_dispatcher failure. """
    if reason == 406:
        return http.not_acceptable([("Content-Type", "text/plain")], "406 Not Acceptable")
    elif reason == 415:
        return http.unsupported_media_type([("Content-Type", "text/plain")], "415 Unsupported Media Type")