Refs #30451 -- Added HttpRequest._set_content_type_params() hook.
This commit is contained in:
parent
87f5d07eed
commit
415e899dc4
|
@ -1,5 +1,3 @@
|
|||
import cgi
|
||||
import codecs
|
||||
import re
|
||||
from io import BytesIO
|
||||
|
||||
|
@ -80,14 +78,8 @@ class WSGIRequest(HttpRequest):
|
|||
self.META['PATH_INFO'] = path_info
|
||||
self.META['SCRIPT_NAME'] = script_name
|
||||
self.method = environ['REQUEST_METHOD'].upper()
|
||||
self.content_type, self.content_params = cgi.parse_header(environ.get('CONTENT_TYPE', ''))
|
||||
if 'charset' in self.content_params:
|
||||
try:
|
||||
codecs.lookup(self.content_params['charset'])
|
||||
except LookupError:
|
||||
pass
|
||||
else:
|
||||
self.encoding = self.content_params['charset']
|
||||
# Set content_type, content_params, and encoding.
|
||||
self._set_content_type_params(environ)
|
||||
try:
|
||||
content_length = int(environ.get('CONTENT_LENGTH'))
|
||||
except (ValueError, TypeError):
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
import cgi
|
||||
import codecs
|
||||
import copy
|
||||
import re
|
||||
from io import BytesIO
|
||||
|
@ -69,6 +71,17 @@ class HttpRequest:
|
|||
def headers(self):
|
||||
return HttpHeaders(self.META)
|
||||
|
||||
def _set_content_type_params(self, meta):
|
||||
"""Set content_type, content_params, and encoding."""
|
||||
self.content_type, self.content_params = cgi.parse_header(meta.get('CONTENT_TYPE', ''))
|
||||
if 'charset' in self.content_params:
|
||||
try:
|
||||
codecs.lookup(self.content_params['charset'])
|
||||
except LookupError:
|
||||
pass
|
||||
else:
|
||||
self.encoding = self.content_params['charset']
|
||||
|
||||
def _get_raw_host(self):
|
||||
"""
|
||||
Return the HTTP host using the environment or request headers. Skip
|
||||
|
|
Loading…
Reference in New Issue