mirror of
https://github.com/zulip/zulip.git
synced 2025-10-27 10:03:56 +00:00
request: Use Django 5.2 HttpRequest.get_preferred_type.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
committed by
Tim Abbott
parent
6006ba4c44
commit
d24eab02d2
@@ -33,7 +33,7 @@ from zerver.lib.exceptions import ErrorCode, JsonableError, MissingAuthenticatio
|
||||
from zerver.lib.markdown import get_markdown_requests, get_markdown_time
|
||||
from zerver.lib.per_request_cache import flush_per_request_caches
|
||||
from zerver.lib.rate_limiter import RateLimitResult
|
||||
from zerver.lib.request import RequestNotes, get_preferred_type
|
||||
from zerver.lib.request import RequestNotes
|
||||
from zerver.lib.response import (
|
||||
AsynchronousResponse,
|
||||
json_response,
|
||||
@@ -377,7 +377,7 @@ class LogRequests(MiddlewareMixin):
|
||||
class JsonErrorHandler(MiddlewareMixin):
|
||||
def process_exception(self, request: HttpRequest, exception: Exception) -> HttpResponse | None:
|
||||
if isinstance(exception, MissingAuthenticationError):
|
||||
if get_preferred_type(request, ["application/json", "text/html"]) == "text/html":
|
||||
if request.get_preferred_type(["application/json", "text/html"]) == "text/html":
|
||||
# If this looks like a request from a top-level page in a
|
||||
# browser, send the user to the login page.
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user