From: Ben Darnell Date: Thu, 3 Jul 2025 21:40:55 +0000 (-0400) Subject: httputil: Restore the host argument to HTTPServerRequest X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=30c4f4ed708e49fea78d8b02cbc0369a30372254;p=thirdparty%2Ftornado.git httputil: Restore the host argument to HTTPServerRequest This argument was mistakenly removed in Tornado 6.5.0 with no warning; it is now back but deprecated. The host header should be used instead. Updates #3468 --- diff --git a/tornado/httputil.py b/tornado/httputil.py index bea9145e..d3dce21f 100644 --- a/tornado/httputil.py +++ b/tornado/httputil.py @@ -459,6 +459,11 @@ class HTTPServerRequest: .. versionchanged:: 4.0 Moved from ``tornado.httpserver.HTTPRequest``. + + .. deprecated:: 6.5.2 + The ``host`` argument to the ``HTTPServerRequest`` constructor is deprecated. Use + ``headers["Host"]`` instead. This argument was mistakenly removed in Tornado 6.5.0 and + temporarily restored in 6.5.2. """ path = None # type: str @@ -474,7 +479,7 @@ class HTTPServerRequest: version: str = "HTTP/1.0", headers: Optional[HTTPHeaders] = None, body: Optional[bytes] = None, - # host: Optional[str] = None, + host: Optional[str] = None, files: Optional[Dict[str, List["HTTPFile"]]] = None, connection: Optional["HTTPConnection"] = None, start_line: Optional["RequestStartLine"] = None, @@ -494,7 +499,7 @@ class HTTPServerRequest: self.protocol = getattr(context, "protocol", "http") try: - self.host = self.headers["Host"] + self.host = host or self.headers["Host"] except KeyError: if version == "HTTP/1.0": # HTTP/1.0 does not require the Host header.