summaryrefslogtreecommitdiff
path: root/django/http/request.py
diff options
context:
space:
mode:
Diffstat (limited to 'django/http/request.py')
-rw-r--r--django/http/request.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/django/http/request.py b/django/http/request.py
index 815544368b..6b51d23e97 100644
--- a/django/http/request.py
+++ b/django/http/request.py
@@ -461,6 +461,31 @@ class HttpHeaders(CaseInsensitiveMapping):
return None
return header.replace("_", "-").title()
+ @classmethod
+ def to_wsgi_name(cls, header):
+ header = header.replace("-", "_").upper()
+ if header in cls.UNPREFIXED_HEADERS:
+ return header
+ return f"{cls.HTTP_PREFIX}{header}"
+
+ @classmethod
+ def to_asgi_name(cls, header):
+ return header.replace("-", "_").upper()
+
+ @classmethod
+ def to_wsgi_names(cls, headers):
+ return {
+ cls.to_wsgi_name(header_name): value
+ for header_name, value in headers.items()
+ }
+
+ @classmethod
+ def to_asgi_names(cls, headers):
+ return {
+ cls.to_asgi_name(header_name): value
+ for header_name, value in headers.items()
+ }
+
class QueryDict(MultiValueDict):
"""