Revision 2aba7764 snf-django-lib/snf_django/lib/api/__init__.py

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

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

  
96 97
                # Get authentication token
97 98
                request.x_auth_token = None
......
246 247
        data = json.dumps(d)
247 248

  
248 249
    response = HttpResponse(data, status=fault.code)
250
    if response.status_code == 405 and hasattr(fault, 'allowed_methods'):
251
        response['Allow'] = ','.join(fault.allowed_methods)
249 252
    update_response_headers(request, response)
250 253
    return response
251 254

  
......
256 259

  
257 260

  
258 261
@api_method(token_required=False, user_required=False)
259
def api_method_not_allowed(request):
260
    raise faults.BadRequest('Method not allowed')
262
def api_method_not_allowed(request, allowed_methods):
263
    raise faults.NotAllowed("Method not allowed",
264
                            allowed_methods=allowed_methods)
261 265

  
262 266

  
263 267
def allow_jsonp(key='callback'):

Also available in: Unified diff