Revision 381a548c snf-django-lib/snf_django/lib/api/__init__.py

b/snf-django-lib/snf_django/lib/api/__init__.py
90 90

  
91 91
                # Check HTTP method
92 92
                if http_method and request.method != http_method:
93
                    raise faults.BadRequest("Method not allowed")
93
                    raise faults.NotAllowed("Method not allowed",
94
                                            allowed_methods=[http_method])
94 95

  
95 96
                # Get authentication token
96 97
                request.x_auth_token = None
......
231 232
        data = json.dumps(d)
232 233

  
233 234
    response = HttpResponse(data, status=fault.code)
235
    if response.status_code == 405 and hasattr(fault, 'allowed_methods'):
236
        response['Allow'] = ','.join(fault.allowed_methods)
234 237
    update_response_headers(request, response)
235 238
    return response
236 239

  
......
241 244

  
242 245

  
243 246
@api_method(token_required=False, user_required=False)
244
def api_method_not_allowed(request):
245
    raise faults.BadRequest('Method not allowed')
247
def api_method_not_allowed(request, allowed_methods):
248
    raise faults.NotAllowed("Method not allowed",
249
                            allowed_methods=allowed_methods)
246 250

  
247 251

  
248 252
def allow_jsonp(key='callback'):

Also available in: Unified diff