Ticket #9943: http-methods-and-statuses.diff
File http-methods-and-statuses.diff, 5.7 KB (added by , 16 years ago) |
---|
-
django/http/__init__.py
393 393 raise Exception("This %s instance cannot tell its position" % self.__class__) 394 394 return sum([len(chunk) for chunk in self._container]) 395 395 396 class HttpResponseRedirect(HttpResponse): 397 status_code = 302 398 396 class _HttpResponseRedirection(HttpResponse): 399 397 def __init__(self, redirect_to): 400 398 HttpResponse.__init__(self) 401 399 self['Location'] = iri_to_uri(redirect_to) 402 400 403 class HttpResponsePermanentRedirect(HttpResponse): 401 class HttpResponseContinue(HttpResponse): 402 status_code = 100 403 404 class HttpResponseSwitchingProtocols(HttpResponse): 405 status_code = 101 406 407 class HttpResponseCreated(HttpResponse): 408 status_code = 201 409 410 class HttpResponseAccepted(HttpResponse): 411 status_code = 202 412 413 class HttpResponseNonAuthoritativeInformation(HttpResponse): 414 status_code = 203 415 416 class HttpResponseNoContent(HttpResponse): 417 status_code = 204 418 419 class HttpResponseResetContent(HttpResponse): 420 status_code = 205 421 422 class HttpResponsePartialContent(HttpResponse): 423 status_code = 206 424 425 class HttpResponseMultipleChoices(HttpResponse): 426 status_code = 300 427 428 class HttpResponsePermanentRedirect(_HttpResponseRedirection): 404 429 status_code = 301 430 HttpResponseMovedPermanently = HttpResponsePermanentRedirect 405 431 432 class HttpResponseRedirect(_HttpResponseRedirection): 433 status_code = 302 434 HttpResponseFound = HttpResponseRedirect 435 436 class HttpResponseSeeOther(_HttpResponseRedirection): 437 status_code = 303 438 439 class HttpResponseNotModified(HttpResponse): 440 status_code = 304 441 442 class HttpResponseUseProxy(_HttpResponseRedirection): 443 status_code = 305 444 445 class HttpResponseTemporaryRedirect(HttpResponse): 446 status_code = 307 447 406 448 def __init__(self, redirect_to): 407 449 HttpResponse.__init__(self) 408 450 self['Location'] = iri_to_uri(redirect_to) 409 451 410 class HttpResponseNotModified(HttpResponse):411 status_code = 304412 413 452 class HttpResponseBadRequest(HttpResponse): 414 453 status_code = 400 415 454 416 class HttpResponse NotFound(HttpResponse):417 status_code = 40 4455 class HttpResponseUnauthorized(HttpResponse): 456 status_code = 401 418 457 419 458 class HttpResponseForbidden(HttpResponse): 420 459 status_code = 403 421 460 461 class HttpResponseNotFound(HttpResponse): 462 status_code = 404 463 422 464 class HttpResponseNotAllowed(HttpResponse): 423 465 status_code = 405 424 466 425 467 def __init__(self, permitted_methods): 426 468 HttpResponse.__init__(self) 427 469 self['Allow'] = ', '.join(permitted_methods) 470 HttpResponseMethodNotAllowed = HttpResponseNotAllowed 428 471 472 class HttpResponseProxyAuthenticationRequired(HttpResponse): 473 status_code = 407 474 475 class HttpResponseRequestTimeout(HttpResponse): 476 status_code = 408 477 478 class HttpResponseConflict(HttpResponse): 479 status_code = 409 480 429 481 class HttpResponseGone(HttpResponse): 430 482 status_code = 410 431 483 432 def __init__(self, *args, **kwargs):433 HttpResponse.__init__(self, *args, **kwargs)484 class HttpResponseLengthRequired(HttpResponse): 485 status_code = 411 434 486 487 class HttpResponsePreconditionFailed(HttpResponse): 488 status_code = 412 489 490 class HttpResponseRequestEntityTooLarge(HttpResponse): 491 status_code = 413 492 493 class HttpResponseRequestURITooLong(HttpResponse): 494 status_code = 414 495 496 class HttpResponseUnsupportedMediaType(HttpResponse): 497 status_code = 415 498 499 class HttpResponseRequestedRangeNotSatisfiable(HttpResponse): 500 status_code = 416 501 502 class HttpResponseExpectationFailed(HttpResponse): 503 status_code = 417 504 435 505 class HttpResponseServerError(HttpResponse): 436 506 status_code = 500 507 HttpResponseInternalServerError = HttpResponseServerError 437 508 438 def __init__(self, *args, **kwargs):439 HttpResponse.__init__(self, *args, **kwargs)509 class HttpResponseNotImplemented(HttpResponse): 510 status_code = 501 440 511 512 class HttpResponseBadGateway(HttpResponse): 513 status_code = 502 514 515 class HttpResponseServiceUnavailable(HttpResponse): 516 status_code = 503 517 518 class HttpResponseGatewayTimeout(HttpResponse): 519 status_code = 504 520 521 class HttpResponseHTTPVersionNotSupported(HttpResponse): 522 status_code = 505 523 441 524 # A backwards compatible alias for HttpRequest.get_host. 442 525 def get_host(request): 443 526 return request.get_host() -
django/views/decorators/http.py
32 32 return wraps(func)(inner) 33 33 return decorator 34 34 35 # Pre-define a specific decorator for each method listed in the HTTP/1.1 RFC: 36 # http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.8 37 38 _require_doc = "Decorator to require that a view only accept the %s method." 39 40 require_CONNECT = require_http_methods(["CONNECT"]) 41 require_CONNECT.__doc__ = _require_doc % "CONNECT" 42 43 require_DELETE = require_http_methods(["DELETE"]) 44 require_DELETE.__doc__ = _require_doc % "DELETE" 45 35 46 require_GET = require_http_methods(["GET"]) 36 require_GET.__doc__ = "Decorator to require that a view only accept the GET method."47 require_GET.__doc__ = _require_doc % "GET" 37 48 49 require_HEAD = require_http_methods(["HEAD"]) 50 require_HEAD.__doc__ = _require_doc % "HEAD" 51 52 require_OPTIONS = require_http_methods(["OPTIONS"]) 53 require_OPTIONS.__doc__ = _require_doc % "OPTIONS" 54 38 55 require_POST = require_http_methods(["POST"]) 39 require_POST.__doc__ = "Decorator to require that a view only accept the POST method." 40 No newline at end of file 56 require_POST.__doc__ = _require_doc % "POST" 57 58 require_PUT = require_http_methods(["PUT"]) 59 require_PUT.__doc__ = _require_doc % "PUT" 60 61 require_TRACE = require_http_methods(["TRACE"]) 62 require_TRACE.__doc__ = _require_doc % "TRACE"