Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion django/contrib/admin/sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ def each_context(self, request):
For sites running on a subpath, use the SCRIPT_NAME value if site_url
hasn't been customized.
"""
script_name = request.META["SCRIPT_NAME"]
script_name = request.meta["SCRIPT_NAME"]
site_url = (
script_name if self.site_url == "/" and script_name else self.site_url
)
Expand Down
2 changes: 1 addition & 1 deletion django/contrib/admindocs/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def process_view(self, request, view_func, view_args, view_kwargs):
"'django.contrib.auth.middleware.AuthenticationMiddleware'."
)
if request.method == "HEAD" and (
request.META.get("REMOTE_ADDR") in settings.INTERNAL_IPS
request.meta.get("REMOTE_ADDR") in settings.INTERNAL_IPS
or (request.user.is_active and request.user.is_staff)
):
response = HttpResponse()
Expand Down
4 changes: 2 additions & 2 deletions django/contrib/auth/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class RemoteUserMiddleware(MiddlewareMixin):
"""

# Name of request header to grab username from. This will be the key as
# used in the request.META dictionary, i.e. the normalization of headers to
# used in the request.meta dictionary, i.e. the normalization of headers to
# all uppercase and the addition of "HTTP_" prefix apply.
header = "REMOTE_USER"
force_logout_if_no_header = True
Expand All @@ -65,7 +65,7 @@ def process_request(self, request):
" before the RemoteUserMiddleware class."
)
try:
username = request.META[self.header]
username = request.meta[self.header]
except KeyError:
# If specified header doesn't exist then remove any existing
# authenticated remote-user, or return (leaving request.user set to
Expand Down
2 changes: 1 addition & 1 deletion django/contrib/messages/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def add_message(request, level, message, extra_tags="", fail_silently=False):
try:
messages = request._messages
except AttributeError:
if not hasattr(request, "META"):
if not hasattr(request, "meta"):
raise TypeError(
"add_message() argument must be an HttpRequest object, not "
"'%s'." % request.__class__.__name__
Expand Down
2 changes: 1 addition & 1 deletion django/core/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class DisallowedRedirect(SuspiciousOperation):

class TooManyFieldsSent(SuspiciousOperation):
"""
The number of fields in a GET or POST request exceeded
The number of fields in a request.query_params or POST request exceeded
settings.DATA_UPLOAD_MAX_NUMBER_FIELDS.
"""

Expand Down
2 changes: 1 addition & 1 deletion django/core/files/uploadhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def handle_raw_input(
:input_data:
An object that supports reading via .read().
:META:
``request.META``.
``request.meta``.
:content_length:
The (integer) value of the Content-Length header from the
client.
Expand Down
32 changes: 16 additions & 16 deletions django/core/handlers/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __init__(self, scope, body_file):
query_string = self.scope.get("query_string", "")
if isinstance(query_string, bytes):
query_string = query_string.decode()
self.META = {
self.meta = {
"REQUEST_METHOD": self.method,
"QUERY_STRING": query_string,
"SCRIPT_NAME": self.script_name,
Expand All @@ -81,16 +81,16 @@ def __init__(self, scope, body_file):
"wsgi.multiprocess": True,
}
if self.scope.get("client"):
self.META["REMOTE_ADDR"] = self.scope["client"][0]
self.META["REMOTE_HOST"] = self.META["REMOTE_ADDR"]
self.META["REMOTE_PORT"] = self.scope["client"][1]
self.meta["REMOTE_ADDR"] = self.scope["client"][0]
self.meta["REMOTE_HOST"] = self.meta["REMOTE_ADDR"]
self.meta["REMOTE_PORT"] = self.scope["client"][1]
if self.scope.get("server"):
self.META["SERVER_NAME"] = self.scope["server"][0]
self.META["SERVER_PORT"] = str(self.scope["server"][1])
self.meta["SERVER_NAME"] = self.scope["server"][0]
self.meta["SERVER_PORT"] = str(self.scope["server"][1])
else:
self.META["SERVER_NAME"] = "unknown"
self.META["SERVER_PORT"] = "0"
# Headers go into META.
self.meta["SERVER_NAME"] = "unknown"
self.meta["SERVER_PORT"] = "0"
# Headers go into meta.
for name, value in self.scope.get("headers", []):
name = name.decode("latin1")
if name == "content-length":
Expand All @@ -102,19 +102,19 @@ def __init__(self, scope, body_file):
# HTTP/2 say only ASCII chars are allowed in headers, but decode
# latin1 just in case.
value = value.decode("latin1")
if corrected_name in self.META:
value = self.META[corrected_name] + "," + value
self.META[corrected_name] = value
if corrected_name in self.meta:
value = self.meta[corrected_name] + "," + value
self.meta[corrected_name] = value
# Pull out request encoding, if provided.
self._set_content_type_params(self.META)
self._set_content_type_params(self.meta)
# Directly assign the body file to be our stream.
self._stream = body_file
# Other bits.
self.resolver_match = None

@cached_property
def GET(self):
return QueryDict(self.META["QUERY_STRING"])
def query_params(self):
return QueryDict(self.meta["QUERY_STRING"])

def _get_scheme(self):
return self.scope.get("scheme") or super()._get_scheme()
Expand All @@ -137,7 +137,7 @@ def _get_files(self):

@cached_property
def COOKIES(self):
return parse_cookie(self.META.get("HTTP_COOKIE", ""))
return parse_cookie(self.meta.get("HTTP_COOKIE", ""))

def close(self):
super().close()
Expand Down
8 changes: 4 additions & 4 deletions django/core/handlers/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ def __init__(self, environ):
# http://test/something and http://test//something being different as
# stated in RFC 3986.
self.path = "%s/%s" % (script_name.rstrip("/"), path_info.replace("/", "", 1))
self.META = environ
self.META["PATH_INFO"] = path_info
self.META["SCRIPT_NAME"] = script_name
self.meta = environ
self.meta["PATH_INFO"] = path_info
self.meta["SCRIPT_NAME"] = script_name
self.method = environ["REQUEST_METHOD"].upper()
# Set content_type, content_params, and encoding.
self._set_content_type_params(environ)
Expand All @@ -83,7 +83,7 @@ def _get_scheme(self):
return self.environ.get("wsgi.url_scheme")

@cached_property
def GET(self):
def query_params(self):
# The WSGI spec says 'QUERY_STRING' may be absent.
raw_query_string = get_bytes_from_wsgi(self.environ, "QUERY_STRING", "")
return QueryDict(raw_query_string, encoding=self._encoding)
Expand Down
14 changes: 7 additions & 7 deletions django/http/multipartparser.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ class MultiPartParser:

boundary_re = _lazy_re_compile(r"[ -~]{0,200}[!-~]")

def __init__(self, META, input_data, upload_handlers, encoding=None):
def __init__(self, meta, input_data, upload_handlers, encoding=None):
"""
Initialize the MultiPartParser object.

:META:
The standard ``META`` dictionary in Django request objects.
:meta:
The standard ``meta`` dictionary in Django request objects.
:input_data:
The raw post data, as a file-like object.
:upload_handlers:
Expand All @@ -69,7 +69,7 @@ def __init__(self, META, input_data, upload_handlers, encoding=None):
The encoding with which to treat the incoming data.
"""
# Content-Type should contain multipart and the boundary information.
content_type = META.get("CONTENT_TYPE", "")
content_type = meta.get("CONTENT_TYPE", "")
if not content_type.startswith("multipart/"):
raise MultiPartParserError("Invalid Content-Type: %s" % content_type)

Expand All @@ -92,7 +92,7 @@ def __init__(self, META, input_data, upload_handlers, encoding=None):
# Content-Length should contain the length of the body we are about
# to receive.
try:
content_length = int(META.get("CONTENT_LENGTH", 0))
content_length = int(meta.get("CONTENT_LENGTH", 0))
except (ValueError, TypeError):
content_length = 0

Expand All @@ -108,7 +108,7 @@ def __init__(self, META, input_data, upload_handlers, encoding=None):
possible_sizes = [x.chunk_size for x in upload_handlers if x.chunk_size]
self._chunk_size = min([2**31 - 4] + possible_sizes)

self._meta = META
self._meta = meta
self._encoding = encoding or settings.DEFAULT_CHARSET
self._content_length = content_length
self._upload_handlers = upload_handlers
Expand Down Expand Up @@ -202,7 +202,7 @@ def _parse(self):
# last boundary.
if settings.DATA_UPLOAD_MAX_NUMBER_FIELDS + 2 < num_post_keys:
raise TooManyFieldsSent(
"The number of GET/POST parameters exceeded "
"The number of query_params/POST parameters exceeded "
"settings.DATA_UPLOAD_MAX_NUMBER_FIELDS."
)

Expand Down
Loading